mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-10 19:01:50 +00:00
Add 2P and 3P/4P timer HUD variations
This commit is contained in:
parent
8c0f7d5757
commit
299a8b707c
5 changed files with 69 additions and 20 deletions
|
|
@ -581,6 +581,7 @@ add_subdirectory(menus)
|
||||||
if(SRB2_CONFIG_ENABLE_WEBM_MOVIES)
|
if(SRB2_CONFIG_ENABLE_WEBM_MOVIES)
|
||||||
add_subdirectory(media)
|
add_subdirectory(media)
|
||||||
endif()
|
endif()
|
||||||
|
add_subdirectory(hud)
|
||||||
|
|
||||||
# strip debug symbols into separate file when using gcc.
|
# strip debug symbols into separate file when using gcc.
|
||||||
# to be consistent with Makefile, don't generate for OS X.
|
# to be consistent with Makefile, don't generate for OS X.
|
||||||
|
|
|
||||||
3
src/hud/CMakeLists.txt
Normal file
3
src/hud/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
target_sources(SRB2SDL2 PRIVATE
|
||||||
|
timer.cpp
|
||||||
|
)
|
||||||
52
src/hud/timer.cpp
Normal file
52
src/hud/timer.cpp
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "../doomstat.h"
|
||||||
|
#include "../g_game.h"
|
||||||
|
#include "../k_hud.h"
|
||||||
|
#include "../p_local.h"
|
||||||
|
#include "../v_draw.hpp"
|
||||||
|
|
||||||
|
using srb2::Draw;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
constexpr INT32 kHudFlags = V_HUDTRANS | V_SLIDEIN;
|
||||||
|
|
||||||
|
}; // namespace
|
||||||
|
|
||||||
|
void K_drawKart2PTimestamp(void)
|
||||||
|
{
|
||||||
|
auto get_row = []
|
||||||
|
{
|
||||||
|
if (stplyr == &players[displayplayers[0]])
|
||||||
|
{
|
||||||
|
return Draw(286, 31).flags(V_SNAPTOTOP);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Draw(286, 163).flags(V_SNAPTOBOTTOM);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Draw row = get_row().flags(kHudFlags | V_SNAPTORIGHT).font(Draw::Font::kZVote);
|
||||||
|
|
||||||
|
row.patch("K_STTIMS");
|
||||||
|
row.xy(12, 2).text("{:03}", stplyr->realtime / TICRATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void K_drawKart4PTimestamp(void)
|
||||||
|
{
|
||||||
|
Draw row = Draw(154, 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);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto time_of = [](int k) -> tic_t { return k <= r_splitscreen ? players[displayplayers[k]].realtime : 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)));
|
||||||
|
}
|
||||||
31
src/k_hud.c
31
src/k_hud.c
|
|
@ -5294,7 +5294,6 @@ void K_drawKartHUD(void)
|
||||||
boolean islonesome = false;
|
boolean islonesome = false;
|
||||||
boolean battlefullscreen = false;
|
boolean battlefullscreen = false;
|
||||||
boolean freecam = demo.freecam; //disable some hud elements w/ freecam
|
boolean freecam = demo.freecam; //disable some hud elements w/ freecam
|
||||||
UINT8 i;
|
|
||||||
UINT8 viewnum = R_GetViewNumber();
|
UINT8 viewnum = R_GetViewNumber();
|
||||||
|
|
||||||
// Define the X and Y for each drawn object
|
// Define the X and Y for each drawn object
|
||||||
|
|
@ -5376,27 +5375,19 @@ void K_drawKartHUD(void)
|
||||||
|
|
||||||
islonesome = K_drawKartPositionFaces();
|
islonesome = K_drawKartPositionFaces();
|
||||||
}
|
}
|
||||||
else if (viewnum == r_splitscreen
|
else if (r_splitscreen == 1)
|
||||||
&& (gametyperules & GTR_TIMELIMIT)
|
|
||||||
&& timelimitintics > 0)
|
|
||||||
{
|
{
|
||||||
tic_t highestrealtime = players[displayplayers[1]].realtime;
|
|
||||||
|
|
||||||
// Uses the highest time across all players (handles paused timer on exiting)
|
|
||||||
for (i = 1; i <= r_splitscreen; i++)
|
|
||||||
{
|
|
||||||
if (players[displayplayers[i]].realtime <= highestrealtime)
|
|
||||||
continue;
|
|
||||||
highestrealtime = players[displayplayers[i]].realtime;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the timestamp (mostly) CENTERED
|
|
||||||
if (LUA_HudEnabled(hud_time))
|
if (LUA_HudEnabled(hud_time))
|
||||||
K_drawKartTimestamp(highestrealtime,
|
{
|
||||||
(r_splitscreen == 1 ? TIME_X : ((BASEVIDWIDTH/2) - 69)),
|
K_drawKart2PTimestamp();
|
||||||
TIME_Y,
|
}
|
||||||
V_HUDTRANS|V_SLIDEIN|V_SNAPTOTOP|(r_splitscreen == 1 ? V_SNAPTORIGHT : 0),
|
}
|
||||||
0);
|
else if (viewnum == r_splitscreen)
|
||||||
|
{
|
||||||
|
if (LUA_HudEnabled(hud_time))
|
||||||
|
{
|
||||||
|
K_drawKart4PTimestamp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode
|
if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ void K_LoadKartHUDGraphics(void);
|
||||||
void K_drawKartHUD(void);
|
void K_drawKartHUD(void);
|
||||||
void K_drawKartFreePlay(void);
|
void K_drawKartFreePlay(void);
|
||||||
void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT32 splitflags, UINT8 mode);
|
void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT32 splitflags, UINT8 mode);
|
||||||
|
void K_drawKart2PTimestamp(void);
|
||||||
|
void K_drawKart4PTimestamp(void);
|
||||||
void K_DrawMapThumbnail(fixed_t x, fixed_t y, fixed_t width, UINT32 flags, UINT16 map, const UINT8 *colormap);
|
void K_DrawMapThumbnail(fixed_t x, fixed_t y, fixed_t width, UINT32 flags, UINT16 map, const UINT8 *colormap);
|
||||||
void K_DrawLikeMapThumbnail(fixed_t x, fixed_t y, fixed_t width, UINT32 flags, patch_t *patch, const UINT8 *colormap);
|
void K_DrawLikeMapThumbnail(fixed_t x, fixed_t y, fixed_t width, UINT32 flags, patch_t *patch, const UINT8 *colormap);
|
||||||
void K_drawTargetHUD(const vector3_t *origin, player_t *player);
|
void K_drawTargetHUD(const vector3_t *origin, player_t *player);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue