]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make the speed unit a global, consistent setting
authorz411 <z411@omaera.org>
Sun, 19 Mar 2023 11:07:04 +0000 (11:07 +0000)
committerterencehill <piuntn@gmail.com>
Sun, 19 Mar 2023 11:07:04 +0000 (11:07 +0000)
_hud_common.cfg
qcsrc/client/hud/hud.qh
qcsrc/client/hud/panel/physics.qc
qcsrc/client/hud/panel/physics.qh
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/hud/panel/strafehud.qc
qcsrc/client/hud/panel/strafehud.qh
qcsrc/client/main.qc
qcsrc/menu/xonotic/dialog_hudpanel_physics.qc
qcsrc/menu/xonotic/dialog_settings_game_hud.qc

index 766f89819bc9d1ef4095699a0c7eb3465cd23fe4..6339895eafd312488b037769801bb5611e7e5854 100644 (file)
@@ -19,6 +19,8 @@ seta hud_colorset_kill_2 "3" "similar to above, but less important... OR, a high
 seta hud_colorset_kill_3 "4" "'good' or 'beneficial' text (you fragging someone, etc)"
 seta hud_colorset_background "7" "neutral/unimportant text"
 
+seta hud_speed_unit "1" "speed unit (1 = qu/s, 2 = m/s, 3 = km/h, 4 = mph, 5 = knots)"
+
 // general hud panel cvars (i.e. shouldn't be adjusted by a skin config)
 seta hud_panel_weapons          1 "enable this panel"
 seta hud_panel_ammo             1 "enable this panel"
@@ -106,7 +108,6 @@ seta hud_panel_engineinfo_framecounter_time "0.1" "time between framerate displa
 
 seta hud_panel_physics_acceleration_movingaverage 1 "use an averaging method for calculating acceleration instead of the real value"
 seta hud_panel_physics_update_interval 0.016 "how often (in seconds) numeric values get updated on screen"
-seta hud_panel_physics_speed_unit "1" "speed unit (1 = qu/s, 2 = m/s, 3 = km/h, 4 = mph, 5 = knots)"
 
 seta hud_panel_itemstime_progressbar_maxtime "30" "when left time is at least this amount, the status bar is full"
 seta hud_panel_itemstime_hidespawned "1" "if 1 hide an item from the panel when all the occurrences of it are available again; if 2 hide it when at least one occurrence is available again"
@@ -157,7 +158,6 @@ seta _hud_panel_strafehud_demo "0" "strafehud changes angle during configure"
 seta hud_panel_strafehud_mode "0" "strafehud mode which controls whether the strafehud is centered at \"0\" = view angle, \"1\" = velocity angle"
 seta hud_panel_strafehud_range "0" "the angle range up to 360 degrees displayed on the strafehud, \"0\" = dynamic (chooses the minimum range required to still see the whole area needed for accelerating at once)"
 seta hud_panel_strafehud_style "1" "\"0\" = no styling, \"1\" = progress bar style for the strafe bar, \"2\" = gradient for the strafe bar"
-seta hud_panel_strafehud_unit "1" "speed unit (1 = qu/s, 2 = m/s, 3 = km/h, 4 = mph, 5 = knots), length unit (1 = qu, 2 = m, 3 = km, 4 = mi, 5 = nmi)"
 seta hud_panel_strafehud_unit_show "1" "show units"
 seta hud_panel_strafehud_bar_neutral_color "1 1 1" "color of the strafe meter neutral zone"
 seta hud_panel_strafehud_bar_neutral_alpha "0.3" "opacity of the strafe meter neutral zone"
index 0eb81916cec1562540c718b4589fb0a2c7dd640d..312aaea99be3a978b1ca78e996452cea18e5479d 100644 (file)
@@ -203,6 +203,8 @@ string autocvar_hud_skin;
 float autocvar_hud_progressbar_alpha;
 float autocvar_hud_panel_update_interval;
 
+int autocvar_hud_speed_unit;
+
 float autocvar_hud_dynamic_follow;
 float autocvar_hud_dynamic_follow_scale;
 vector autocvar_hud_dynamic_follow_scale_xyz;
