mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 12:21:19 +00:00
Merge branch 'Lua-video-lib-expansion' into 'next'
Lua video lib expansion New video/drawer library functions for hud.add to use: v.width() and v.height() return the screen width and height respectively (in other words you get the screen resolution), while v.renderer() returns the string for the renderer used ("software", "opengl", or "none"). Possibly add more stuff later, but for now these things at the least can be merged in next See merge request !40
This commit is contained in:
commit
891c7843ca
1 changed files with 31 additions and 1 deletions
|
@ -16,7 +16,9 @@
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
#include "st_stuff.h" // hudinfo[]
|
#include "st_stuff.h" // hudinfo[]
|
||||||
#include "g_game.h"
|
#include "g_game.h"
|
||||||
|
#include "i_video.h" // rendermode
|
||||||
#include "p_local.h" // camera_t
|
#include "p_local.h" // camera_t
|
||||||
|
#include "screen.h" // screen width/height
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "w_wad.h"
|
#include "w_wad.h"
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
|
@ -486,7 +488,7 @@ static int libd_getColormap(lua_State *L)
|
||||||
INT32 skinnum = TC_DEFAULT;
|
INT32 skinnum = TC_DEFAULT;
|
||||||
skincolors_t color = luaL_optinteger(L, 2, 0);
|
skincolors_t color = luaL_optinteger(L, 2, 0);
|
||||||
UINT8* colormap = NULL;
|
UINT8* colormap = NULL;
|
||||||
//HUDSAFE
|
HUDONLY
|
||||||
if (lua_isnoneornil(L, 1))
|
if (lua_isnoneornil(L, 1))
|
||||||
; // defaults to TC_DEFAULT
|
; // defaults to TC_DEFAULT
|
||||||
else if (lua_type(L, 1) == LUA_TNUMBER) // skin number
|
else if (lua_type(L, 1) == LUA_TNUMBER) // skin number
|
||||||
|
@ -510,6 +512,31 @@ static int libd_getColormap(lua_State *L)
|
||||||
return 1;
|
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
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
static luaL_Reg lib_draw[] = {
|
static luaL_Reg lib_draw[] = {
|
||||||
{"patchExists", libd_patchExists},
|
{"patchExists", libd_patchExists},
|
||||||
{"cachePatch", libd_cachePatch},
|
{"cachePatch", libd_cachePatch},
|
||||||
|
@ -521,6 +548,9 @@ static luaL_Reg lib_draw[] = {
|
||||||
{"drawString", libd_drawString},
|
{"drawString", libd_drawString},
|
||||||
{"stringWidth", libd_stringWidth},
|
{"stringWidth", libd_stringWidth},
|
||||||
{"getColormap", libd_getColormap},
|
{"getColormap", libd_getColormap},
|
||||||
|
{"width", libd_width},
|
||||||
|
{"height", libd_height},
|
||||||
|
{"renderer", libd_renderer},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue