mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
lua
This commit is contained in:
parent
4ea3513076
commit
e40bf85a6f
7 changed files with 62 additions and 16 deletions
|
@ -375,11 +375,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
|
|||
|
||||
// draw level title
|
||||
if ((WipeStageTitle && st_overlay)
|
||||
&& *mapheaderinfo[gamemap-1]->lvlttl != '\0'
|
||||
#ifdef HAVE_BLUA
|
||||
&& LUA_HudEnabled(hud_stagetitle)
|
||||
#endif
|
||||
)
|
||||
&& *mapheaderinfo[gamemap-1]->lvlttl != '\0')
|
||||
{
|
||||
ST_runTitleCard();
|
||||
ST_drawWipeTitleCard();
|
||||
|
|
|
@ -47,6 +47,10 @@
|
|||
#include "m_cond.h" // condition sets
|
||||
#include "md5.h" // demo checksums
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
#include "lua_hud.h"
|
||||
#endif
|
||||
|
||||
gameaction_t gameaction;
|
||||
gamestate_t gamestate = GS_NULL;
|
||||
UINT8 ultimatemode = false;
|
||||
|
|
|
@ -43,3 +43,4 @@ 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);
|
||||
|
|
|
@ -92,12 +92,14 @@ static const char *const patch_opt[] = {
|
|||
enum hudhook {
|
||||
hudhook_game = 0,
|
||||
hudhook_scores,
|
||||
hudhook_title
|
||||
hudhook_title,
|
||||
hudhook_titlecard
|
||||
};
|
||||
static const char *const hudhook_opt[] = {
|
||||
"game",
|
||||
"scores",
|
||||
"title",
|
||||
"titlecard",
|
||||
NULL};
|
||||
|
||||
// alignment types for v.drawString
|
||||
|
@ -1052,6 +1054,9 @@ int LUA_HudLib(lua_State *L)
|
|||
|
||||
lua_newtable(L);
|
||||
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");
|
||||
|
||||
luaL_newmetatable(L, META_HUDINFO);
|
||||
|
@ -1189,4 +1194,38 @@ void LUAh_TitleHUD(void)
|
|||
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
|
||||
|
|
|
@ -3234,9 +3234,6 @@ boolean P_SetupLevel(boolean skipprecip)
|
|||
&& WipeStageTitle
|
||||
&& ranspecialwipe != 2
|
||||
&& *mapheaderinfo[gamemap-1]->lvlttl != '\0'
|
||||
#ifdef HAVE_BLUA
|
||||
&& LUA_HudEnabled(hud_stagetitle)
|
||||
#endif
|
||||
)
|
||||
G_PreLevelTitleCard(lt_ticker, true);
|
||||
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
void ST_preDrawTitleCard(void)
|
||||
|
@ -1283,8 +1283,17 @@ void ST_drawTitleCard(void)
|
|||
INT32 zzticker;
|
||||
patch_t *actpat, *zigzag, *zztext;
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
if (!LUA_HudEnabled(hud_stagetitle))
|
||||
goto luahook;
|
||||
#endif
|
||||
|
||||
if (lt_ticker >= (lt_endtime + TICRATE))
|
||||
#ifdef HAVE_BLUA
|
||||
goto luahook;
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
||||
if ((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);
|
||||
|
||||
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
|
||||
// If the HUD is 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))
|
||||
#ifdef HAVE_BLUA
|
||||
&& LUA_HudEnabled(hud_stagetitle)
|
||||
#endif
|
||||
)
|
||||
if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer)))
|
||||
{
|
||||
stagetitle = true;
|
||||
ST_preDrawTitleCard();
|
||||
|
|
|
@ -49,7 +49,6 @@ void ST_doPaletteStuff(void);
|
|||
|
||||
// title card
|
||||
void ST_startTitleCard(void);
|
||||
void ST_preDrawTitleCard(void);
|
||||
void ST_runTitleCard(void);
|
||||
void ST_drawTitleCard(void);
|
||||
void ST_preLevelTitleCardDrawer(tic_t ticker, boolean update);
|
||||
|
|
Loading…
Reference in a new issue