From a73de55f9671309d7d08de8aba3e2c6cf1815e0c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 May 2025 15:20:42 +0200 Subject: [PATCH] also put votescreen patches into votescreen struct + more cleanup --- src/p_setup.c | 20 +++---- src/y_inter.c | 152 ++++++++++++++++++++++++++++++++++---------------- src/y_inter.h | 20 +++++-- 3 files changed, 130 insertions(+), 62 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 51f7312dc..3ab1f8816 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3197,33 +3197,33 @@ static boolean P_CheckMapReplacements(char *name) static boolean P_CheckVoteReplacements(char *name) { // widescreen patch Race - if (!VoteScreen.wideracereplaced && !memcmp(name, "INTERSCW", 8)) + if (!VoteScreen.replaced.widerace && !memcmp(name, "INTERSCW", 8)) { - VoteScreen.wideracereplaced = true; + VoteScreen.replaced.widerace = true; return false; } - if (!VoteScreen.racereplaced && !memcmp(name, "INTERSCR", 8)) + if (!VoteScreen.replaced.race && !memcmp(name, "INTERSCR", 8)) { - VoteScreen.racereplaced = true; + VoteScreen.replaced.race = true; return false; } // widescreen patch Battle - if (!VoteScreen.widebattlereplaced && !memcmp(name, "BATTLSCW", 8)) + if (!VoteScreen.replaced.widebattle && !memcmp(name, "BATTLSCW", 8)) { - VoteScreen.widebattlereplaced = true; + VoteScreen.replaced.widebattle = true; return false; } - if (!VoteScreen.battlereplaced && !memcmp(name, "BATTLSCR", 8)) + if (!VoteScreen.replaced.battle && !memcmp(name, "BATTLSCR", 8)) { - VoteScreen.battlereplaced = true; + VoteScreen.replaced.battle = true; return false; } - if (VoteScreen.wideracereplaced && VoteScreen.racereplaced - && VoteScreen.widebattlereplaced && VoteScreen.battlereplaced) + if (VoteScreen.replaced.widerace && VoteScreen.replaced.race + && VoteScreen.replaced.widebattle && VoteScreen.replaced.battle) { return true; } diff --git a/src/y_inter.c b/src/y_inter.c index 856ca3ac7..ce2b3081c 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -66,9 +66,6 @@ static INT32 intertic; static INT32 endtic = -1; static INT32 sorttic = -1; -// votescreen stuff -votescreen_t VoteScreen = {0}; - intertype_t intertype = int_none; static huddrawlist_h luahuddrawlist_intermission = NULL; @@ -106,17 +103,13 @@ typedef struct boolean loaded; } y_voteclient; +// votescreen stuff +votescreen_t VoteScreen = {0}; + static y_votelvlinfo levelinfo[5]; static y_voteclient voteclient; static INT32 votetic; static INT32 voteendtic = -1; -static patch_t *cursor = NULL; -static patch_t *cursor1 = NULL; -static patch_t *cursor2 = NULL; -static patch_t *cursor3 = NULL; -static patch_t *cursor4 = NULL; -static patch_t *randomlvl = NULL; -static patch_t *rubyicon = NULL; static void Y_UnloadVoteData(void); @@ -891,7 +884,56 @@ static void Y_UnloadData(void) // SRB2Kart: Voting! -static void Y_DrawVoteBackground(patch_t *patch) +// +// Y_VoteScreenCheck +// +static void Y_VoteScreenCheck(void) +{ + strcpy(VoteScreen.Prefix, "INTS"); + + if (VoteScreen.luaPrefix[0] != 0) + strlcpy(VoteScreen.Prefix, VoteScreen.luaPrefix, sizeof(VoteScreen.Prefix)); + else if (G_BattleGametype()) + strcpy(VoteScreen.Prefix, "BTLS"); + + VoteScreen.foundLuaVoteFrames = VoteScreen.foundLuaVoteWideFrames = 0; + VoteScreen.currentAnimFrame = 0; + + INT32 i = 1; + + // check for lua vote background replacements + for (;;) + { + // Check if the lumps exist (checking for VEXTR(N|W)xx for race and VEXTRB(N|W)xx for battle) + boolean normalLumpExists = W_LumpExists(va("%sC%d", VoteScreen.Prefix, i)); + boolean wideLumpExists = W_LumpExists(va("%sW%d", VoteScreen.Prefix, i)); + + if (normalLumpExists || wideLumpExists) + { + if (normalLumpExists) + VoteScreen.foundLuaVoteFrames++; + + if (wideLumpExists) + VoteScreen.foundLuaVoteWideFrames++; + } + else // If we don't find at least frame 1 (e.g VEXTRN1), let's just stop looking + break; + + i++; + } + + // non lua vote background handling + boolean prefbattletype = ((votelevels[0][1] & ~0x80) == GT_MATCH); + VoteScreen.widebgpatch = W_CachePatchName((prefbattletype ? "BATTLSCW" : "INTERSCW"), PU_PATCH); + VoteScreen.bgpatch = W_CachePatchName((prefbattletype ? "BATTLSCR" : "INTERSCR"), PU_PATCH); +} + +// +// Y_VoteBackgroundDrawer +// +// Determines which patch drawer to use for scaling +// +static void Y_VoteBackgroundDrawer(patch_t *patch) { switch (cv_votebgscaling.value) { @@ -913,27 +955,31 @@ static void Y_DrawVoteBackground(patch_t *patch) } } -// Y_DrawAnimatedVoteScreenPatch // -// Draw animated patch based on frame counter on vote screen +// Y_DrawLuaVoteScreenPatch +// +// Handles votebackgrounds set by "setVoteBackground" +// Aswell as animated patches // static void Y_DrawLuaVoteScreenPatch(boolean widePatch) { INT32 nextframe = 0; patch_t *votebg = NULL; - char tempPrefix[7]; + char tempPrefix[6]; const INT32 tempfoundAnimLuaVoteFrames = ((widePatch ? VoteScreen.foundLuaVoteWideFrames : VoteScreen.foundLuaVoteFrames) - 1); strcpy(tempPrefix, va("%s%s", VoteScreen.Prefix, (widePatch ? "W" : "C"))); - // non animated votescreen + // Draw non animated patch if (!tempfoundAnimLuaVoteFrames) { votebg = W_CachePatchName(va("%s1", tempPrefix), PU_PATCH); - Y_DrawVoteBackground(votebg); + Y_VoteBackgroundDrawer(votebg); return; } + // Draw animated patch based on frame counter on vote screen + // Just in case someone provides LESS widescreen frames than normal frames or vice versa, reset the frame counter to 0 if (VoteScreen.currentAnimFrame > tempfoundAnimLuaVoteFrames) VoteScreen.currentAnimFrame = 0; @@ -942,12 +988,15 @@ static void Y_DrawLuaVoteScreenPatch(boolean widePatch) votebg = W_CachePatchName(va("%s%d", tempPrefix, nextframe), PU_PATCH); - Y_DrawVoteBackground(votebg); + Y_VoteBackgroundDrawer(votebg); if (renderisnewtic && (votetic % 2 == 0) && !paused) VoteScreen.currentAnimFrame = (nextframe > tempfoundAnimLuaVoteFrames) ? 0 : nextframe; } +// +// Y_DrawVoteScreenPatch +// static void Y_DrawVoteScreenPatch(void) { patch_t *votebg = NULL; @@ -963,8 +1012,8 @@ static void Y_DrawVoteScreenPatch(void) votebg = VoteScreen.bgpatch; UINT8 prefgametype = (votelevels[0][1] & ~0x80); - const boolean widebgreplaced = (prefgametype == GT_MATCH) ? VoteScreen.widebattlereplaced : VoteScreen.wideracereplaced; - const boolean bgreplaced = (prefgametype == GT_MATCH) ? VoteScreen.battlereplaced : VoteScreen.racereplaced; + const boolean widebgreplaced = (prefgametype == GT_MATCH) ? VoteScreen.replaced.widebattle : VoteScreen.replaced.widerace; + const boolean bgreplaced = (prefgametype == GT_MATCH) ? VoteScreen.replaced.battle : VoteScreen.replaced.race; // we check a bunch of stuff to always have a "valid" fallback if ((widescreen && (widebgreplaced || !bgreplaced)) @@ -973,7 +1022,7 @@ static void Y_DrawVoteScreenPatch(void) votebg = VoteScreen.widebgpatch; // widescreen patch } - Y_DrawVoteBackground(votebg); + Y_VoteBackgroundDrawer(votebg); } // @@ -1036,7 +1085,7 @@ void Y_VoteDrawer(void) if (i == 3) { str = "RANDOM"; - pic = randomlvl; + pic = VoteScreen.randomlvl; } else { @@ -1060,7 +1109,7 @@ void Y_VoteDrawer(void) if (!splitscreen) { - thiscurs = cursor; + thiscurs = VoteScreen.cursor[0]; p = consoleplayer; color = levelinfo[i].gtc; colormap = NULL; @@ -1070,19 +1119,19 @@ void Y_VoteDrawer(void) switch (j) { case 1: - thiscurs = cursor2; + thiscurs = VoteScreen.cursor[2]; p = displayplayers[1]; break; case 2: - thiscurs = cursor3; + thiscurs = VoteScreen.cursor[3]; p = displayplayers[2]; break; case 3: - thiscurs = cursor4; + thiscurs = VoteScreen.cursor[4]; p = displayplayers[3]; break; default: - thiscurs = cursor1; + thiscurs = VoteScreen.cursor[1]; p = displayplayers[0]; break; } @@ -1110,7 +1159,7 @@ void Y_VoteDrawer(void) else { V_DrawFixedPatch((BASEVIDWIDTH-20)<= 3 && (i != pickedvote || voteendtic == -1)) - pic = randomlvl; + pic = VoteScreen.randomlvl; else pic = levelinfo[votes[i]].pic; if (!timer && i == voteclient.ranim) { - V_DrawScaledPatch(x-18, y+9, V_SNAPTOLEFT, cursor); + V_DrawScaledPatch(x-18, y+9, V_SNAPTOLEFT, VoteScreen.cursor[0]); if (voteendtic != -1 && !(votetic % 4)) V_DrawFill(x-1, y-1, 42, 27, 120|V_SNAPTOLEFT); else @@ -1181,7 +1230,7 @@ void Y_VoteDrawer(void) else { V_DrawFixedPatch((x+40)<