]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into z411/new_timer
authorz411 <z411@omaera.org>
Wed, 9 Feb 2022 19:54:41 +0000 (16:54 -0300)
committerz411 <z411@omaera.org>
Wed, 9 Feb 2022 19:54:41 +0000 (16:54 -0300)
hud_luma.cfg
hud_luminos.cfg
qcsrc/client/hud/panel/timer.qc
qcsrc/common/stats.qh
qcsrc/server/command/common.qh
qcsrc/server/round_handler.qc
qcsrc/server/world.qc
qcsrc/server/world.qh

index 7bcbef2b937fa8afb4af63737e06203c809eab90..faa8911e8b102033b55b6974f270484c12ad28f0 100644 (file)
@@ -134,7 +134,7 @@ seta hud_panel_notify_fadetime "3"
 seta hud_panel_notify_icon_aspect "1"
 
 seta hud_panel_timer_pos "0.456000 0"
-seta hud_panel_timer_size "0.088000 0.030000"
+seta hud_panel_timer_size "0.088000 0.050000"
 seta hud_panel_timer_bg "border_plain_north"
 seta hud_panel_timer_bg_color ""
 seta hud_panel_timer_bg_color_team ""
index 715d57efdcff1b8da2a2a9acfb537277446b097c..c680a5c6098b2b0ab7cfb5f5cdef729700c73aec 100644 (file)
@@ -134,7 +134,7 @@ seta hud_panel_notify_fadetime "3"
 seta hud_panel_notify_icon_aspect "2"
 
 seta hud_panel_timer_pos "0.800000 0.040000"
-seta hud_panel_timer_size "0.070000 0.040000"
+seta hud_panel_timer_size "0.070000 0.050000"
 seta hud_panel_timer_bg "border_small_timer"
 seta hud_panel_timer_bg_color ""
 seta hud_panel_timer_bg_color_team ""
index f70e5a2805962a43cbebc48607f65b80d27cda8b..87eff1fa090f81f05efc31d69abe243c8f47cf4b 100644 (file)
@@ -29,67 +29,113 @@ void HUD_Timer()
                HUD_Scale_Enable();
        else
                HUD_Scale_Disable();
-       HUD_Panel_DrawBg();
        if(panel_bg_padding)
        {
                pos += '1 1 0' * panel_bg_padding;
                mySize -= '2 2 0' * panel_bg_padding;
        }
 
-       string timer;
-       float timelimit, timeleft, minutesLeft;
-
-       timelimit = STAT(TIMELIMIT);
-
-       if (autocvar_hud_panel_timer_unbound){
-               timeleft = max(0, timelimit * 60 + STAT(GAMESTARTTIME) - time);
-       } else {
-               timeleft = bound(0, timelimit * 60 + STAT(GAMESTARTTIME) - time, timelimit * 60);
-       }
-       timeleft = ceil(timeleft);
-
-       minutesLeft = floor(timeleft / 60);
+       string timer, subtimer, subtext;
+       float timelimit, timeleft, overtimes;
+       float round_timelimit, round_timeleft;
 
-       float warmup_timeleft = 0;
+       // Calculate timelimit
        if(warmup_stage)
        {
-               float warmup_timelimit = STAT(WARMUP_TIMELIMIT);
-               if(warmup_timelimit > 0)
-                       warmup_timeleft = max(0, warmup_timelimit - time + STAT(GAMESTARTTIME));
-               else if(warmup_timelimit == 0)
-                       warmup_timeleft = timeleft;
-               warmup_timeleft = ceil(warmup_timeleft);
+               timelimit = STAT(WARMUP_TIMELIMIT);
+               if(timelimit == 0)
+                       timelimit = STAT(TIMELIMIT) * 60;
+       }
+       else
+       {
+               timelimit = STAT(TIMELIMIT) * 60;
        }
 
+       // Calculate time left
+       timeleft = timelimit + STAT(GAMESTARTTIME) - time;
+       if (!autocvar_hud_panel_timer_unbound)
+               timeleft = bound(0, timeleft, timelimit);
+       timeleft = ceil(timeleft);
+
+       // Timer color
        vector timer_color;
-       if(intermission_time || minutesLeft >= 5 || warmup_stage || timelimit == 0)
+       if(intermission_time || timeleft >= 300 || warmup_stage || timelimit <= 0)
                timer_color = '1 1 1'; //white
-       else if(minutesLeft >= 1)
+       else if(timeleft >= 60)
                timer_color = '1 1 0'; //yellow
        else
                timer_color = '1 0 0'; //red
 
+       // Timer text
        if (intermission_time) {
                timer = seconds_tostring(max(0, floor(intermission_time - STAT(GAMESTARTTIME))));
-       } else if (warmup_stage && warmup_timeleft >= 60) {
-               timer = _("WARMUP");
-       } else if (autocvar_hud_panel_timer_increment || (!warmup_stage && timelimit == 0) || (warmup_stage && warmup_timeleft <= 0)) {
-               if (time < STAT(GAMESTARTTIME))
-                       if (autocvar_hud_panel_timer_unbound){
-                               timer = seconds_tostring(-(STAT(GAMESTARTTIME) - time));
-                       } else {
-                               timer = seconds_tostring(0); //while restart is still active, show 00:00
-                       }
-               else
-                       timer = seconds_tostring(floor(time - STAT(GAMESTARTTIME)));
+       } else if (autocvar_hud_panel_timer_increment || timelimit <= 0) {
+               float time_elapsed = floor(time - STAT(GAMESTARTTIME));
+               if (!autocvar_hud_panel_timer_unbound)
+                       time_elapsed = max(0, time_elapsed);
+
+               timer = seconds_tostring(time_elapsed);
        } else {
-               if(warmup_stage)
-                       timer = seconds_tostring(warmup_timeleft);
-               else
-                       timer = seconds_tostring(timeleft);
+               timer = seconds_tostring(timeleft);
        }
-
-       drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
+       
+       // Subtimer text
+       if(STAT(ROUNDSTARTTIME))
+       {
+               round_timelimit = STAT(ROUND_TIMELIMIT);
+               
+               if (autocvar_hud_panel_timer_increment || round_timelimit <= 0) {
+                       float round_time_elapsed = floor(time - STAT(ROUNDSTARTTIME));
+                       if (!autocvar_hud_panel_timer_unbound)
+                               round_time_elapsed = max(0, round_time_elapsed);
+
+                       subtimer = seconds_tostring(round_time_elapsed);
+               } else {
+                       round_timeleft = round_timelimit + STAT(ROUNDSTARTTIME) - time;
+                       if (!autocvar_hud_panel_timer_unbound)
+                               round_timeleft = bound(0, round_timeleft, round_timelimit);
+                       round_timeleft = ceil(round_timeleft);
+                       
+                       subtimer = seconds_tostring(round_timeleft);
+               }
+       }
+       else
+               subtimer = string_null;
+
+       // Subtext
+       overtimes = STAT(OVERTIMESADDED);
+
+       if(warmup_stage || autocvar__hud_configure)
+               subtext = _("Warmup");
+       else if(intermission_time)
+               subtext = _("Intermission");
+       else if(STAT(TIMEOUT_STATUS))
+               subtext = _("Timeout");
+       else if (overtimes >= 2)
+               subtext = sprintf(_("Overtime #%d"), overtimes);
+       else if(overtimes)
+               subtext = _("Overtime");
+       else
+               subtext = string_null;
+
+       vector timer_size, subtext_size, subtimer_size;
+       
+       subtext_size  = vec2(mySize.x, mySize.y / 3);
+       timer_size    = vec2(mySize.x, mySize.y - subtext_size.y);
+       subtimer_size = vec2(mySize.x / 3, mySize.y - subtext_size.y);
+       
+       panel_size.y -= subtext_size.y;
+       HUD_Panel_DrawBg();
+       
+       if(subtimer) {
+               timer_size.x -= subtimer_size.x;
+               drawstring_aspect(pos + eX * timer_size.x, subtimer, subtimer_size, '1 1 0', panel_fg_alpha, DRAWFLAG_NORMAL);
+       }
+       
+       drawstring_aspect(pos, timer, timer_size, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
+       
+       if(subtext)
+               drawstring_aspect(pos + eY * timer_size.y, subtext, subtext_size, '1 0 0', panel_fg_alpha, DRAWFLAG_NORMAL);
 
        draw_endBoldFont();
 }
index 091f7e689dbb1960c7e71c1312d11da1646ef866..afc4b5e9ff52011a0d969197608582d0d6a02e67 100644 (file)
@@ -79,6 +79,9 @@ float game_stopped;
 float game_starttime; //point in time when the countdown to game start is over
 float round_starttime; //point in time when the countdown to round start is over
 int autocvar_leadlimit;
+float checkrules_overtimesadded;
+float timeout_status; // (values: 0, 1, 2) contains whether a timeout is not active (0), was called but still at leadtime (1) or is active (2)
+
 // TODO: world.qh can't be included here due to circular includes!
 #define autocvar_fraglimit cvar("fraglimit")
 #define autocvar_fraglimit_override cvar("fraglimit_override")
@@ -115,6 +118,8 @@ REGISTER_STAT(SECRETS_TOTAL, int, secrets_total)
 REGISTER_STAT(SECRETS_FOUND, int, secrets_found)
 REGISTER_STAT(RESPAWN_TIME, float)
 REGISTER_STAT(ROUNDSTARTTIME, float, round_starttime)
+REGISTER_STAT(OVERTIMESADDED, float, checkrules_overtimesadded)
+REGISTER_STAT(TIMEOUT_STATUS, float, timeout_status)
 REGISTER_STAT(MONSTERS_TOTAL, int)
 REGISTER_STAT(MONSTERS_KILLED, int)
 REGISTER_STAT(NADE_BONUS, float)
@@ -360,6 +365,7 @@ REGISTER_STAT(Q3COMPAT, int, q3compat)
 #ifdef SVQC
 #include "physics/movetypes/movetypes.qh"
 float warmup_limit;
+float round_limit;
 #endif
 
 #ifdef SVQC
@@ -399,6 +405,7 @@ REGISTER_STAT(MOVEVARS_AIRCONTROL, float)
 REGISTER_STAT(FRAGLIMIT, float, autocvar_fraglimit)
 REGISTER_STAT(TIMELIMIT, float, autocvar_timelimit)
 REGISTER_STAT(WARMUP_TIMELIMIT, float, warmup_limit)
+REGISTER_STAT(ROUND_TIMELIMIT, float, round_limit)
 #ifdef SVQC
 float autocvar_sv_wallfriction;
 #define autocvar_sv_gravity cvar("sv_gravity")
index 5fd66bdbbac1f595e76e0bb06ca4024d0865ea46..5fbf0dc697d5a0ac5d046292d525f6a6c2def2a5 100644 (file)
@@ -58,7 +58,6 @@ float sys_frametime;     // gets initialised in worldspawn, saves the value from
 float orig_slowmo;       // contains the value of autocvar_slowmo so that, after timeout finished, it isn't set to slowmo 1 necessarily
 float timeout_time;      // contains the time in seconds that the active timeout has left
 float timeout_leadtime;  // contains the number of seconds left of the leadtime (before the timeout starts)
-float timeout_status;    // (values: 0, 1, 2) contains whether a timeout is not active (0), was called but still at leadtime (1) or is active (2)
 .float allowed_timeouts; // contains the number of allowed timeouts for each player
 .vector lastV_angle;     // used when pausing the game in order to force the player to keep his old view angle fixed
 
index 5307eca782a827398f66eed801fdd73682d458b4..fa68211f9e8fd442c42dc0875505a819fa5943f1 100644 (file)
@@ -75,6 +75,7 @@ void round_handler_Init(float the_delay, float the_count, float the_round_timeli
        this.count = fabs(floor(the_count));
        this.cnt = this.count + 1;
        this.round_timelimit = (the_round_timelimit > 0) ? the_round_timelimit : 0;
+       round_limit = the_round_timelimit;
 }
 
 // NOTE: this is only needed because if round_handler spawns at time 1
index 51093d51b512abb12fc687c7b391ee0fea9b28db..604b4bd5be32c5002f1a179a9ef729f3917741ed 100644 (file)
@@ -1636,6 +1636,7 @@ void CheckRules_World()
                                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_RACE_FINISHLAP);
                        else
                                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_OVERTIME_FRAG);
+                       checkrules_overtimesadded = 1;
                }
        }
        else
index 299c88535446724e3819fc5f90c67ac07efe0693..9cd9799f6e8f96eeb3e08e7944fa562dd340aa44 100644 (file)
@@ -30,7 +30,7 @@ float autocvar_timelimit_suddendeath;
 float checkrules_equality;
 float checkrules_suddendeathwarning;
 float checkrules_suddendeathend;
-float checkrules_overtimesadded; //how many overtimes have been already added
+//float checkrules_overtimesadded; //how many overtimes have been already added
 
 // flag set on worldspawn so that the code knows if it is dedicated or not
 bool server_is_dedicated;