handle vote bg fallbacks more gracefully

if someone doesent provide a widescreen patch it now falls back to the replaced non widescreen one and vice versa instead of just falling back to what vanilla provides
This commit is contained in:
Alug committed 2025-01-30 10:31:36 +01:00
1 parent 305d408e02
commit 520f92e892
3 files changed
+90 -23

No files matched your search

+41
View File
@@ -3074,6 +3074,12 @@ boolean P_AddWadFileLocal(const char *wadfilename)
return true;
}
// check for replacement votescreen backgrounds
boolean wideracereplaced = false;
boolean racereplaced = false;
boolean widebattlereplaced = false;
boolean battlereplaced = false;
//
// Add a WAD file and do the per-WAD setup stages.
// Call P_MultiSetupWadFiles as soon as possible after any number of these.
@@ -3198,6 +3204,41 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local)
// TODO: Experimental SPRTINFO support, test first
R_LoadSpriteInfoLumps(wadnum, wadfiles[wadnum]->numlumps);
//
// check for votescreen replacements
//
lumpinfo = wadfiles[wadnum]->lumpinfo;
for (i = 0; i < numlumps; i++, lumpinfo++)
{
name = lumpinfo->name;
// widescreen patch Race
if (!wideracereplaced && !strncmp(name, "INTERSCW", 8))
{
wideracereplaced = true;
continue;
}
if (!racereplaced && !strncmp(name, "INTERSCR", 8))
{
racereplaced = true;
continue;
}
// widescreen patch Battle
if (!widebattlereplaced && !strncmp(name, "BATTLSCW", 8))
{
widebattlereplaced = true;
continue;
}
if (!battlereplaced && !strncmp(name, "BATTLSCR", 8))
{
battlereplaced = true;
continue;
}
}
refreshdirmenu &= ~REFRESHDIR_GAMEDATA; // Under usual circumstances we'd wait for REFRESHDIR_GAMEDATA to disappear the next frame, but it's a bit too dangerous for that...
partadd_stage = 0;
return wadnum;
+5
View File
@@ -67,6 +67,11 @@ void HWR_LoadLevel(void);
boolean P_AddWadFile(const char *wadfilename, boolean local);
boolean P_AddWadFileLocal(const char *wadfilename);
extern boolean wideracereplaced;
extern boolean racereplaced;
extern boolean widebattlereplaced;
extern boolean battlereplaced;
// WARNING: The following functions should be grouped as follows:
// any amount of PartialAdds followed by MultiSetups until returned true,
// as soon as possible.
+44 -23
View File
@@ -920,7 +920,7 @@ static void Y_UnloadData(void)
//
// Draw animated patch based on frame counter on vote screen
//
static inline void Y_DrawAnimatedVoteScreenPatch(boolean widePatch)
static void Y_DrawAnimatedVoteScreenPatch(boolean widePatch)
{
char tempAnimPrefix[7];
widePatch ? strcpy(tempAnimPrefix, animWidePrefix) : strcpy(tempAnimPrefix, animPrefix);
@@ -939,6 +939,47 @@ static inline void Y_DrawAnimatedVoteScreenPatch(boolean widePatch)
currentAnimFrame = (currentAnimFrame + 1 > tempFoundAnimVoteFrames - 1) ? 0 : currentAnimFrame + 1;
}
static void Y_DrawVoteScreenPatch(void)
{
const boolean widescreen = (vid.width / vid.dupx > 320);
const boolean animvote = (foundAnimVoteWideFrames || foundAnimVoteFrames);
if (animvote)
{
Y_DrawAnimatedVoteScreenPatch((foundAnimVoteWideFrames && widescreen));
return;
}
patch_t *votebg = bgpatch;
UINT8 prefgametype = (votelevels[0][1] & ~0x80);
const boolean widebgreplaced = (prefgametype == GT_MATCH) ? widebattlereplaced : wideracereplaced;
const boolean bgreplaced = (prefgametype == GT_MATCH) ? battlereplaced : racereplaced;
// this is horrid
if (widescreen)
{
if (widebgreplaced)
votebg = widebgpatch;
else if (bgreplaced)
votebg = bgpatch;
else
votebg = widebgpatch;
}
else
{
if (bgreplaced)
votebg = bgpatch;
else if (widebgreplaced)
votebg = widebgpatch;
else
votebg = bgpatch;
}
V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(votebg->width)/2),
(vid.height / vid.dupy) - SHORT(votebg->height),
V_SNAPTOTOP|V_SNAPTOLEFT, votebg);
}
//
// Y_VoteDrawer
//
@@ -965,28 +1006,8 @@ void Y_VoteDrawer(void)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
const boolean widescreen = (vid.width / vid.dupx > 320);
if (foundAnimVoteWideFrames && widescreen)
{
Y_DrawAnimatedVoteScreenPatch(true);
}
else if (foundAnimVoteFrames)
{
Y_DrawAnimatedVoteScreenPatch(false);
}
else if (widebgpatch && widescreen)
{
V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(widebgpatch->width)/2),
(vid.height / vid.dupy) - SHORT(widebgpatch->height),
V_SNAPTOTOP|V_SNAPTOLEFT, widebgpatch);
}
else
{
V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(bgpatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?)
(vid.height / vid.dupy) - SHORT(bgpatch->height),
V_SNAPTOTOP|V_SNAPTOLEFT, bgpatch);
}
// decides which votebg to draw and draws it
Y_DrawVoteScreenPatch();
for (i = 0; i < 4; i++) // First, we need to figure out the height of this thing...
{