Intermission HUD hook for Lua

This commit is contained in:
Jaime Passos 2019-12-18 18:09:56 -03:00
parent 5f73d48614
commit cb0e14035b
3 changed files with 60 additions and 2 deletions

View file

@ -33,6 +33,9 @@ enum hud {
hud_coopemeralds, hud_coopemeralds,
hud_tokens, hud_tokens,
hud_tabemblems, hud_tabemblems,
// Intermission
hud_intermissiontally,
hud_intermissionmessages,
hud_MAX hud_MAX
}; };
@ -43,4 +46,5 @@ boolean LUA_HudEnabled(enum hud option);
void LUAh_GameHUD(player_t *stplyr); void LUAh_GameHUD(player_t *stplyr);
void LUAh_ScoresHUD(void); void LUAh_ScoresHUD(void);
void LUAh_TitleHUD(void); void LUAh_TitleHUD(void);
void LUAh_TitleCardHUD(player_t *stplyr); void LUAh_TitleCardHUD(player_t *stplayr);
void LUAh_IntermissionHUD(void);

View file

@ -60,6 +60,9 @@ static const char *const hud_disable_options[] = {
"coopemeralds", "coopemeralds",
"tokens", "tokens",
"tabemblems", "tabemblems",
"intermissiontally",
"intermissionmessages",
NULL}; NULL};
enum hudinfo { enum hudinfo {
@ -92,12 +95,14 @@ static const char *const patch_opt[] = {
enum hudhook { enum hudhook {
hudhook_game = 0, hudhook_game = 0,
hudhook_scores, hudhook_scores,
hudhook_intermission,
hudhook_title, hudhook_title,
hudhook_titlecard hudhook_titlecard
}; };
static const char *const hudhook_opt[] = { static const char *const hudhook_opt[] = {
"game", "game",
"scores", "scores",
"intermission",
"title", "title",
"titlecard", "titlecard",
NULL}; NULL};
@ -1228,4 +1233,29 @@ void LUAh_TitleCardHUD(player_t *stplayr)
hud_running = false; hud_running = false;
} }
void LUAh_IntermissionHUD(void)
{
if (!gL || !(hudAvailable & (1<<hudhook_intermission)))
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 #endif

View file

@ -37,6 +37,10 @@
#include "m_cond.h" // condition sets #include "m_cond.h" // condition sets
#include "lua_hook.h" // IntermissionThinker hook #include "lua_hook.h" // IntermissionThinker hook
#ifdef HAVE_BLUA
#include "lua_hud.h"
#endif
#ifdef HWRENDER #ifdef HWRENDER
#include "hardware/hw_main.h" #include "hardware/hw_main.h"
#endif #endif
@ -319,9 +323,17 @@ void Y_IntermissionDrawer(void)
// Bonus loops // Bonus loops
INT32 i; INT32 i;
if (intertype == int_none || rendermode == render_none) if (rendermode == render_none)
return; return;
if (intertype == int_none)
{
#ifdef HAVE_BLUA
LUAh_IntermissionHUD();
#endif
return;
}
if (!usebuffer) if (!usebuffer)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
@ -359,6 +371,12 @@ void Y_IntermissionDrawer(void)
else else
V_DrawPatchFill(bgtile); V_DrawPatchFill(bgtile);
#ifdef HAVE_BLUA
LUAh_IntermissionHUD();
if (!LUA_HudEnabled(hud_intermissiontally))
goto skiptallydrawer;
#endif
if (intertype == int_coop) if (intertype == int_coop)
{ {
INT32 bonusy; INT32 bonusy;
@ -908,6 +926,12 @@ void Y_IntermissionDrawer(void)
} }
} }
#ifdef HAVE_BLUA
skiptallydrawer:
if (!LUA_HudEnabled(hud_intermissionmessages))
return;
#endif
if (timer) if (timer)
V_DrawCenteredString(BASEVIDWIDTH/2, 188, V_YELLOWMAP, V_DrawCenteredString(BASEVIDWIDTH/2, 188, V_YELLOWMAP,
va("start in %d seconds", timer/TICRATE)); va("start in %d seconds", timer/TICRATE));