From 295bf081a75206afd46d41f203726c5eb5180b28 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Tue, 30 Oct 2018 18:24:03 +0100 Subject: [PATCH 1/5] A few additions to the hud library --- src/hu_stuff.c | 68 +++--------------------------------------------- src/k_kart.c | 54 ++++++++++++++++++++++++++++++++------ src/lua_hud.h | 29 +++++++-------------- src/lua_hudlib.c | 48 ++++++++++++++++++++++------------ 4 files changed, 91 insertions(+), 108 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index b28793b7f..a48b83858 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -109,8 +109,6 @@ static patch_t *crosshair[HU_CROSSHAIRS]; // 3 precached crosshair graphics // protos. // ------- static void HU_DrawRankings(void); -static void HU_DrawCoopOverlay(void); -static void HU_DrawNetplayCoopOverlay(void); //====================================================================== // KEYBOARD LAYOUTS FOR ENTERING TEXT @@ -2112,11 +2110,11 @@ void HU_Drawer(void) if (LUA_HudEnabled(hud_rankings)) #endif HU_DrawRankings(); - if (gametype == GT_COOP) - HU_DrawNetplayCoopOverlay(); + //if (gametype == GT_COOP) + // HU_DrawNetplayCoopOverlay(); } - else - HU_DrawCoopOverlay(); + //else + //HU_DrawCoopOverlay(); #ifdef HAVE_BLUA LUAh_ScoresHUD(); #endif @@ -2787,64 +2785,6 @@ static void HU_DrawRankings(void) HU_DrawSpectatorTicker(); } -static void HU_DrawCoopOverlay(void) -{ - if (token -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_tokens) -#endif - ) - { - V_DrawString(168, 176, 0, va("- %d", token)); - V_DrawSmallScaledPatch(148, 172, 0, tokenicon); - } - -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_tabemblems)) -#endif - if (!modifiedgame || savemoddata) - { - V_DrawString(160, 144, 0, va("- %d/%d", M_CountEmblems(), numemblems+numextraemblems)); - V_DrawScaledPatch(128, 144 - SHORT(emblemicon->height)/4, 0, emblemicon); - } - -#ifdef HAVE_BLUA - if (!LUA_HudEnabled(hud_coopemeralds)) - return; -#endif - - if (emeralds & EMERALD1) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8 , (BASEVIDHEIGHT/3)-32, 0, emeraldpics[0]); - if (emeralds & EMERALD2) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8+24, (BASEVIDHEIGHT/3)-16, 0, emeraldpics[1]); - if (emeralds & EMERALD3) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8+24, (BASEVIDHEIGHT/3)+16, 0, emeraldpics[2]); - if (emeralds & EMERALD4) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8 , (BASEVIDHEIGHT/3)+32, 0, emeraldpics[3]); - if (emeralds & EMERALD5) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8-24, (BASEVIDHEIGHT/3)+16, 0, emeraldpics[4]); - if (emeralds & EMERALD6) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8-24, (BASEVIDHEIGHT/3)-16, 0, emeraldpics[5]); - if (emeralds & EMERALD7) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8 , (BASEVIDHEIGHT/3) , 0, emeraldpics[6]); -} - -static void HU_DrawNetplayCoopOverlay(void) -{ - int i; - -#ifdef HAVE_BLUA - if (!LUA_HudEnabled(hud_coopemeralds)) - return; -#endif - - for (i = 0; i < 7; ++i) - { - if (emeralds & (1 << i)) - V_DrawScaledPatch(20 + (i * 20), 6, 0, emeraldpics[i]); - } -} - // Interface to CECHO settings for the outside world, avoiding the // expense (and security problems) of going via the console buffer. diff --git a/src/k_kart.c b/src/k_kart.c index 2ce2d0e12..9fe1d9df2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -20,6 +20,7 @@ #include "m_cond.h" #include "k_kart.h" #include "f_finale.h" +#include "lua_hud.h" // For Lua hud checks // SOME IMPORTANT VARIABLES DEFINED IN DOOMDEF.H: // gamespeed is cc (0 for easy, 1 for normal, 2 for hard) @@ -7556,7 +7557,12 @@ void K_drawKartHUD(void) } if (splitscreen == 2) // Player 4 in 3P is the minimap :p + { + #ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_minimap)) + #endif K_drawKartMinimap(); + } // Draw full screen stuff that turns off the rest of the HUD if (mapreset && stplyr == &players[displayplayer]) @@ -7581,25 +7587,45 @@ void K_drawKartHUD(void) K_drawKartPlayerCheck(); if (splitscreen == 0 && cv_kartminimap.value) - K_drawKartMinimap(); // 3P splitscreen is handled above + { + #ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_minimap)) + #endif + K_drawKartMinimap(); // 3P splitscreen is handled above + + } // Draw the item window - K_drawKartItem(); + #ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_item)) + #endif + K_drawKartItem(); // Draw WANTED status if (G_BattleGametype()) - K_drawKartWanted(); + { + #ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_wanted)) + #endif + K_drawKartWanted(); + } // If not splitscreen, draw... if (!splitscreen) { // Draw the timestamp - K_drawKartTimestamp(stplyr->realtime, TIME_X, TIME_Y, gamemap, true); + #ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_time)) + #endif + K_drawKartTimestamp(stplyr->realtime, TIME_X, TIME_Y, gamemap, true); if (!modeattacking) { // The top-four faces on the left - isfreeplay = K_drawKartPositionFaces(); + #ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_gamerankings)) + #endif + isfreeplay = K_drawKartPositionFaces(); } } @@ -7608,12 +7634,18 @@ void K_drawKartHUD(void) if (G_RaceGametype()) // Race-only elements { // Draw the lap counter - K_drawKartLaps(); + #ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_gametypeinfo)) + #endif + K_drawKartLaps(); if (!splitscreen) { // Draw the speedometer // TODO: Make a better speedometer. + #ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_speedometer)) + #endif K_drawKartSpeedometer(); } @@ -7622,7 +7654,10 @@ void K_drawKartHUD(void) else if (!modeattacking) { // Draw the numerical position - K_DrawKartPositionNum(stplyr->kartstuff[k_position]); + #ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_position)) + #endif + K_DrawKartPositionNum(stplyr->kartstuff[k_position]); } else //if (!(demoplayback && hu_showscores)) { @@ -7633,7 +7668,10 @@ void K_drawKartHUD(void) else if (G_BattleGametype()) // Battle-only { // Draw the hits left! - K_drawKartBumpersOrKarma(); + #ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_gametypeinfo)) + #endif + K_drawKartBumpersOrKarma(); } } diff --git a/src/lua_hud.h b/src/lua_hud.h index ba0a1d894..ea8c3ce9f 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -13,26 +13,17 @@ enum hud { hud_stagetitle = 0, hud_textspectator, - // Singleplayer / Co-op - hud_score, + hud_time, - hud_rings, - hud_lives, - // Match / CTF / Tag / Ringslinger - hud_weaponrings, - hud_powerstones, - // NiGHTS mode - hud_nightslink, - hud_nightsdrill, - hud_nightsrings, - hud_nightsscore, - hud_nightstime, - hud_nightsrecords, - // TAB scores overlays - hud_rankings, - hud_coopemeralds, - hud_tokens, - hud_tabemblems, + hud_gametypeinfo, + hud_minimap, + hud_item, + hud_position, + hud_gamerankings, // Rankings to the left + hud_wanted, + hud_speedometer, + hud_rankings, // Tab rankings + hud_MAX }; diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index e8e9e173d..5182a40ab 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -39,25 +39,15 @@ static const char *const hud_disable_options[] = { "stagetitle", "textspectator", - "score", "time", - "rings", - "lives", - - "weaponrings", - "powerstones", - - "nightslink", - "nightsdrill", - "nightsrings", - "nightsscore", - "nightstime", - "nightsrecords", - + "gametypeinfo", // Bumpers / Karma / Laps depending on gametype + "minimap", + "item", + "position", + "gamerankings", // Gametype rankings to the left + "wanted", + "speedometer", "rankings", - "coopemeralds", - "tokens", - "tabemblems", NULL}; enum hudinfo { @@ -584,6 +574,15 @@ static int libd_renderer(lua_State *L) return 1; } +// Lat': Get cv_translucenthud's value for HUD rendering as a normal V_xxTRANS int +// Could as well be thrown in global vars for ease of access but I guess it makes sense for it to be a HUD fn +static int libd_getlocaltransflag(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, (10-cv_translucenthud.value)*V_10TRANS); // A bit weird that it's called "translucenthud" yet 10 is fully opaque :V + return 1; +} + static luaL_Reg lib_draw[] = { {"patchExists", libd_patchExists}, {"cachePatch", libd_cachePatch}, @@ -601,6 +600,7 @@ static luaL_Reg lib_draw[] = { {"dupx", libd_dupx}, {"dupy", libd_dupy}, {"renderer", libd_renderer}, + {"localTransFlag", libd_getlocaltransflag}, {NULL, NULL} }; @@ -624,6 +624,19 @@ static int lib_huddisable(lua_State *L) return 0; } +// 30/10/18: Lat': Why the FUCK is this NOT in vanilla +static int LUA_IsHUDEnabled(lua_State *L) +{ + enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); + lua_settop(L, 2); + if (!gL || hud_enabled[option/8] & (1<<(option%8))) + lua_pushboolean(L, true); + else + lua_pushboolean(L, false); + + return 1; +} + // add a HUD element for rendering static int lib_hudadd(lua_State *L) { @@ -648,6 +661,7 @@ static int lib_hudadd(lua_State *L) static luaL_Reg lib_hud[] = { {"enable", lib_hudenable}, {"disable", lib_huddisable}, + {"enabled", LUA_IsHUDEnabled}, {"add", lib_hudadd}, {NULL, NULL} }; From 7c5ccd7019ce01be10e0ee0e426656d30b9475b9 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Tue, 30 Oct 2018 23:08:58 +0100 Subject: [PATCH 2/5] Removed some useless stuff --- src/lua_hudlib.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 5182a40ab..e12eb2d80 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -574,7 +574,7 @@ static int libd_renderer(lua_State *L) return 1; } -// Lat': Get cv_translucenthud's value for HUD rendering as a normal V_xxTRANS int +// Lat': Get cv_translucenthud's value for HUD rendering as a normal V_xxTRANS int instead of V_HUDTRANS. This is useful if we want to work from that transparency value // Could as well be thrown in global vars for ease of access but I guess it makes sense for it to be a HUD fn static int libd_getlocaltransflag(lua_State *L) { @@ -625,11 +625,10 @@ static int lib_huddisable(lua_State *L) } // 30/10/18: Lat': Why the FUCK is this NOT in vanilla -static int LUA_IsHUDEnabled(lua_State *L) +static int lib_hudenabled(lua_State *L) { enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); - lua_settop(L, 2); - if (!gL || hud_enabled[option/8] & (1<<(option%8))) + if (hud_enabled[option/8] & (1<<(option%8))) lua_pushboolean(L, true); else lua_pushboolean(L, false); @@ -661,7 +660,7 @@ static int lib_hudadd(lua_State *L) static luaL_Reg lib_hud[] = { {"enable", lib_hudenable}, {"disable", lib_huddisable}, - {"enabled", LUA_IsHUDEnabled}, + {"enabled", LUA_hudenabled}, {"add", lib_hudadd}, {NULL, NULL} }; From c7b8836f90cb50e114bf28d669df9e20548537b1 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Tue, 30 Oct 2018 23:10:56 +0100 Subject: [PATCH 3/5] I'm a genius and forgot to rename the stuff correctly --- src/lua_hudlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index e12eb2d80..63d8c2670 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -660,7 +660,7 @@ static int lib_hudadd(lua_State *L) static luaL_Reg lib_hud[] = { {"enable", lib_hudenable}, {"disable", lib_huddisable}, - {"enabled", LUA_hudenabled}, + {"enabled", lib_hudenabled}, {"add", lib_hudadd}, {NULL, NULL} }; From f0a438899896268453da3dd7df9b4d13cfef35fe Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Wed, 31 Oct 2018 17:14:32 +0100 Subject: [PATCH 4/5] I forgot a }, you may slap me. --- src/hu_stuff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index b43373064..e4eccadf9 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2114,7 +2114,8 @@ void HU_Drawer(void) #ifdef HAVE_BLUA LUAh_ScoresHUD(); #endif - } + } + } if (gamestate != GS_LEVEL) return; From d52d9d4c715a9df8fcfe1eeef07ec90be0730f7c Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 3 Nov 2018 22:24:45 +0100 Subject: [PATCH 5/5] Remove indents on #ifdefs and take K_drawInput in the hud_position check --- src/k_kart.c | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 08c747bc5..cce899664 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6432,6 +6432,11 @@ static boolean K_drawKartPositionFaces(void) if (numplayersingame <= 1) return true; + +#ifdef HAVE_BLUA + if (!LUA_HudEnabled(hud_minirankings)) + return false; // Don't proceed but still return true for free play above if HUD is disabled. +#endif for (j = 0; j < numplayersingame; j++) { @@ -7547,9 +7552,9 @@ void K_drawKartHUD(void) if (splitscreen == 2) // Player 4 in 3P is the minimap :p { - #ifdef HAVE_BLUA +#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_minimap)) - #endif +#endif K_drawKartMinimap(); } @@ -7577,25 +7582,25 @@ void K_drawKartHUD(void) if (splitscreen == 0 && cv_kartminimap.value) { - #ifdef HAVE_BLUA +#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_minimap)) - #endif +#endif K_drawKartMinimap(); // 3P splitscreen is handled above } // Draw the item window - #ifdef HAVE_BLUA +#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_item)) - #endif +#endif K_drawKartItem(); // Draw WANTED status if (G_BattleGametype()) { - #ifdef HAVE_BLUA +#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_wanted)) - #endif +#endif K_drawKartWanted(); } @@ -7603,17 +7608,17 @@ void K_drawKartHUD(void) if (!splitscreen) { // Draw the timestamp - #ifdef HAVE_BLUA +#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_time)) - #endif +#endif K_drawKartTimestamp(stplyr->realtime, TIME_X, TIME_Y, gamemap, true); if (!modeattacking) { // The top-four faces on the left - #ifdef HAVE_BLUA + /*#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_minirankings)) - #endif + #endif*/ isfreeplay = K_drawKartPositionFaces(); } } @@ -7623,18 +7628,18 @@ void K_drawKartHUD(void) if (G_RaceGametype()) // Race-only elements { // Draw the lap counter - #ifdef HAVE_BLUA +#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_gametypeinfo)) - #endif +#endif K_drawKartLaps(); if (!splitscreen) { // Draw the speedometer // TODO: Make a better speedometer. - #ifdef HAVE_BLUA +#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_speedometer)) - #endif +#endif K_drawKartSpeedometer(); } @@ -7643,23 +7648,26 @@ void K_drawKartHUD(void) else if (!modeattacking) { // Draw the numerical position - #ifdef HAVE_BLUA +#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_position)) - #endif +#endif K_DrawKartPositionNum(stplyr->kartstuff[k_position]); } else //if (!(demoplayback && hu_showscores)) { // Draw the input UI - K_drawInput(); +#ifdef HAVE_BLUA + if (LUA_HudEnabled(hud_position)) +#endif + K_drawInput(); } } else if (G_BattleGametype()) // Battle-only { // Draw the hits left! - #ifdef HAVE_BLUA +#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_gametypeinfo)) - #endif +#endif K_drawKartBumpersOrKarma(); } }