index 53d778a4ba2ffac65fd43658cd5d861199e50d9c..efbf045cd5d5908d4c3defa10eb7f4c0700121a8 100644 (file)
@@ -63,7 +63,7 @@ void HUD_Physics()
                text_scale = min(autocvar_hud_panel_physics_text_scale, 1);
 
        //compute speed
-       float speed, conversion_factor = GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit);
+       float speed, conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit);
        vector vel = (csqcplayer ? csqcplayer.velocity : pmove_vel);
 
        float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
@@ -177,7 +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);
+                       string unit = GetSpeedUnit(autocvar_hud_speed_unit);
                        drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                }
        }
index e0f93b0f530df38848377cfbf060e989f914af39..353a970cd183f3d4eba889e60ed252b0ee8f04d6 100644 (file)
@@ -14,7 +14,6 @@ int autocvar_hud_panel_physics_baralign;
 bool autocvar_hud_panel_physics_flip;
 bool autocvar_hud_panel_physics_dynamichud      = true;
 float autocvar_hud_panel_physics_speed_max;
-int autocvar_hud_panel_physics_speed_unit;
 bool autocvar_hud_panel_physics_speed_unit_show;
 bool autocvar_hud_panel_physics_speed_vertical;
 int autocvar_hud_panel_physics_text;
index 9256d162bc83721c86c06e94f075a5fb4d81391f..cd176345fc060fa42b4428902eb3d88a611cf6ea 100644 (file)
@@ -2455,7 +2455,8 @@ void Scoreboard_Draw()
 
        if(MUTATOR_CALLHOOK(ShowRankings)) {
                string ranktitle = M_ARGV(0, string);
-               string unit = GetSpeedUnit(autocvar_hud_panel_physics_speed_unit);
+               string unit = GetSpeedUnit(autocvar_hud_speed_unit);
+               float conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit);
                if(race_speedaward_alltimebest)
                {
                        string name;
@@ -2464,11 +2465,11 @@ void Scoreboard_Draw()
                        if(race_speedaward)
                        {
                                name = textShortenToWidth(ColorTranslateRGB(race_speedaward_holder), namesize, hud_fontsize, stringwidth_colors);
-                               str = sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward, unit, name);
+                               str = sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward * conversion_factor, unit, name);
                                str = strcat(str, " / ");
                        }
                        name = textShortenToWidth(ColorTranslateRGB(race_speedaward_alltimebest_holder), namesize, hud_fontsize, stringwidth_colors);
-                       str = strcat(str, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest, unit, name));
+                       str = strcat(str, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest * conversion_factor, unit, name));
                        drawcolorcodedstring(pos, str, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
                        pos.y += 1.25 * hud_fontsize.y; // line height + line spacing
                }
index e4e339c44a53497c54e60485d00ce88b23468134..46e8b7631b4eb7d3529f622c491cf9222ae00e86 100644 (file)
@@ -116,9 +116,9 @@ void HUD_StrafeHUD()
 
         // HUD
         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);
-        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  speed_conversion_factor       = GetSpeedUnitFactor(autocvar_hud_speed_unit);
+        float  length_conversion_factor      = GetLengthUnitFactor(autocvar_hud_speed_unit);
+        int    length_decimals               = autocvar_hud_speed_unit >= 3 && autocvar_hud_speed_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);
         float  minspeed;
@@ -639,7 +639,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);
+                string speed_unit = GetSpeedUnit(autocvar_hud_speed_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);
             }
         }
@@ -674,7 +674,7 @@ void HUD_StrafeHUD()
                 float text_alpha = cos(((time - jumptime) / autocvar_hud_panel_strafehud_jumpheight_fade) * 90 * DEG2RAD); // fade non-linear like the physics panel does
                 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);
