From 0f0195d35ba1d8f50787dd747eee90553f96c9d0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 14 May 2025 02:01:02 +0200 Subject: [PATCH] Make votescreen backgrounds resolution and dup independant also some slight cleanup currently this scales vertically to fill out the screen vertically not sure if horizontally would be preferred, but thatd most likely cut off alot of parts from some votebgs --- src/v_video.c | 8 ++++++++ src/v_video.h | 1 + src/y_inter.c | 28 +++++++++++++--------------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index dca7d7dc8..a983fd485 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1562,6 +1562,14 @@ void V_DrawPatchFill(patch_t *pat) } } +// Draws a patch and scales it to fill out the screen vertically while remaining centered +void V_DrawCenteredScaledFullScreenPatch(patch_t *patch) +{ + fixed_t scale = FixedDiv(vid.height << FRACBITS, patch->height << FRACBITS); + fixed_t x = ((vid.width << FRACBITS) - FixedMul(patch->width << FRACBITS, scale)) / 2; // i fucking hate maths + V_DrawFixedPatch(x, 0, scale, V_NOSCALEPATCH, patch, NULL); +} + void V_DrawVhsEffect(boolean rewind) { static fixed_t upbary = 100*FRACUNIT, downbary = 150*FRACUNIT; diff --git a/src/v_video.h b/src/v_video.h index 00d0f6cb2..6b695b9c1 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -282,6 +282,7 @@ typedef struct player_s player_t; void V_DoPostProcessor(INT32 view, INT32 param); void V_DrawPatchFill(patch_t *pat); +void V_DrawCenteredScaledFullScreenPatch(patch_t *patch); void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes, size_t destrowbytes); diff --git a/src/y_inter.c b/src/y_inter.c index db38ae4cb..4aaf60bb8 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -912,35 +912,35 @@ static void Y_UnloadData(void) // static void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) { + patch_t *votebg = NULL; char tempAnimPrefix[7]; - widePatch ? strcpy(tempAnimPrefix, animWidePrefix) : strcpy(tempAnimPrefix, animPrefix); - const INT32 tempFoundAnimVoteFrames = widePatch ? foundAnimVoteWideFrames : foundAnimVoteFrames; + strcpy(tempAnimPrefix, (widePatch ? animWidePrefix : animPrefix)); + const INT32 tempFoundAnimVoteFrames = (widePatch ? foundAnimVoteWideFrames : foundAnimVoteFrames) - 1; // Just in case someone provides LESS widescreen frames than normal frames or vice versa, reset the frame counter to 0 - if (currentAnimFrame > tempFoundAnimVoteFrames - 1) + if (currentAnimFrame > tempFoundAnimVoteFrames) currentAnimFrame = 0; - patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_PATCH); - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (background->width/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) - (vid.height / vid.dupy) - background->height, - V_SNAPTOTOP|V_SNAPTOLEFT, background); + votebg = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_PATCH); - if (renderisnewtic && votetic % 2 == 0 && !paused) - currentAnimFrame = (currentAnimFrame + 1 > tempFoundAnimVoteFrames - 1) ? 0 : currentAnimFrame + 1; + V_DrawCenteredScaledFullScreenPatch(votebg); + + if (renderisnewtic && (votetic % 2 == 0) && !paused) + currentAnimFrame = (currentAnimFrame + 1 > tempFoundAnimVoteFrames) ? 0 : (currentAnimFrame + 1); } static void Y_DrawVoteScreenPatch(void) { + patch_t *votebg = NULL; const boolean widescreen = (vid.width / vid.dupx > 320); - const boolean animvote = (foundAnimVoteWideFrames || foundAnimVoteFrames); - if (animvote) + if (foundAnimVoteWideFrames || foundAnimVoteFrames) { Y_DrawAnimatedVoteScreenPatch((foundAnimVoteWideFrames && widescreen)); return; } - patch_t *votebg = bgpatch; // non widescreen patch + votebg = bgpatch; // non widescreen patch UINT8 prefgametype = (votelevels[0][1] & ~0x80); const boolean widebgreplaced = (prefgametype == GT_MATCH) ? widebattlereplaced : wideracereplaced; @@ -952,9 +952,7 @@ static void Y_DrawVoteScreenPatch(void) votebg = widebgpatch; } - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (votebg->width/2), - (vid.height / vid.dupy) - votebg->height, - V_SNAPTOTOP|V_SNAPTOLEFT, votebg); + V_DrawCenteredScaledFullScreenPatch(votebg); } //