mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-22 11:51:11 +00:00
CLIENT/FTE: Add stopwatch to HUD
This commit is contained in:
parent
2a94f8daf9
commit
6d37aaae5f
3 changed files with 44 additions and 0 deletions
|
@ -212,6 +212,11 @@ int platform_is_web;
|
|||
#define OPTION_WEB_ONLY 1
|
||||
#define OPTION_WEB_AND_EXE 2
|
||||
|
||||
// Stopwatch server time counter
|
||||
float stopwatch_sec;
|
||||
int stopwatch_min;
|
||||
int stopwatch_hr;
|
||||
|
||||
//controller buttons
|
||||
|
||||
/*
|
||||
|
|
|
@ -1522,6 +1522,25 @@ void(float width, float height) HUD_ReviveIcons =
|
|||
}
|
||||
}
|
||||
|
||||
void(float width, float height) HUD_StopWatch =
|
||||
{
|
||||
string sec, min, hr;
|
||||
string stopwatch;
|
||||
|
||||
if (stopwatch_sec < 10) {
|
||||
sec = strcat("0", substring(ftos(stopwatch_sec), 0, 3));
|
||||
} else {
|
||||
sec = substring(ftos(stopwatch_sec), 0, 4);
|
||||
}
|
||||
|
||||
if (stopwatch_min < 10) min = strcat("0", ftos(stopwatch_min)); else min = ftos(stopwatch_min);
|
||||
if (stopwatch_hr < 10) hr = strcat("0", ftos(stopwatch_hr)); else hr = ftos(stopwatch_hr);
|
||||
|
||||
stopwatch = strcat(hr, ":", min, ":", sec);
|
||||
|
||||
drawstring([width - (strlen(stopwatch) * 12) - 2, 2], stopwatch, [12, 12], TEXT_ORANGE, 1, 0);
|
||||
}
|
||||
|
||||
/*******************
|
||||
* HUD Draw *
|
||||
*******************/
|
||||
|
@ -1576,6 +1595,10 @@ void(float width, float height) HUD_Draw =
|
|||
|
||||
HUD_PlayerNames(width, height);
|
||||
HUD_ReviveIcons(width, height);
|
||||
|
||||
if (cvar("scr_serverstopwatch")) {
|
||||
HUD_StopWatch(width, height);
|
||||
}
|
||||
} else {
|
||||
HUD_Waypoint(width, height);
|
||||
}
|
||||
|
|
|
@ -177,6 +177,10 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init =
|
|||
// force build date text in menu
|
||||
cvar_set("cl_showbuildtime", "1");
|
||||
|
||||
// in-game stopwatch
|
||||
registercvar("scr_serverstopwatch", "0");
|
||||
stopwatch_sec = stopwatch_min = stopwatch_hr = 0;
|
||||
|
||||
// retrieve custom maps
|
||||
Customs_Get();
|
||||
|
||||
|
@ -548,6 +552,18 @@ noref void(float width, float height, float menushown) CSQC_UpdateView =
|
|||
|
||||
cvar_set("r_viewmodel_fov", ftos(cvar("r_viewmodel_default_fov")*getstatf(STAT_VIEWZOOM)));
|
||||
|
||||
// Increment the stopwatch
|
||||
// FIXME: I don't really liket his being in UpdateView.. this has nothing to do with rendering.
|
||||
stopwatch_sec = time - (stopwatch_min * 60 + (stopwatch_hr * 360));
|
||||
|
||||
if (stopwatch_sec >= 60) {
|
||||
stopwatch_min += stopwatch_sec/60;
|
||||
}
|
||||
|
||||
if (stopwatch_min >= 60) {
|
||||
stopwatch_hr += stopwatch_min/60;
|
||||
stopwatch_min = 0;
|
||||
}
|
||||
|
||||
//autoadd entities received from servers for drawing
|
||||
addentities(MASK_ENGINE);
|
||||
|
|
Loading…
Reference in a new issue