diff --git a/src/p_setup.c b/src/p_setup.c index 3b2ed7714..652062079 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -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; diff --git a/src/p_setup.h b/src/p_setup.h index 7f90564e0..e40169a76 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -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. diff --git a/src/y_inter.c b/src/y_inter.c index 115967509..2603db48a 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -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... {