]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/timer.qc
Merge branch 'master' into z411/bai-server
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / timer.qc
index aa0c73b5bf90c4d08ea4e37d0d49cdb7f1ab460e..003f1c4b736662ff8a9754be77bfeda5881e2b39 100644 (file)
@@ -5,6 +5,8 @@
 #include <client/view.qh>
 
 // Timer (#5)
+float last_timeleft;
+int autocvar_cl_timer_countdown = 3; // 0 = disabled, 1 = always on, 2 = only spec, 3 = as dictated by server
 
 void HUD_Timer_Export(int fh)
 {
@@ -70,6 +72,7 @@ void HUD_Timer()
        vector timer_color = '1 1 1';
        vector subtimer_color = '1 1 1';
        bool swap = (autocvar_hud_panel_timer_secondary == 2 && STAT(ROUNDSTARTTIME));
+       float timeout_last = STAT(TIMEOUT_LAST);
 
        // Use real or frozen time and get the time limit
        curtime = (intermission_time ? intermission_time : time);
@@ -82,8 +85,26 @@ void HUD_Timer()
        if(!intermission_time && !warmup_stage && timelimit > 0)
                timer_color = HUD_Timer_Color(timeleft);
 
+       // countdown sound
+       // if 3 use server dictated option, otherwise the client's
+       int countdown_type;
+       if(autocvar_cl_timer_countdown == 3)
+               countdown_type = sv_timer_countdown;
+       else
+               countdown_type = autocvar_cl_timer_countdown;
+       
+       if(countdown_type && !warmup_stage && timeleft > 0 && timeleft != last_timeleft && timeleft <= 10 && !intermission_time)
+       {
+               if(countdown_type == 1 || (countdown_type == 2 && spectatee_status))
+                       sound(NULL, CH_INFO, SND_ENDCOUNT, VOL_BASE, ATTN_NONE);
+               
+               last_timeleft = timeleft;
+       }
+
        // Timer text
-       if (autocvar_hud_panel_timer_increment || timelimit <= 0)
+       if (timelimit == -1)
+               timer = (autocvar_hud_panel_timer_increment ? 0 : STAT(TIMELIMIT) * 60);
+       else if (autocvar_hud_panel_timer_increment || timelimit <= 0)
                timer = HUD_Timer_TimeElapsed(curtime, STAT(GAMESTARTTIME));
        else
                timer = timeleft;
@@ -96,12 +117,19 @@ void HUD_Timer()
                        subtimer_str = "--:--";
                        subtimer_color = '1 0 0';
                } else {
-                       float round_curtime, round_timelimit, round_timeleft;
+                       float round_curtime, round_endtime, round_timelimit, round_timeleft;
 
                        // Use real or frozen time and get the time limit
-                       round_curtime = (game_stopped_time ? game_stopped_time : time);
+                       round_endtime = STAT(ROUNDENDTIME);
                        round_timelimit = STAT(ROUND_TIMELIMIT);
 
+                       if(round_endtime)
+                               round_curtime = round_endtime;
+                       else if(timeout_last)
+                               round_curtime = timeout_last;
+                       else
+                               round_curtime = time;
+
                        // Calculate time left
                        round_timeleft = HUD_Timer_TimeLeft(round_curtime, STAT(ROUNDSTARTTIME), round_timelimit);
 
@@ -121,20 +149,13 @@ void HUD_Timer()
        int overtimes = STAT(OVERTIMES);
 
        if(warmup_stage || autocvar__hud_configure)
-       {
-               if (STAT(WARMUP_TIMELIMIT) > 0)
-                       subtext = _("Warmup");
-               else
-                       subtext = srv_minplayers ? _("Warmup: too few players") : _("Warmup: no time limit");
-       }
+               subtext = _("Warmup");
        else if(STAT(TIMEOUT_STATUS) == 2)
                subtext = _("Timeout");
-       else if (overtimes == -1)
-               subtext = _("Sudden Death");
-       else if(overtimes == 1)
-               subtext = _("Overtime");
-       else if (overtimes >= 2)
+       else if(overtimes >= 2)
                subtext = sprintf(_("Overtime #%d"), overtimes);
+       else if(overtimes != 0)
+               subtext = _("Overtime");
 
        subtext_size  = vec2(mySize.x, mySize.y / 3);
        timer_size    = vec2(mySize.x, mySize.y - subtext_size.y);