Add intermission hud hook #10

Merged
Indev450 merged 1 commits from lua-feature-intermissionhud into Saturn 2023-08-05 09:59:34 +02:00
4 changed files with 64 additions and 2 deletions

No files matched your search

+3
View File
@@ -8732,6 +8732,9 @@ struct {
{"TC_ALLWHITE",TC_ALLWHITE},
{"TC_RAINBOW",TC_RAINBOW},
{"TC_BLINK",TC_BLINK},
// Custom client features exposed to lua
{"FEATURE_INTERMISSIONHUD",1},
#endif
{NULL,0}
+1
View File
@@ -43,5 +43,6 @@ boolean LUA_HudEnabled(enum hud option);
void LUAh_GameHUD(player_t *stplyr, huddrawlist_h list);
void LUAh_ScoresHUD(huddrawlist_h list);
void LUAh_IntermissionHUD(huddrawlist_h list);
#endif // __LUA_HUD_H__
+40 -2
View File
@@ -84,11 +84,13 @@ static const char *const patch_opt[] = {
enum hudhook {
hudhook_game = 0,
hudhook_scores
hudhook_scores = 1,
hudhook_intermission = 2,
};
static const char *const hudhook_opt[] = {
"game",
"scores",
"intermission",
NULL};
// alignment types for v.drawString
@@ -987,7 +989,10 @@ int LUA_HudLib(lua_State *L)
lua_rawseti(L, -2, 2); // HUD[2] = game rendering functions array
lua_newtable(L);
lua_rawseti(L, -2, 3); // HUD[2] = scores rendering functions array
lua_rawseti(L, -2, 3); // HUD[3] = scores rendering functions array
lua_newtable(L);
lua_rawseti(L, -2, 4); // HUD[4] = intermission rendering functions array
lua_setfield(L, LUA_REGISTRYINDEX, "HUD");
luaL_newmetatable(L, META_HUDINFO);
@@ -1132,4 +1137,37 @@ void LUAh_ScoresHUD(huddrawlist_h list)
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
}
void LUAh_IntermissionHUD(huddrawlist_h list)
{
if (!gL || !(hudAvailable & (1<<hudhook_intermission)))
return;
lua_pushlightuserdata(gL, list);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
hud_running = true;
lua_settop(gL, 0);
lua_pushcfunction(gL, LUA_GetErrorMessage);
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, 0, 1);
}
lua_settop(gL, 0);
hud_running = false;
lua_pushlightuserdata(gL, NULL);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
}
#endif
+20
View File
@@ -41,6 +41,7 @@
#include "k_kart.h" // colortranslations
#include "console.h" // cons_menuhighlight
#include "lua_hook.h" // IntermissionThinker hook
#include "lua_hud.h" // intermission hud hook
#ifdef HWRENDER
#include "hardware/hw_main.h"
@@ -117,6 +118,11 @@ static INT32 sorttic = -1;
intertype_t intertype = int_none;
#ifdef HAVE_BLUA
static huddrawlist_h luahuddrawlist_intermission = NULL;
#endif
static void Y_FollowIntermission(void);
static void Y_UnloadData(void);
@@ -360,6 +366,15 @@ void Y_IntermissionDrawer(void)
if (usebuffer) // Fade everything out
V_DrawFadeScreen(0xFF00, 22);
#ifdef HAVE_BLUA
if (renderisnewtic)
{
LUA_HUD_ClearDrawList(luahuddrawlist_intermission);
LUAh_IntermissionHUD(luahuddrawlist_intermission);
}
LUA_HUD_DrawList(luahuddrawlist_intermission);
#endif
if (!splitscreen)
whiteplayer = demo.playback ? displayplayers[0] : consoleplayer;
@@ -880,6 +895,11 @@ void Y_StartIntermission(void)
usetile = useinterpic = false;
usebuffer = true;
}
#ifdef HAVE_BLUA
LUA_HUD_DestroyDrawList(luahuddrawlist_intermission);
luahuddrawlist_intermission = LUA_HUD_CreateDrawList();
#endif
}
// ======