]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Rankings panel: allow immediate update of speed unit when changing hud_panel_physics_...
authorterencehill <piuntn@gmail.com>
Thu, 8 Jul 2021 21:38:23 +0000 (23:38 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 8 Jul 2021 21:38:23 +0000 (23:38 +0200)
qcsrc/client/hud/panel/physics.qc
qcsrc/client/hud/panel/racetimer.qh
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/hud/panel/strafehud.qc
qcsrc/client/main.qc

index 6a0baed31bc124f644e07985d8a65fc33d32a18b..53d778a4ba2ffac65fd43658cd5d861199e50d9c 100644 (file)
@@ -64,7 +64,6 @@ void HUD_Physics()
 
        //compute speed
        float speed, conversion_factor = GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit);
-       string unit = GetSpeedUnit(autocvar_hud_panel_physics_speed_unit);
        vector vel = (csqcplayer ? csqcplayer.velocity : pmove_vel);
 
        float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
@@ -178,6 +177,7 @@ void HUD_Physics()
                        tmp_size.x = panel_size.x * (1 - 0.75);
                        tmp_size.y = panel_size.y * 0.4 * text_scale;
                        tmp_offset.y = (panel_size.y * 0.4 - tmp_size.y) / 2;
+                       string unit = GetSpeedUnit(autocvar_hud_panel_physics_speed_unit);
                        drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                }
        }
index ba7bd32298137f0b532cc4e01e6a69274f64f613..8f4c09c101ed60b14e7c420f0fd99e681f8c6942 100644 (file)
@@ -23,10 +23,8 @@ string race_penaltyreason; // reason for penalty
 float race_server_record; // server record
 float race_speedaward;
 string race_speedaward_holder;
-string race_speedaward_unit;
 float race_speedaward_alltimebest;
 string race_speedaward_alltimebest_holder;
-string race_speedaward_alltimebest_unit;
 
 // RACE
 float race_mycheckpoint;
index 6133b18de6b9b76becf29352123fb32556884912..5cd42e545c6af4d55290411e37b33496dbced26e 100644 (file)
@@ -2070,12 +2070,13 @@ void Scoreboard_Draw()
 
        if(MUTATOR_CALLHOOK(ShowRankings)) {
                string ranktitle = M_ARGV(0, string);
+               string unit = GetSpeedUnit(autocvar_hud_panel_physics_speed_unit);
                if(race_speedaward) {
-                       drawcolorcodedstring(pos, sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward, race_speedaward_unit, ColorTranslateRGB(race_speedaward_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawcolorcodedstring(pos, sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward, unit, ColorTranslateRGB(race_speedaward_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
                        pos.y += 1.25 * hud_fontsize.y;
                }
                if(race_speedaward_alltimebest) {
-                       drawcolorcodedstring(pos, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest, race_speedaward_alltimebest_unit, ColorTranslateRGB(race_speedaward_alltimebest_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawcolorcodedstring(pos, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest, unit, ColorTranslateRGB(race_speedaward_alltimebest_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
                        pos.y += 1.25 * hud_fontsize.y;
                }
                if (race_speedaward || race_speedaward_alltimebest)
index dd9594b7b522071fa23dffd10cb076ade2da4c21..2f0df08213ec3c599888571f4063b77fe99185a8 100644 (file)
@@ -124,8 +124,6 @@ void HUD_StrafeHUD()
         int    mode                          = autocvar_hud_panel_strafehud_mode >= 0 && autocvar_hud_panel_strafehud_mode <= 1 ? autocvar_hud_panel_strafehud_mode : 0;
         float  speed_conversion_factor       = GetSpeedUnitFactor(autocvar_hud_panel_strafehud_unit);
         float  length_conversion_factor      = GetLengthUnitFactor(autocvar_hud_panel_strafehud_unit);
-        string speed_unit                    = GetSpeedUnit(autocvar_hud_panel_strafehud_unit);
-        string length_unit                   = GetLengthUnit(autocvar_hud_panel_strafehud_unit);
         int    length_decimals               = autocvar_hud_panel_strafehud_unit >= 3 && autocvar_hud_panel_strafehud_unit <= 5 ? 6 : 2; // use more decimals when displaying km or miles
         float  antiflicker_angle             = bound(0, autocvar_hud_panel_strafehud_antiflicker_angle, 180);
         float  antiflicker_speed             = max(0, autocvar_hud_panel_strafehud_antiflicker_speed);
@@ -647,6 +645,7 @@ void HUD_StrafeHUD()
             {
                 vector startspeed_size = panel_size;
                 startspeed_size.y = panel_size.y * min(autocvar_hud_panel_strafehud_startspeed_size, 5);
+                string speed_unit = GetSpeedUnit(autocvar_hud_panel_strafehud_unit);
                 drawstring_aspect(panel_pos + eY * panel_size.y, strcat(ftos_decimals(startspeed * speed_conversion_factor, 2), autocvar_hud_panel_strafehud_unit_show ? speed_unit : ""), startspeed_size, autocvar_hud_panel_strafehud_startspeed_color, text_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
             }
         }
@@ -699,6 +698,7 @@ void HUD_StrafeHUD()
             {
                 vector jumpheight_size = panel_size;
                 jumpheight_size.y = panel_size.y * min(autocvar_hud_panel_strafehud_jumpheight_size, 5);
+                string length_unit = GetLengthUnit(autocvar_hud_panel_strafehud_unit);
                 drawstring_aspect(panel_pos - eY * jumpheight_size.y, strcat(ftos_decimals(jumpheight_persistent * length_conversion_factor, length_decimals), autocvar_hud_panel_strafehud_unit_show ? length_unit : ""), jumpheight_size, autocvar_hud_panel_strafehud_jumpheight_color, text_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
             }
         }
index 757effd99bf766574f3fb328e25766ad5e782a90..ca49edd03c42b05442f35eddd6237f8fba8b1409 100644 (file)
@@ -1183,12 +1183,10 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew)
                case RACE_NET_SPEED_AWARD:
                        race_speedaward = ReadInt24_t() * GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit);
                        strcpy(race_speedaward_holder, ReadString());
-                       strcpy(race_speedaward_unit, GetSpeedUnit(autocvar_hud_panel_physics_speed_unit));
                        break;
                case RACE_NET_SPEED_AWARD_BEST:
                        race_speedaward_alltimebest = ReadInt24_t() * GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit);
                        strcpy(race_speedaward_alltimebest_holder, ReadString());
-                       strcpy(race_speedaward_alltimebest_unit, GetSpeedUnit(autocvar_hud_panel_physics_speed_unit));
                        break;
                case RACE_NET_RANKINGS_CNT:
                        RANKINGS_DISPLAY_CNT = ReadByte();