Merge branch 'item-roulette-numbers' into 'master'

Roulette numbers when the roulette can give you more than 1 of an item

Closes #974

See merge request KartKrew/Kart!2010
This commit is contained in:
AJ Martinez 2024-03-04 23:24:15 +00:00
commit 1345439d7c
6 changed files with 64 additions and 15 deletions

View file

@ -319,6 +319,15 @@ void HU_Init(void)
PR ("PRFN");
REG;
DIM ('0', 10);
DIG (2);
PR ("ROLNUM");
REG;
PR ("RO4NUM");
REG;
DIG (3);
ADIM (KART);

View file

@ -80,6 +80,8 @@ enum
X (NIGHTSNUM),
X (PINGNUM),
X (PROFNUM),
X (ROLNUM),
X (RO4NUM),
X (KART),
X (TIMER),

View file

@ -1371,6 +1371,7 @@ static void K_drawKartItem(void)
// Set to 'no item' just in case.
const UINT8 offset = ((r_splitscreen > 1) ? 1 : 0);
patch_t *localpatch[3] = { kp_nodraw, kp_nodraw, kp_nodraw };
UINT8 localamt[3] = {0, 0, 0};
patch_t *localbg = ((offset) ? kp_itembg[2] : kp_itembg[0]);
patch_t *localinv = ((offset) ? kp_invincibility[((leveltime % (6*3)) / 3) + 7] : kp_invincibility[(leveltime % (7*3)) / 3]);
INT32 fx = 0, fy = 0, fflags = 0; // final coords for hud and flags...
@ -1403,14 +1404,19 @@ static void K_drawKartItem(void)
{
case KITEM_INVINCIBILITY:
localpatch[i] = localinv;
localamt[i] = amt;
break;
case KITEM_ORBINAUT:
localpatch[i] = kp_orbinaut[(offset ? 4 : std::min(amt-1, 3))];
if (amt > 4)
localamt[i] = amt;
break;
default:
localpatch[i] = K_GetCachedItemPatch(item, offset);
if (item != KITEM_BALLHOG || amt != 5)
localamt[i] = amt;
break;
}
}
@ -1586,25 +1592,35 @@ static void K_drawKartItem(void)
V_SLIDEIN|fflags
);
V_DrawFixedPatch(
fx<<FRACBITS, (fy<<FRACBITS) + rouletteOffset + rouletteSpace,
FRACUNIT, V_HUDTRANS|V_SLIDEIN|fflags,
localpatch[0], (localcolor[0] ? R_GetTranslationColormap(colormode[0], localcolor[0], GTC_CACHE) : NULL)
);
V_DrawFixedPatch(
fx<<FRACBITS, (fy<<FRACBITS) + rouletteOffset - rouletteSpace,
FRACUNIT, V_HUDTRANS|V_SLIDEIN|fflags,
localpatch[2], (localcolor[2] ? R_GetTranslationColormap(colormode[2], localcolor[2], GTC_CACHE) : NULL)
);
auto draw_item = [&](fixed_t y, int i)
{
const UINT8 *colormap = (localcolor[i] ? R_GetTranslationColormap(colormode[i], localcolor[i], GTC_CACHE) : NULL);
V_DrawFixedPatch(
fx<<FRACBITS, (fy<<FRACBITS) + rouletteOffset + y,
FRACUNIT, V_HUDTRANS|V_SLIDEIN|fflags,
localpatch[i], colormap
);
if (localamt[i] > 1)
{
using srb2::Draw;
Draw(
fx + rouletteCrop.x + FixedToFloat(rouletteSpace/2),
fy + rouletteCrop.y + FixedToFloat(rouletteOffset + y + rouletteSpace) - (r_splitscreen > 1 ? 15 : 33))
.font(r_splitscreen > 1 ? Draw::Font::kRollingNum4P : Draw::Font::kRollingNum)
.align(Draw::Align::kCenter)
.flags(V_HUDTRANS|V_SLIDEIN|fflags)
.colormap(colormap)
.text("{}", localamt[i]);
}
};
draw_item(rouletteSpace, 0);
draw_item(-rouletteSpace, 2);
if (stplyr->itemRoulette.active == true)
{
// Draw the item underneath the box.
V_DrawFixedPatch(
fx<<FRACBITS, (fy<<FRACBITS) + rouletteOffset,
FRACUNIT, V_HUDTRANS|V_SLIDEIN|fflags,
localpatch[1], (localcolor[1] ? R_GetTranslationColormap(colormode[1], localcolor[1], GTC_CACHE) : NULL)
);
draw_item(0, 1);
V_ClearClipRect();
}
else

View file

@ -308,6 +308,12 @@ int Draw::font_to_fontno(Font font)
case Font::kMedium:
return MED_FONT;
case Font::kRollingNum:
return ROLNUM_FONT;
case Font::kRollingNum4P:
return RO4NUM_FONT;
}
return TINY_FONT;

View file

@ -41,6 +41,8 @@ public:
kThinTimer,
kMenu,
kMedium,
kRollingNum,
kRollingNum4P,
};
enum class Align

View file

@ -2342,6 +2342,12 @@ static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result)
case PINGF_FONT:
result->spacew = 3;
break;
case ROLNUM_FONT:
result->spacew = 17;
break;
case RO4NUM_FONT:
result->spacew = 9;
break;
}
switch (fontno)
@ -2373,6 +2379,12 @@ static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result)
case PINGF_FONT:
result->lfh = 10;
break;
case ROLNUM_FONT:
result->lfh = 33;
break;
case RO4NUM_FONT:
result->lfh = 15;
break;
}
switch (fontno)
@ -2432,6 +2444,8 @@ static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result)
break;
case OPPRF_FONT:
case PINGF_FONT:
case ROLNUM_FONT:
case RO4NUM_FONT:
if (result->chw)
result->dim_fn = FixedCharacterDim;
else