This commit is contained in:
Jaime Passos 2019-11-18 13:50:44 -03:00
parent 8ad20c1108
commit 23a5801a09
7 changed files with 62 additions and 16 deletions

View file

@ -375,11 +375,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
// draw level title // draw level title
if ((WipeStageTitle && st_overlay) if ((WipeStageTitle && st_overlay)
&& *mapheaderinfo[gamemap-1]->lvlttl != '\0' && *mapheaderinfo[gamemap-1]->lvlttl != '\0')
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_stagetitle)
#endif
)
{ {
ST_runTitleCard(); ST_runTitleCard();
ST_drawWipeTitleCard(); ST_drawWipeTitleCard();

View file

@ -47,6 +47,10 @@
#include "m_cond.h" // condition sets #include "m_cond.h" // condition sets
#include "md5.h" // demo checksums #include "md5.h" // demo checksums
#ifdef HAVE_BLUA
#include "lua_hud.h"
#endif
gameaction_t gameaction; gameaction_t gameaction;
gamestate_t gamestate = GS_NULL; gamestate_t gamestate = GS_NULL;
UINT8 ultimatemode = false; UINT8 ultimatemode = false;

View file

@ -43,3 +43,4 @@ 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);

View file

@ -92,12 +92,14 @@ static const char *const patch_opt[] = {
enum hudhook { enum hudhook {
hudhook_game = 0, hudhook_game = 0,
hudhook_scores, hudhook_scores,
hudhook_title hudhook_title,
hudhook_titlecard
}; };
static const char *const hudhook_opt[] = { static const char *const hudhook_opt[] = {
"game", "game",
"scores", "scores",
"title", "title",
"titlecard",
NULL}; NULL};
// alignment types for v.drawString // alignment types for v.drawString
@ -1052,6 +1054,9 @@ int LUA_HudLib(lua_State *L)
lua_newtable(L); lua_newtable(L);
lua_rawseti(L, -2, 4); // HUD[3] = title rendering functions array lua_rawseti(L, -2, 4); // HUD[3] = title rendering functions array
lua_newtable(L);
lua_rawseti(L, -2, 5); // HUD[4] = title card rendering functions array
lua_setfield(L, LUA_REGISTRYINDEX, "HUD"); lua_setfield(L, LUA_REGISTRYINDEX, "HUD");
luaL_newmetatable(L, META_HUDINFO); luaL_newmetatable(L, META_HUDINFO);
@ -1189,4 +1194,38 @@ void LUAh_TitleHUD(void)
hud_running = false; hud_running = false;
} }
void LUAh_TitleCardHUD(player_t *stplayr)
{
if (!gL || !(hudAvailable & (1<<hudhook_titlecard)))
return;
hud_running = true;
lua_pop(gL, -1);
lua_getfield(gL, LUA_REGISTRYINDEX, "HUD");
I_Assert(lua_istable(gL, -1));
lua_rawgeti(gL, -1, 5); // HUD[5] = 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_PushUserdata(gL, stplayr, META_PLAYER);
lua_pushinteger(gL, lt_ticker);
lua_pushinteger(gL, (lt_endtime + TICRATE));
lua_pushnil(gL);
while (lua_next(gL, -6) != 0) {
lua_pushvalue(gL, -6); // graphics library (HUD[1])
lua_pushvalue(gL, -6); // stplayr
lua_pushvalue(gL, -6); // lt_ticker
lua_pushvalue(gL, -6); // lt_endtime
LUA_Call(gL, 4);
}
lua_pop(gL, -1);
hud_running = false;
}
#endif #endif

View file

@ -3234,9 +3234,6 @@ boolean P_SetupLevel(boolean skipprecip)
&& WipeStageTitle && WipeStageTitle
&& ranspecialwipe != 2 && ranspecialwipe != 2
&& *mapheaderinfo[gamemap-1]->lvlttl != '\0' && *mapheaderinfo[gamemap-1]->lvlttl != '\0'
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_stagetitle)
#endif
) )
G_PreLevelTitleCard(lt_ticker, true); G_PreLevelTitleCard(lt_ticker, true);

View file

@ -1210,7 +1210,7 @@ void ST_startTitleCard(void)
} }
// //
// What happens before drawing the title card. // What happens before drawing the status bar.
// Which is just setting the HUD translucency. // Which is just setting the HUD translucency.
// //
void ST_preDrawTitleCard(void) void ST_preDrawTitleCard(void)
@ -1283,8 +1283,17 @@ void ST_drawTitleCard(void)
INT32 zzticker; INT32 zzticker;
patch_t *actpat, *zigzag, *zztext; patch_t *actpat, *zigzag, *zztext;
#ifdef HAVE_BLUA
if (!LUA_HudEnabled(hud_stagetitle))
goto luahook;
#endif
if (lt_ticker >= (lt_endtime + TICRATE)) if (lt_ticker >= (lt_endtime + TICRATE))
#ifdef HAVE_BLUA
goto luahook;
#else
return; return;
#endif
if ((lt_ticker-lt_lasttic) > 1) if ((lt_ticker-lt_lasttic) > 1)
lt_ticker = lt_lasttic+1; lt_ticker = lt_lasttic+1;
@ -1324,6 +1333,11 @@ void ST_drawTitleCard(void)
V_DrawCenteredString(subttlxpos - ttlnumxpos, 128, V_PERPLAYER|V_ALLOWLOWERCASE, subttl); V_DrawCenteredString(subttlxpos - ttlnumxpos, 128, V_PERPLAYER|V_ALLOWLOWERCASE, subttl);
lt_lasttic = lt_ticker; lt_lasttic = lt_ticker;
#ifdef HAVE_BLUA
luahook:
LUAh_TitleCardHUD(stplyr);
#endif
} }
// //
@ -2525,11 +2539,7 @@ static void ST_overlayDrawer(void)
// Check for a valid level title // Check for a valid level title
// If the HUD is enabled // If the HUD is enabled
// And, if Lua is running, if the HUD library has the stage title enabled // And, if Lua is running, if the HUD library has the stage title enabled
if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer)) if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer)))
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_stagetitle)
#endif
)
{ {
stagetitle = true; stagetitle = true;
ST_preDrawTitleCard(); ST_preDrawTitleCard();

View file

@ -49,7 +49,6 @@ void ST_doPaletteStuff(void);
// title card // title card
void ST_startTitleCard(void); void ST_startTitleCard(void);
void ST_preDrawTitleCard(void);
void ST_runTitleCard(void); void ST_runTitleCard(void);
void ST_drawTitleCard(void); void ST_drawTitleCard(void);
void ST_preLevelTitleCardDrawer(tic_t ticker, boolean update); void ST_preLevelTitleCardDrawer(tic_t ticker, boolean update);