mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-24 17:02:35 +00:00
K_DrawMapThumbnail
- Handles map thumbnail drawing in a way agnostic to patch size - Specify a desired final width in pixels `<< FRACBITS`, not a scale - more specific for our incoming varied purposes. - Encore and voting screen Random have to be handled externally - Put in k_hud.c because I'm not sure where would be most appropriate snd it works well enough, can be moved later
This commit is contained in:
parent
cc4518f80a
commit
bd5d51ac7b
4 changed files with 102 additions and 103 deletions
29
src/k_hud.c
29
src/k_hud.c
|
|
@ -1124,6 +1124,35 @@ static void K_initKartHUD(void)
|
|||
}
|
||||
}
|
||||
|
||||
void K_DrawMapThumbnail(INT32 x, INT32 y, INT32 width, UINT32 flags, UINT16 map, UINT8 *colormap)
|
||||
{
|
||||
patch_t *PictureOfLevel = NULL;
|
||||
|
||||
if (map >= nummapheaders || !mapheaderinfo[map])
|
||||
{
|
||||
PictureOfLevel = W_CachePatchName("M_NOLVL", PU_CACHE);
|
||||
}
|
||||
else if (!mapheaderinfo[map]->thumbnailPic)
|
||||
{
|
||||
PictureOfLevel = blanklvl;
|
||||
}
|
||||
else
|
||||
{
|
||||
PictureOfLevel = mapheaderinfo[map]->thumbnailPic;
|
||||
}
|
||||
|
||||
if (flags & V_FLIP)
|
||||
x += width;
|
||||
|
||||
V_DrawFixedPatch(
|
||||
x, y,
|
||||
FixedDiv(width, (SHORT(PictureOfLevel->width) << FRACBITS)),
|
||||
flags,
|
||||
PictureOfLevel,
|
||||
colormap
|
||||
);
|
||||
}
|
||||
|
||||
// see also MT_PLAYERARROW mobjthinker in p_mobj.c
|
||||
static void K_drawKartItem(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ void K_drawKartHUD(void);
|
|||
void K_drawKartFreePlay(void);
|
||||
void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UINT8 mode);
|
||||
void K_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol);
|
||||
void K_DrawMapThumbnail(INT32 x, INT32 y, INT32 width, UINT32 flags, UINT16 map, UINT8 *colormap);
|
||||
|
||||
extern patch_t *kp_facehighlight[8];
|
||||
|
||||
|
|
|
|||
|
|
@ -1925,28 +1925,24 @@ void M_DrawRaceDifficulty(void)
|
|||
static void M_DrawCupPreview(INT16 y, cupheader_t *cup)
|
||||
{
|
||||
UINT8 i;
|
||||
const INT16 pad = ((vid.width/vid.dupx) - BASEVIDWIDTH)/2;
|
||||
INT16 x = -(cupgrid.previewanim % 82) - pad;
|
||||
INT16 x = -(cupgrid.previewanim % 82);
|
||||
|
||||
V_DrawFill(0, y, BASEVIDWIDTH, 54, 31);
|
||||
|
||||
if (cup && (cup->unlockrequired >= MAXUNLOCKABLES || M_CheckNetUnlockByID(cup->unlockrequired)))
|
||||
{
|
||||
i = (cupgrid.previewanim / 82) % cup->numlevels;
|
||||
while (x < BASEVIDWIDTH + pad)
|
||||
while (x < BASEVIDWIDTH)
|
||||
{
|
||||
INT32 cupLevelNum = cup->cachedlevels[i];
|
||||
patch_t *PictureOfLevel = NULL;
|
||||
|
||||
if (cupLevelNum < nummapheaders && mapheaderinfo[cupLevelNum])
|
||||
{
|
||||
PictureOfLevel = mapheaderinfo[cupLevelNum]->thumbnailPic;
|
||||
}
|
||||
K_DrawMapThumbnail(
|
||||
(x+1)<<FRACBITS, (y+2)<<FRACBITS,
|
||||
80<<FRACBITS,
|
||||
0,
|
||||
cupLevelNum,
|
||||
NULL);
|
||||
|
||||
if (!PictureOfLevel)
|
||||
PictureOfLevel = blanklvl;
|
||||
|
||||
V_DrawSmallScaledPatch(x + 1, y+2, 0, PictureOfLevel);
|
||||
i = (i+1) % cup->numlevels;
|
||||
x += 82;
|
||||
}
|
||||
|
|
@ -2164,26 +2160,22 @@ static void M_DrawHighLowLevelTitle(INT16 x, INT16 y, INT16 map)
|
|||
|
||||
static void M_DrawLevelSelectBlock(INT16 x, INT16 y, INT16 map, boolean redblink, boolean greyscale)
|
||||
{
|
||||
patch_t *PictureOfLevel = NULL;
|
||||
UINT8 *colormap = NULL;
|
||||
|
||||
if (greyscale)
|
||||
colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_GREY, GTC_MENUCACHE);
|
||||
|
||||
if (mapheaderinfo[map])
|
||||
{
|
||||
PictureOfLevel = mapheaderinfo[map]->thumbnailPic;
|
||||
}
|
||||
|
||||
if (!PictureOfLevel)
|
||||
PictureOfLevel = blanklvl;
|
||||
|
||||
if (redblink)
|
||||
V_DrawScaledPatch(3+x, y, 0, W_CachePatchName("LVLSEL2", PU_CACHE));
|
||||
else
|
||||
V_DrawScaledPatch(3+x, y, 0, W_CachePatchName("LVLSEL", PU_CACHE));
|
||||
|
||||
V_DrawSmallMappedPatch(9+x, y+6, 0, PictureOfLevel, colormap);
|
||||
K_DrawMapThumbnail(
|
||||
(9+x)<<FRACBITS, (y+6)<<FRACBITS,
|
||||
80<<FRACBITS,
|
||||
0,
|
||||
map,
|
||||
colormap);
|
||||
M_DrawHighLowLevelTitle(98+x, y+8, map);
|
||||
}
|
||||
|
||||
|
|
@ -3915,7 +3907,7 @@ static void M_DrawReplayHutReplayInfo(menudemo_t *demoref)
|
|||
{
|
||||
patch_t *patch = NULL;
|
||||
UINT8 *colormap;
|
||||
INT32 x, y, w, h;
|
||||
INT32 x, y;
|
||||
|
||||
switch (demoref->type)
|
||||
{
|
||||
|
|
@ -3937,34 +3929,19 @@ static void M_DrawReplayHutReplayInfo(menudemo_t *demoref)
|
|||
// Draw level stuff
|
||||
x = 15; y = 15;
|
||||
|
||||
// A 160x100 image of the level as entry MAPxxP
|
||||
if (demoref->map < nummapheaders && mapheaderinfo[demoref->map])
|
||||
{
|
||||
patch = mapheaderinfo[demoref->map]->thumbnailPic;
|
||||
if (!patch)
|
||||
{
|
||||
patch = blanklvl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
patch = W_CachePatchName("M_NOLVL", PU_CACHE);
|
||||
}
|
||||
K_DrawMapThumbnail(
|
||||
x<<FRACBITS, y<<FRACBITS,
|
||||
80<<FRACBITS,
|
||||
V_SNAPTOTOP|((demoref->kartspeed & DF_ENCORE) ? V_FLIP : 0),
|
||||
demoref->map,
|
||||
NULL);
|
||||
|
||||
if (!(demoref->kartspeed & DF_ENCORE))
|
||||
V_DrawSmallScaledPatch(x, y, V_SNAPTOTOP, patch);
|
||||
else
|
||||
if (demoref->kartspeed & DF_ENCORE)
|
||||
{
|
||||
w = SHORT(patch->width);
|
||||
h = SHORT(patch->height);
|
||||
V_DrawSmallScaledPatch(x+(w>>1), y, V_SNAPTOTOP|V_FLIP, patch);
|
||||
|
||||
{
|
||||
static angle_t rubyfloattime = 0;
|
||||
const fixed_t rubyheight = FINESINE(rubyfloattime>>ANGLETOFINESHIFT);
|
||||
V_DrawFixedPatch((x+(w>>2))<<FRACBITS, ((y+(h>>2))<<FRACBITS) - (rubyheight<<1), FRACUNIT, V_SNAPTOTOP, W_CachePatchName("RUBYICON", PU_CACHE), NULL);
|
||||
rubyfloattime += (ANGLE_MAX/NEWTICRATE);
|
||||
}
|
||||
static angle_t rubyfloattime = 0;
|
||||
const fixed_t rubyheight = FINESINE(rubyfloattime>>ANGLETOFINESHIFT);
|
||||
V_DrawFixedPatch((x+40)<<FRACBITS, ((y+50)<<FRACBITS) - (rubyheight<<1), FRACUNIT, V_SNAPTOTOP, W_CachePatchName("RUBYICON", PU_CACHE), NULL);
|
||||
rubyfloattime += (ANGLE_MAX/NEWTICRATE);
|
||||
}
|
||||
|
||||
x += 85;
|
||||
|
|
|
|||
100
src/y_inter.c
100
src/y_inter.c
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include "m_random.h" // M_RandomKey
|
||||
#include "g_input.h" // G_PlayerInputDown
|
||||
#include "k_hud.h" // K_DrawMapThumbnail
|
||||
#include "k_battle.h"
|
||||
#include "k_boss.h"
|
||||
#include "k_pwrlv.h"
|
||||
|
|
@ -1006,34 +1007,11 @@ void Y_VoteDrawer(void)
|
|||
y = (200-height)/2;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
const char *str;
|
||||
patch_t *pic;
|
||||
UINT8 j, color;
|
||||
|
||||
if (i == 3)
|
||||
{
|
||||
str = "RANDOM";
|
||||
pic = randomlvl;
|
||||
}
|
||||
else
|
||||
{
|
||||
str = levelinfo[i].str;
|
||||
|
||||
pic = NULL;
|
||||
|
||||
if (mapheaderinfo[votelevels[i][0]])
|
||||
{
|
||||
pic = mapheaderinfo[votelevels[i][0]]->thumbnailPic;
|
||||
}
|
||||
|
||||
if (!pic)
|
||||
{
|
||||
pic = blanklvl;
|
||||
}
|
||||
}
|
||||
|
||||
if (selected[i])
|
||||
{
|
||||
const char *str;
|
||||
UINT8 sizeadd = selected[i];
|
||||
|
||||
for (j = 0; j <= splitscreen; j++) // another loop for drawing the selection backgrounds in the right order, grumble grumble..
|
||||
|
|
@ -1093,11 +1071,24 @@ void Y_VoteDrawer(void)
|
|||
sizeadd--;
|
||||
}
|
||||
|
||||
if (!levelinfo[i].encore)
|
||||
V_DrawSmallScaledPatch(BASEVIDWIDTH-100, y, V_SNAPTORIGHT, pic);
|
||||
if (i == 3)
|
||||
{
|
||||
str = "RANDOM";
|
||||
V_DrawSmallScaledPatch(BASEVIDWIDTH-100, y, V_SNAPTORIGHT, randomlvl);
|
||||
}
|
||||
else
|
||||
{
|
||||
V_DrawFixedPatch((BASEVIDWIDTH-20)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, V_FLIP|V_SNAPTORIGHT, pic, 0);
|
||||
str = levelinfo[i].str;
|
||||
K_DrawMapThumbnail(
|
||||
(BASEVIDWIDTH-100)<<FRACBITS, (y)<<FRACBITS,
|
||||
80<<FRACBITS,
|
||||
V_SNAPTORIGHT|(levelinfo[i].encore ? V_FLIP : 0),
|
||||
votelevels[i][0],
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (levelinfo[i].encore)
|
||||
{
|
||||
V_DrawFixedPatch((BASEVIDWIDTH-60)<<FRACBITS, ((y+25)<<FRACBITS) - (rubyheight<<1), FRACUNIT, V_SNAPTORIGHT, rubyicon, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -1117,11 +1108,22 @@ void Y_VoteDrawer(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!levelinfo[i].encore)
|
||||
V_DrawTinyScaledPatch(BASEVIDWIDTH-60, y, V_SNAPTORIGHT, pic);
|
||||
if (i == 3)
|
||||
{
|
||||
V_DrawTinyScaledPatch(BASEVIDWIDTH-60, y, V_SNAPTORIGHT, randomlvl);
|
||||
}
|
||||
else
|
||||
{
|
||||
V_DrawFixedPatch((BASEVIDWIDTH-20)<<FRACBITS, y<<FRACBITS, FRACUNIT/4, V_FLIP|V_SNAPTORIGHT, pic, 0);
|
||||
K_DrawMapThumbnail(
|
||||
(BASEVIDWIDTH-60)<<FRACBITS, (y)<<FRACBITS,
|
||||
40<<FRACBITS,
|
||||
V_SNAPTORIGHT|(levelinfo[i].encore ? V_FLIP : 0),
|
||||
votelevels[i][0],
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (levelinfo[i].encore)
|
||||
{
|
||||
V_DrawFixedPatch((BASEVIDWIDTH-40)<<FRACBITS, (y<<FRACBITS) + (25<<(FRACBITS-1)) - rubyheight, FRACUNIT/2, V_SNAPTORIGHT, rubyicon, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -1146,27 +1148,6 @@ void Y_VoteDrawer(void)
|
|||
|
||||
if ((playeringame[i] && !players[i].spectator) && votes[i] != -1)
|
||||
{
|
||||
patch_t *pic;
|
||||
|
||||
if (votes[i] >= 3 && (i != pickedvote || voteendtic == -1))
|
||||
{
|
||||
pic = randomlvl;
|
||||
}
|
||||
else
|
||||
{
|
||||
pic = NULL;
|
||||
|
||||
if (mapheaderinfo[votelevels[votes[i]][0]])
|
||||
{
|
||||
pic = mapheaderinfo[votelevels[votes[i]][0]]->thumbnailPic;
|
||||
}
|
||||
|
||||
if (!pic)
|
||||
{
|
||||
pic = blanklvl;
|
||||
}
|
||||
}
|
||||
|
||||
if (!timer && i == voteclient.ranim)
|
||||
{
|
||||
V_DrawScaledPatch(x-18, y+9, V_SNAPTOLEFT, cursor);
|
||||
|
|
@ -1176,11 +1157,22 @@ void Y_VoteDrawer(void)
|
|||
V_DrawFill(x-1, y-1, 42, 27, levelinfo[votes[i]].gtc|V_SNAPTOLEFT);
|
||||
}
|
||||
|
||||
if (!levelinfo[votes[i]].encore)
|
||||
V_DrawTinyScaledPatch(x, y, V_SNAPTOLEFT, pic);
|
||||
if (votes[i] >= 3 && (i != pickedvote || voteendtic == -1))
|
||||
{
|
||||
V_DrawTinyScaledPatch(x, y, V_SNAPTOLEFT, randomlvl);
|
||||
}
|
||||
else
|
||||
{
|
||||
V_DrawFixedPatch((x+40)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/4, V_SNAPTOLEFT|V_FLIP, pic, 0);
|
||||
K_DrawMapThumbnail(
|
||||
(x)<<FRACBITS, (y)<<FRACBITS,
|
||||
40<<FRACBITS,
|
||||
V_SNAPTOLEFT|(levelinfo[votes[i]].encore ? V_FLIP : 0),
|
||||
votelevels[votes[i]][0],
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (levelinfo[votes[i]].encore)
|
||||
{
|
||||
V_DrawFixedPatch((x+20)<<FRACBITS, (y<<FRACBITS) + (25<<(FRACBITS-1)) - rubyheight, FRACUNIT/2, V_SNAPTOLEFT, rubyicon, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue