mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-20 18:01:16 +00:00
Intermission HUD hook for Lua
This commit is contained in:
parent
5f73d48614
commit
cb0e14035b
3 changed files with 60 additions and 2 deletions
|
@ -33,6 +33,9 @@ enum hud {
|
|||
hud_coopemeralds,
|
||||
hud_tokens,
|
||||
hud_tabemblems,
|
||||
// Intermission
|
||||
hud_intermissiontally,
|
||||
hud_intermissionmessages,
|
||||
hud_MAX
|
||||
};
|
||||
|
||||
|
@ -43,4 +46,5 @@ boolean LUA_HudEnabled(enum hud option);
|
|||
void LUAh_GameHUD(player_t *stplyr);
|
||||
void LUAh_ScoresHUD(void);
|
||||
void LUAh_TitleHUD(void);
|
||||
void LUAh_TitleCardHUD(player_t *stplyr);
|
||||
void LUAh_TitleCardHUD(player_t *stplayr);
|
||||
void LUAh_IntermissionHUD(void);
|
||||
|
|
|
@ -60,6 +60,9 @@ static const char *const hud_disable_options[] = {
|
|||
"coopemeralds",
|
||||
"tokens",
|
||||
"tabemblems",
|
||||
|
||||
"intermissiontally",
|
||||
"intermissionmessages",
|
||||
NULL};
|
||||
|
||||
enum hudinfo {
|
||||
|
@ -92,12 +95,14 @@ static const char *const patch_opt[] = {
|
|||
enum hudhook {
|
||||
hudhook_game = 0,
|
||||
hudhook_scores,
|
||||
hudhook_intermission,
|
||||
hudhook_title,
|
||||
hudhook_titlecard
|
||||
};
|
||||
static const char *const hudhook_opt[] = {
|
||||
"game",
|
||||
"scores",
|
||||
"intermission",
|
||||
"title",
|
||||
"titlecard",
|
||||
NULL};
|
||||
|
@ -1228,4 +1233,29 @@ void LUAh_TitleCardHUD(player_t *stplayr)
|
|||
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
|
||||
|
|
|
@ -37,6 +37,10 @@
|
|||
#include "m_cond.h" // condition sets
|
||||
#include "lua_hook.h" // IntermissionThinker hook
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
#include "lua_hud.h"
|
||||
#endif
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_main.h"
|
||||
#endif
|
||||
|
@ -319,9 +323,17 @@ void Y_IntermissionDrawer(void)
|
|||
// Bonus loops
|
||||
INT32 i;
|
||||
|
||||
if (intertype == int_none || rendermode == render_none)
|
||||
if (rendermode == render_none)
|
||||
return;
|
||||
|
||||
if (intertype == int_none)
|
||||
{
|
||||
#ifdef HAVE_BLUA
|
||||
LUAh_IntermissionHUD();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (!usebuffer)
|
||||
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
|
||||
|
||||
|
@ -359,6 +371,12 @@ void Y_IntermissionDrawer(void)
|
|||
else
|
||||
V_DrawPatchFill(bgtile);
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
LUAh_IntermissionHUD();
|
||||
if (!LUA_HudEnabled(hud_intermissiontally))
|
||||
goto skiptallydrawer;
|
||||
#endif
|
||||
|
||||
if (intertype == int_coop)
|
||||
{
|
||||
INT32 bonusy;
|
||||
|
@ -908,6 +926,12 @@ void Y_IntermissionDrawer(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
skiptallydrawer:
|
||||
if (!LUA_HudEnabled(hud_intermissionmessages))
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (timer)
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, 188, V_YELLOWMAP,
|
||||
va("start in %d seconds", timer/TICRATE));
|
||||
|
|
Loading…
Reference in a new issue