From 6db125c0f32e544128e6d4bc87b274e40dc412f4 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Wed, 12 Feb 2025 01:04:52 +0100 Subject: [PATCH] Introducing... M_GetMapThumbnail and arbitrarily scaled thumbnails * only supports two sizes --- src/hu_stuff.c | 4 +++ src/m_menu.c | 75 ++++++++++++++++++++++---------------------------- src/m_menu.h | 2 ++ src/r_defs.h | 2 ++ src/y_inter.c | 55 +++++++++++------------------------- 5 files changed, 57 insertions(+), 81 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 624085591..e6cbcbda9 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -99,6 +99,8 @@ static char hu_tick; patch_t *missingpat; patch_t *blanklvl; +patch_t *randomlvl; +patch_t *nolvl; // song credits static patch_t *songcreditbg; @@ -188,6 +190,8 @@ void HU_LoadGraphics(void) Font_Load(); HU_UpdatePatch(&blanklvl, "BLANKLVL"); + HU_UpdatePatch(&randomlvl, "RANDOMLV"); + HU_UpdatePatch(&nolvl, "M_NOLVL"); HU_UpdatePatch(&songcreditbg, "K_SONGCR"); diff --git a/src/m_menu.c b/src/m_menu.c index cf2a23b14..675c376d0 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1785,6 +1785,23 @@ INT32 HU_GetHighlightColor(void) return highlightflags; } +fixed_t M_GetMapThumbnail(INT16 mapnum, patch_t **out) +{ + patch_t *patch = NULL; + if (mapnum == -1) + patch = randomlvl; + else if (mapnum >= 0 && mapnum < nummapheaders && mapheaderinfo[mapnum]) + patch = mapheaderinfo[mapnum]->thumbnailPic; + + if (!patch) + patch = blanklvl; + + *out = patch; + + // check width instead of height because haha big winton + return patch->width >= 320 ? FRACUNIT/4 : FRACUNIT/2; +} + // Sky Room menu_t SR_PandoraDef = { @@ -5619,19 +5636,18 @@ static void DrawReplayHutReplayInfo(void) // Draw level stuff x = 15; y = 15; - // A 160x100 image of the level //CONS_Printf("%d %s\n", demolist[dir_on[menudepthleft]].map, G_BuildMapName(demolist[dir_on[menudepthleft]].map)); - patch = mapheaderinfo[demolist[dir_on[menudepthleft]].map-1] - ? mapheaderinfo[demolist[dir_on[menudepthleft]].map-1]->thumbnailPic - : W_CachePatchName("M_NOLVL", PU_CACHE); + fixed_t scale = M_GetMapThumbnail(demolist[dir_on[menudepthleft]].map, &patch); + if (patch == blanklvl) + patch = nolvl; if (!(demolist[dir_on[menudepthleft]].kartspeed & DF_ENCORE)) - V_DrawSmallScaledPatch(x, y, V_SNAPTOTOP, patch); + V_DrawFixedPatch(x<width); - h = SHORT(patch->height); - V_DrawSmallScaledPatch(x+(w>>1), y, V_SNAPTOTOP|V_FLIP, patch); + w = FixedMul(SHORT(patch->width), scale); + h = FixedMul(SHORT(patch->height), scale); + V_DrawFixedPatch((x+(w>>1))<>1; + fixed_t scale = M_GetMapThumbnail(cv_nextmap.value-1, &PictureOfLevel); - // A 160x100 image of the level - if (cv_nextmap.value) - { - PictureOfLevel = mapheaderinfo[cv_nextmap.value-1]->thumbnailPic; - if (!PictureOfLevel) - PictureOfLevel = blanklvl; - } - else - PictureOfLevel = W_CachePatchName("RANDOMLV", PU_CACHE); - - w = SHORT(PictureOfLevel->width)/2; - i = SHORT(PictureOfLevel->height)/2; + w = FixedMul(SHORT(PictureOfLevel->width), scale); + i = FixedMul(SHORT(PictureOfLevel->height), scale); x = BASEVIDWIDTH/2 - w/2; y = currentMenu->y + 130 + 8 - i; @@ -9007,14 +9014,14 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) V_DrawFill(x-1, y-1, w+2, i+2, trans); // variable reuse... if ((cv_kartencore.value != 1) || gamestate == GS_TIMEATTACK || cv_newgametype.value != GT_RACE) - V_DrawSmallScaledPatch(x, y, 0, PictureOfLevel); + V_DrawFixedPatch(x<= 0) - { - PictureOfLevel = mapheaderinfo[i]->thumbnailPic; - if (!PictureOfLevel) - PictureOfLevel = blanklvl; - } - else - PictureOfLevel = W_CachePatchName("RANDOMLV", PU_CACHE); + scale = M_GetMapThumbnail(i, &PictureOfLevel)/2; x -= horizspac + w/2; - V_DrawTinyScaledPatch(x, y, trans, PictureOfLevel); + V_DrawFixedPatch(x< horizspac-dupadjust); x = (BASEVIDWIDTH + w)/2 + horizspac; @@ -9084,17 +9083,9 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) } while (!M_CanShowLevelInList(i, cv_newgametype.value)); - // A 160x100 image of the level as entry MAPxxP - if (i >= 0) - { - PictureOfLevel = mapheaderinfo[i]->thumbnailPic; - if (!PictureOfLevel) - PictureOfLevel = blanklvl; - } - else - PictureOfLevel = W_CachePatchName("RANDOMLV", PU_CACHE); + scale = M_GetMapThumbnail(i, &PictureOfLevel)/2; - V_DrawTinyScaledPatch(x, y, trans, PictureOfLevel); + V_DrawFixedPatch(x<thumbnailPic; - } - - if (!pic) - { - pic = blanklvl; - } + mapnum = votelevels[i][0]; } + scale = M_GetMapThumbnail(mapnum, &pic); if (selected[i]) { @@ -1342,10 +1334,10 @@ void Y_VoteDrawer(void) } if (!levelinfo[i].encore) - V_DrawSmallScaledPatch(BASEVIDWIDTH-100, y, V_SNAPTORIGHT, pic); + V_DrawFixedPatch((BASEVIDWIDTH-100)<= 3 && (i != pickedvote || voteendtic == -1)) - { - pic = randomlvl; - } + mapnum = -1; // randomlvl else - { - pic = NULL; + mapnum = votelevels[votes[i]][0]; - if (mapheaderinfo[votelevels[votes[i]][0]]) - { - pic = mapheaderinfo[votelevels[votes[i]][0]]->thumbnailPic; - } - - if (!pic) - { - pic = blanklvl; - } - } + scale = M_GetMapThumbnail(mapnum, &pic)/2; if (!timer && i == voteclient.ranim) { @@ -1425,10 +1404,10 @@ void Y_VoteDrawer(void) } if (!levelinfo[votes[i]].encore) - V_DrawTinyScaledPatch(x, y, V_SNAPTOLEFT, pic); + V_DrawFixedPatch(x<width, scale))<