HUD: Battle rankings and GOAL (4P version) + 4P timer tweak

- 4P version only displays top 2 players
- Compared to 1P version, local player is not required to
  be on the list
- Skull is displayed if any of the party members have
  reached the point limit
- 4P timers reduced to just digits, in order to make space
  for rankings
This commit is contained in:
James R 2024-01-12 06:10:43 -08:00
parent c3a6f6b77d
commit f232647868
2 changed files with 68 additions and 5 deletions

View file

@ -43,16 +43,15 @@ void K_drawKart2PTimestamp(void)
void K_drawKart4PTimestamp(void)
{
Draw row = Draw(154, 0).flags(kHudFlags).font(Draw::Font::kZVote).align(Draw::Align::kCenter);
Draw row = Draw(159, 0).flags(kHudFlags).font(Draw::Font::kZVote).align(Draw::Align::kCenter);
auto draw = [](const Draw& row, tic_t time)
{
row.patch("K_STTIMS");
row.xy(5, 12).text("{:03}", time / TICRATE);
row.text("{:03}", time / TICRATE);
};
auto time_of = [](int k) -> tic_t { return k <= r_splitscreen ? player_timer(&players[displayplayers[k]]) : 0u; };
draw(row.y(1).flags(V_SNAPTOTOP), std::max(time_of(0), time_of(1)));
draw(row.y(178).flags(V_SNAPTOBOTTOM), std::max(time_of(2), time_of(3)));
draw(row.y(191).flags(V_SNAPTOBOTTOM), std::max(time_of(2), time_of(3)));
}

View file

@ -2220,6 +2220,7 @@ struct PositionFacesInfo
PositionFacesInfo();
void draw_1p();
void draw_4p_battle(int y, INT32 flags);
};
PositionFacesInfo::PositionFacesInfo()
@ -2467,6 +2468,53 @@ void PositionFacesInfo::draw_1p()
}
}
void PositionFacesInfo::draw_4p_battle(int y, INT32 flags)
{
using srb2::Draw;
Draw row = Draw(152, y).flags(V_HUDTRANS | V_SLIDEIN | flags).font(Draw::Font::kPing);
UINT8 skull = []
{
int party = G_PartySize(consoleplayer);
for (int i = 0; i < party; ++i)
{
// Is any party member about to win?
if (g_pointlimit <= players[G_PartyMember(consoleplayer, i)].roundscore)
{
return 1;
}
}
return 0;
}();
row.patch(kp_goal[skull][1]);
if (!skull)
{
row.xy(8.5, 5).align(Draw::Align::kCenter).text("{:02}", g_pointlimit);
}
row.xy(7, 18).patch(kp_goalrod[1]);
auto head = [&](Draw col, int i)
{
const player_t& p = players[rankplayer[i]];
col.colormap(p.skin, static_cast<skincolornum_t>(p.skincolor)).patch(faceprefix[p.skin][FACE_MINIMAP]);
bool dance = g_pointlimit <= p.roundscore;
bool flash = dance && leveltime % 8 < 4;
(
flash ?
col.xy(8, 6).colorize(SKINCOLOR_TANGERINE).flags(V_STRINGDANCE) :
col.xy(8, 6).flags(dance ? V_STRINGDANCE : 0)
).text("{:02}", p.roundscore);
};
// Draw top 2 players
head(row.xy(2, 31), 1);
head(row.xy(2, 18), 0);
}
static boolean K_drawKartPositionFaces(void)
{
PositionFacesInfo state{};
@ -2477,7 +2525,18 @@ static boolean K_drawKartPositionFaces(void)
if (!LUA_HudEnabled(hud_minirankings))
return false; // Don't proceed but still return true for free play above if HUD is disabled.
state.draw_1p();
switch (r_splitscreen)
{
case 0:
state.draw_1p();
break;
case 2:
case 3:
state.draw_4p_battle(9, V_SNAPTOTOP);
state.draw_4p_battle(147, V_SNAPTOBOTTOM);
break;
}
return false;
}
@ -5592,6 +5651,11 @@ void K_drawKartHUD(void)
{
K_drawKart4PTimestamp();
}
if (gametyperules & GTR_POINTLIMIT)
{
K_drawKartPositionFaces();
}
}
}