mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-22 03:41:15 +00:00
CLIENT: Add scr_serverstopwatch 2 for round timer
This commit is contained in:
parent
ae7e3634fe
commit
c5a4014181
3 changed files with 50 additions and 0 deletions
|
@ -218,6 +218,13 @@ float stopwatch_sec;
|
||||||
int stopwatch_min;
|
int stopwatch_min;
|
||||||
int stopwatch_hr;
|
int stopwatch_hr;
|
||||||
|
|
||||||
|
// Same dealio, but for rounds
|
||||||
|
float stopwatch_round_sec;
|
||||||
|
int stopwatch_round_min;
|
||||||
|
int stopwatch_round_hr;
|
||||||
|
int stopwatch_round_isactive;
|
||||||
|
float stopwatch_round_starttime;
|
||||||
|
|
||||||
//controller buttons
|
//controller buttons
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -482,6 +482,7 @@ void(float width, float height) HUD_Rounds =
|
||||||
}
|
}
|
||||||
else if (rounds_change == 2)//this is the rounds icon moving from middle
|
else if (rounds_change == 2)//this is the rounds icon moving from middle
|
||||||
{
|
{
|
||||||
|
stopwatch_round_isactive = true;
|
||||||
float round_center_y_offset = 0;
|
float round_center_y_offset = 0;
|
||||||
float round_center_x_offset = 0;
|
float round_center_x_offset = 0;
|
||||||
|
|
||||||
|
@ -497,6 +498,7 @@ void(float width, float height) HUD_Rounds =
|
||||||
}
|
}
|
||||||
else if (rounds_change == 3)//shift to white
|
else if (rounds_change == 3)//shift to white
|
||||||
{
|
{
|
||||||
|
stopwatch_round_isactive = false;
|
||||||
if (!color_shift_init)
|
if (!color_shift_init)
|
||||||
{
|
{
|
||||||
color_shift[0] = 107;
|
color_shift[0] = 107;
|
||||||
|
@ -774,6 +776,7 @@ void(float width, float height) HUD_Rounds =
|
||||||
}
|
}
|
||||||
else if (rounds_change == 7)//blink white while fading back
|
else if (rounds_change == 7)//blink white while fading back
|
||||||
{
|
{
|
||||||
|
stopwatch_round_isactive = true;
|
||||||
if (!color_shift_init)
|
if (!color_shift_init)
|
||||||
{
|
{
|
||||||
color_shift_end[0] = 107;
|
color_shift_end[0] = 107;
|
||||||
|
@ -1640,6 +1643,26 @@ void(float width, float height) HUD_StopWatch =
|
||||||
drawstring([width - (strlen(stopwatch) * 12) - 2, 2], stopwatch, [12, 12], TEXT_ORANGE, 1, 0);
|
drawstring([width - (strlen(stopwatch) * 12) - 2, 2], stopwatch, [12, 12], TEXT_ORANGE, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void(float width, float height) HUD_RoundStopWatch =
|
||||||
|
{
|
||||||
|
string sec, min, hr;
|
||||||
|
string stopwatch;
|
||||||
|
|
||||||
|
if (stopwatch_round_sec < 10) {
|
||||||
|
sec = strcat("0", substring(ftos(stopwatch_round_sec), 0, 3));
|
||||||
|
} else {
|
||||||
|
sec = substring(ftos(stopwatch_round_sec), 0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sec == "00") sec = "00.0";
|
||||||
|
if (stopwatch_round_min < 10) min = strcat("0", ftos(stopwatch_round_min)); else min = ftos(stopwatch_round_min);
|
||||||
|
if (stopwatch_round_hr < 10) hr = strcat("0", ftos(stopwatch_round_hr)); else hr = ftos(stopwatch_round_hr);
|
||||||
|
|
||||||
|
stopwatch = strcat(hr, ":", min, ":", sec);
|
||||||
|
|
||||||
|
drawstring([width - (strlen(stopwatch) * 12) - 2, 16], stopwatch, [12, 12], [1, 1, 1], 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
* HUD Draw *
|
* HUD Draw *
|
||||||
*******************/
|
*******************/
|
||||||
|
@ -1702,6 +1725,9 @@ void(float width, float height) HUD_Draw =
|
||||||
if (cvar("scr_serverstopwatch")) {
|
if (cvar("scr_serverstopwatch")) {
|
||||||
HUD_StopWatch(width, height);
|
HUD_StopWatch(width, height);
|
||||||
}
|
}
|
||||||
|
if (cvar("scr_serverstopwatch") >= 2) {
|
||||||
|
HUD_RoundStopWatch(width, height);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
HUD_Waypoint(width, height);
|
HUD_Waypoint(width, height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,8 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init =
|
||||||
// in-game stopwatch
|
// in-game stopwatch
|
||||||
autocvar(scr_serverstopwatch, 0);
|
autocvar(scr_serverstopwatch, 0);
|
||||||
stopwatch_sec = stopwatch_min = stopwatch_hr = 0;
|
stopwatch_sec = stopwatch_min = stopwatch_hr = 0;
|
||||||
|
stopwatch_round_sec = stopwatch_round_min = stopwatch_round_hr = 0;
|
||||||
|
stopwatch_round_starttime = time;
|
||||||
|
|
||||||
// retrieve custom maps
|
// retrieve custom maps
|
||||||
Customs_Get();
|
Customs_Get();
|
||||||
|
@ -825,6 +827,21 @@ noref void(float width, float height, float menushown) CSQC_UpdateView =
|
||||||
stopwatch_min = 0;
|
stopwatch_min = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stopwatch_round_isactive) {
|
||||||
|
stopwatch_round_sec = (time - stopwatch_round_starttime) - (stopwatch_round_min * 60 + (stopwatch_round_hr * 3600));
|
||||||
|
|
||||||
|
if (stopwatch_round_sec >= 60) {
|
||||||
|
stopwatch_round_min += stopwatch_round_sec/60;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stopwatch_round_min >= 60) {
|
||||||
|
stopwatch_round_hr += stopwatch_round_min/60;
|
||||||
|
stopwatch_round_min = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stopwatch_round_starttime = time;
|
||||||
|
}
|
||||||
|
|
||||||
//autoadd entities received from servers for drawing
|
//autoadd entities received from servers for drawing
|
||||||
addentities(MASK_ENGINE);
|
addentities(MASK_ENGINE);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue