]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/racetimer.qc
Merge branch 'terencehill/spectate_player' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / racetimer.qc
index 7ad7f943d1ddffa61352704813b1f774d9f83d53..281b2377ff10e839439cd83f002a5ef6ebf93130 100644 (file)
@@ -1,5 +1,8 @@
 #include "racetimer.qh"
 
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
 #include <common/mapinfo.qh>
 
 // Race timer (#6)
@@ -68,7 +71,7 @@ string MakeRaceString(int cp, float mytime, float theirtime, float othertime, fl
                        othertimestr = strcat("+", ftos_decimals(mytime - othertime, TIME_DECIMALS));
                else
                        othertimestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(othertime));
-               othercol = "^3";
+               othercol = "^7";
        }
 
        if(cp == 254)
@@ -95,7 +98,7 @@ void HUD_RaceTimer ()
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_racetimer) return;
-               if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
+               if(!(ISGAMETYPE(RACE) || ISGAMETYPE(CTS))) return;
                if(spectatee_status == -1) return;
        }
 
@@ -145,10 +148,11 @@ void HUD_RaceTimer ()
                str_pos = pos + eX * 0.5 * (mySize.x - stringwidth(s, false, '1 1 0' * 0.6 * mySize.y));
                drawstring(str_pos, s, '1 1 0' * 0.6 * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                draw_endBoldFont();
-               s = _("^1Intermediate 1 (+15.42)");
+               s = strcat("^1", sprintf(_("Intermediate %d"), 1), " (+15.42)");
                str_pos = pos + vec2(0.5 * (mySize.x - stringwidth(s, true, '1 1 0' * 0.2 * mySize.y)), 0.6 * mySize.y);
                drawcolorcodedstring(str_pos, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL);
-               s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
+               s = sprintf(_("PENALTY: %.1f (%s)"), 2, _("missing a checkpoint"));
+               s = strcat("^1", s);
                str_pos = pos + vec2(0.5 * (mySize.x - stringwidth(s, true, '1 1 0' * 0.2 * mySize.y)), 0.8 * mySize.y);
                drawcolorcodedstring(str_pos, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL);
        }
@@ -176,14 +180,9 @@ void HUD_RaceTimer ()
                                if(race_nextbesttime)
                                {
                                        a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
-                                       float a2 = bound(0, 2 - ((race_laptime + TIME_DECODE(race_mybesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
+                                       float a2 = ((race_mybesttime) ? bound(0, 2 - ((race_laptime + TIME_DECODE(race_mybesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1) : 0);
                                        if(a > 0) // next one?
                                                s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), ((a2 > 0) ? TIME_DECODE(race_mybesttime) : 0), 0, race_nextbestname);
-                                       else if(a2 > 0)
-                                       {
-                                               a = a2;
-                                               s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_mybesttime), 0, 0, "");
-                                       }
                                }
                        }
                }
@@ -199,7 +198,8 @@ void HUD_RaceTimer ()
                        a = bound(0, 2 - (time - race_penaltyeventtime), 1);
                        if(a > 0)
                        {
-                               s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
+                               s = sprintf(_("PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
+                               s = strcat("^1", s);
                                str_pos = pos + vec2(0.5 * (mySize.x - stringwidth(s, true, '1 1 0' * 0.2 * mySize.y)), 0.8 * mySize.y);
                                drawcolorcodedstring(str_pos, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                        }
@@ -248,10 +248,19 @@ void HUD_RaceTimer ()
                        a = bound(0, (1 + t - time), 1);
                        if(a > 0)
                        {
+                               string col;
                                if(time < t)
-                                       s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
+                               {
+                                       t = (t - time) * 0.1;
+                                       col = "^1";
+                               }
                                else
-                                       s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
+                               {
+                                       t = 0;
+                                       col = "^2";
+                               }
+                               s = sprintf(_("PENALTY: %.1f (%s)"), t, race_penaltyreason);
+                               s = strcat(col, s);
                                str_pos = pos + vec2(0.5 * (mySize.x - stringwidth(s, true, '1 1 0' * 0.2 * mySize.y)), 0.6 * mySize.y);
                                drawcolorcodedstring(str_pos, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
                        }