+                string length_unit = GetLengthUnit(autocvar_hud_speed_unit);
                 drawstring_aspect(panel_pos - eY * jumpheight_size.y, strcat(ftos_decimals(jumpheight, 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 2fbd9b27526ca84e467cf83c23f13aff8dd8a9ef..64a78c981466ec9a8eda3a631c63f2561694b119 100644 (file)
@@ -7,7 +7,6 @@ bool autocvar_hud_panel_strafehud_dynamichud    = true;
 int autocvar_hud_panel_strafehud_mode = 0;
 float autocvar_hud_panel_strafehud_range = 0;
 int autocvar_hud_panel_strafehud_style = 1;
-int autocvar_hud_panel_strafehud_unit = 1;
 bool autocvar_hud_panel_strafehud_unit_show = true;
 vector autocvar_hud_panel_strafehud_bar_neutral_color = '1 1 1';
 float autocvar_hud_panel_strafehud_bar_neutral_alpha = 0.3;
index 4e05e681db3d48d8c37276dfe4339e4e895fcd9e..8f10bd7574043f95fe64b0751a5461b55eb3eaed 100644 (file)
@@ -1254,11 +1254,11 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew)
                        race_server_record = ReadInt24_t();
                        break;
                case RACE_NET_SPEED_AWARD:
-                       race_speedaward = ReadInt24_t() * GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit);
+                       race_speedaward = ReadInt24_t();
                        strcpy(race_speedaward_holder, ReadString());
                        break;
                case RACE_NET_SPEED_AWARD_BEST:
-                       race_speedaward_alltimebest = ReadInt24_t() * GetSpeedUnitFactor(autocvar_hud_panel_physics_speed_unit);
+                       race_speedaward_alltimebest = ReadInt24_t();
                        strcpy(race_speedaward_alltimebest_holder, ReadString());
                        break;
                case RACE_NET_RANKINGS_CNT:
index 3a1e0bee1822a42e2fd363323e8f41cec73296f4..db966263f03e98d62b2ce06ee0e60b471479502f 100644 (file)
@@ -45,16 +45,8 @@ void XonoticHUDPhysicsDialog_fill(entity me)
                // me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("qu/s")));
                        // setDependent(e, "hud_panel_physics_progressbar", 1, 1);
        me.TR(me);
-               me.TDempty(me, 0.2);
-               me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Speed unit:")));
-               me.TD(me, 1, 2.6/3*2, e = makeXonoticTextSlider("hud_panel_physics_speed_unit"));
-                       e.addValue(e, _("qu/s") , "1");
-                       e.addValue(e, _("m/s")  , "2");
-                       e.addValue(e, _("km/h") , "3");
-                       e.addValue(e, _("mph")  , "4");
-                       e.addValue(e, _("knots"), "5");
-                       e.configureXonoticTextSliderValues(e);
-               me.TD(me, 1, 2.6/3, e = makeXonoticCheckBox(0, "hud_panel_physics_speed_unit_show", _("Show")));
+               me.TDempty(me, 1);
+               me.TD(me, 1, 3, e = makeXonoticCheckBox(0, "hud_panel_physics_speed_unit_show", _("Show speed unit")));
        me.TR(me);
                me.TDempty(me, 0.2);
                me.TD(me, 1, 3.8/2, e = makeXonoticCheckBox(0, "hud_panel_physics_topspeed", _("Top speed")));
index 76ee74c599c3242581f20bbaf3747a43e0a09f78..dadef064763604ae27aa79de8345cfa673be80c3 100644 (file)
@@ -159,6 +159,15 @@ void XonoticGameHUDSettingsTab_fill(entity me)
                        setDependent(e, "hud_shownames", 1, 1);
 
        me.TR(me);
+       me.TR(me);
+               me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Speed unit:")));
+               me.TD(me, 1, 2, e = makeXonoticTextSlider("hud_speed_unit"));
+                       e.addValue(e, _("qu/s") , "1");
+                       e.addValue(e, _("m/s")  , "2");
+                       e.addValue(e, _("km/h") , "3");
+                       e.addValue(e, _("mph")  , "4");
+                       e.addValue(e, _("knots"), "5");
+                       e.configureXonoticTextSliderValues(e);
        me.TR(me);
                me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Damage overlay:")));
                me.TD(me, 1, 2, e = makeXonoticSlider(0, 1, 0.05, "hud_damage"));