title screen hud hook

This commit is contained in:
toasterbabe 2017-05-13 22:38:06 +01:00
parent f5fa67b7ad
commit ba4275c415
3 changed files with 45 additions and 1 deletions

View file

@ -34,6 +34,10 @@
#include "p_local.h"
#include "p_setup.h"
#ifdef HAVE_BLUA
#include "lua_hud.h"
#endif
// Stage of animation:
// 0 = text, 1 = art screen
static INT32 finalecount;
@ -1524,7 +1528,11 @@ void F_TitleScreenDrawer(void)
// rei|miru: use title pics?
if (hidetitlepics)
#ifdef HAVE_BLUA
goto luahook;
#else
return;
#endif
V_DrawScaledPatch(30, 14, 0, ttwing);
@ -1562,6 +1570,11 @@ void F_TitleScreenDrawer(void)
}
V_DrawScaledPatch(48, 142, 0,ttbanner);
#ifdef HAVE_BLUA
luahook:
LUAh_TitleHUD();
#endif
}
// (no longer) De-Demo'd Title Screen

View file

@ -42,3 +42,4 @@ boolean LUA_HudEnabled(enum hud option);
void LUAh_GameHUD(player_t *stplyr);
void LUAh_ScoresHUD(void);
void LUAh_TitleHUD(void);

View file

@ -87,11 +87,13 @@ static const char *const patch_opt[] = {
enum hudhook {
hudhook_game = 0,
hudhook_scores
hudhook_scores,
hudhook_title
};
static const char *const hudhook_opt[] = {
"game",
"scores",
"title",
NULL};
// alignment types for v.drawString
@ -650,6 +652,9 @@ int LUA_HudLib(lua_State *L)
lua_newtable(L);
lua_rawseti(L, -2, 3); // HUD[2] = scores rendering functions array
lua_newtable(L);
lua_rawseti(L, -2, 4); // HUD[3] = title rendering functions array
lua_setfield(L, LUA_REGISTRYINDEX, "HUD");
luaL_newmetatable(L, META_HUDINFO);
@ -762,4 +767,29 @@ void LUAh_ScoresHUD(void)
hud_running = false;
}
void LUAh_TitleHUD(void)
{
if (!gL || !(hudAvailable & (1<<hudhook_title)))
return;
hud_running = true;
lua_pop(gL, -1);
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -1, 4); // HUD[4] = rendering funcs
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw
I_Assert(lua_istable(gL, -1));
lua_remove(gL, -3); // pop HUD
lua_pushnil(gL);
while (lua_next(gL, -3) != 0) {
lua_pushvalue(gL, -3); // graphics library (HUD[1])
LUA_Call(gL, 1);
}
lua_pop(gL, -1);
hud_running = false;
}
#endif