From dafe0ccd11b321546dbf5728d510c98f51db2ce0 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 31 Jan 2016 21:53:14 +0000 Subject: [PATCH 1/3] Added v.width(), v.height() and v.renderer() to Lua's drawer/video library --- src/lua_hudlib.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 5a83d95b..fa15b9be 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -16,7 +16,9 @@ #include "r_local.h" #include "st_stuff.h" // hudinfo[] #include "g_game.h" +#include "i_video.h" // rendermode #include "p_local.h" // camera_t +#include "screen.h" // screen width/height #include "v_video.h" #include "w_wad.h" #include "z_zone.h" @@ -510,6 +512,30 @@ static int libd_getColormap(lua_State *L) return 1; } +static int libd_width(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, vid.width); // push screen width + return 1; +} + +static int libd_height(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, vid.height); // push screen height + return 1; +} + +static int libd_renderer(lua_State *L) +{ + HUDONLY + if (rendermode == render_opengl) // OpenGL renderer + lua_pushliteral(L, "opengl"); + else // Software renderer + lua_pushliteral(L, "software"); + return 1; +} + static luaL_Reg lib_draw[] = { {"patchExists", libd_patchExists}, {"cachePatch", libd_cachePatch}, @@ -521,6 +547,9 @@ static luaL_Reg lib_draw[] = { {"drawString", libd_drawString}, {"stringWidth", libd_stringWidth}, {"getColormap", libd_getColormap}, + {"width", libd_width}, + {"height", libd_height}, + {"renderer", libd_renderer}, {NULL, NULL} }; From 04528eb3e64e931588e33c48d58a2c3201875e00 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 31 Jan 2016 22:15:17 +0000 Subject: [PATCH 2/3] MonsterIestyn: what about render_none? --- src/lua_hudlib.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index fa15b9be..0ba7b3d2 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -529,10 +529,11 @@ static int libd_height(lua_State *L) static int libd_renderer(lua_State *L) { HUDONLY - if (rendermode == render_opengl) // OpenGL renderer - lua_pushliteral(L, "opengl"); - else // Software renderer - lua_pushliteral(L, "software"); + switch (rendermode) { + case render_opengl: lua_pushliteral(L, "opengl"); break; // OpenGL renderer + case render_soft: lua_pushliteral(L, "software"); break; // Software renderer + default: lua_pushliteral(L, "none"); break; // render_none (for dedicated), in case there's any reason this should be run + } return 1; } From d1b89c9320f98cfe2bf514fe7dbd1890c4f21403 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 31 Jan 2016 22:52:02 +0000 Subject: [PATCH 3/3] Quick fix for another drawer lib function while I'm here, cough --- src/lua_hudlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 0ba7b3d2..325f00b0 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -488,7 +488,7 @@ static int libd_getColormap(lua_State *L) INT32 skinnum = TC_DEFAULT; skincolors_t color = luaL_optinteger(L, 2, 0); UINT8* colormap = NULL; - //HUDSAFE + HUDONLY if (lua_isnoneornil(L, 1)) ; // defaults to TC_DEFAULT else if (lua_type(L, 1) == LUA_TNUMBER) // skin number