]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add support for showing speed in splits to racetimer
authorDes - <gitlab@damianv.com.ar>
Tue, 3 Dec 2024 10:11:34 +0000 (10:11 +0000)
committerDr. Jaska <drjaska83@gmail.com>
Tue, 3 Dec 2024 10:11:34 +0000 (10:11 +0000)
qcsrc/client/hud/panel/racetimer.qc
qcsrc/client/hud/panel/racetimer.qh
qcsrc/client/main.qh
xonotic-client.cfg

index 514a9c25883d71f354c22a77dad0bd415f58f6aa..e26b72bc3cb1169aac65a706b4d17b00ad49d14f 100644 (file)
@@ -1,4 +1,5 @@
 #include "racetimer.qh"
+#include "physics.qh"
 
 #include <client/draw.qh>
 #include <common/ent_cs.qh>
@@ -222,6 +223,31 @@ void HUD_RaceTimer ()
                                                s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, ((race_mypreviousbesttime) ? TIME_DECODE(race_time) - TIME_DECODE(race_mypreviousbesttime) : 0), 0, race_previousbestname);
                                        else
                                                s = MakeRaceString(race_checkpoint, 0, -1, 0, 0, race_previousbestname);
+
+                                       if(autocvar_cl_race_cptimes_showspeed)
+                                       {
+                                               float speed_conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit);
+                                               float speed = race_timespeed;
+                                               float speed_diff = rint(speed - race_checkpoint_splits_speed[race_checkpoint]);
+                                               string units_text = autocvar_cl_race_cptimes_showspeed_unit ? GetSpeedUnit(autocvar_hud_speed_unit) : "";
+
+                                               // figure out color
+                                               string speed_color = rgb_to_hexcolor(autocvar_hud_progressbar_acceleration_neg_color);
+                                               if(speed_diff > 0) speed_color = rgb_to_hexcolor(autocvar_hud_progressbar_acceleration_color);
+                                               else if (speed_diff == 0) speed_color = "^3";
+
+                                               if(race_time && race_previousbesttime && race_checkpoint_splits_speed[race_checkpoint])
+                                                       s = sprintf("%s ^7%d%s %s(%+d%s)", s, speed * speed_conversion_factor, units_text, speed_color, speed_diff * speed_conversion_factor, units_text);
+                                               else
+                                                       s = sprintf("%s ^7%d%s", s, speed * speed_conversion_factor, units_text);
+
+                                               // if fastest cp time, store speed for later comparison
+                                               if((TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime)) < 0 || !race_checkpoint_splits_speed[race_checkpoint])
+                                               {
+                                                       race_checkpoint_splits_speed[race_checkpoint] = speed;
+                                               }
+
+                                       }
                                        if(race_time)
                                                forcetime = TIME_ENCODED_TOSTRING(race_time, false);
 
index 054fe82870636ccc85cd2c719b423ce396b52b26..b471209b634d4cf2264a5b2312c29e45b303f45f 100644 (file)
@@ -12,6 +12,7 @@ float race_timebestspeed;
 float race_laptime;
 float race_checkpointtime;
 string race_checkpoint_splits[256];
+float race_checkpoint_splits_speed[256];
 float race_previousbesttime;
 float race_mypreviousbesttime;
 string race_previousbestname;
index 698c70b2d94495073bd89cd238ed560db54ae1f2..66d10cdae2a5c56cf4c46417cc6c16688953943a 100644 (file)
@@ -23,9 +23,13 @@ bool autocvar_developer_csqcentities;
 // this can't be done now as players would lack these from their configs then
 bool autocvar_cl_race_checkpoint_splits_console;
 bool autocvar_cl_race_checkpoint_splits_hud;
+bool autocvar_cl_race_cptimes_showspeed = false;
+bool autocvar_cl_race_cptimes_showspeed_unit = true;
 #else
 AUTOCVAR_SAVE(cl_race_checkpoint_splits_console, bool, 1, "Print checkpoint splits to console");
 AUTOCVAR_SAVE(cl_race_checkpoint_splits_hud, bool, 1, "Show race checkpoint splits on HUD in infomessages");
+AUTOCVAR_SAVE(cl_race_cptimes_showspeed, bool, 0, "Show race checkpoint speed (NOTE: ignores vertical speed)");
+AUTOCVAR_SAVE(cl_race_cptimes_showspeed_unit, bool, 1, "Show race checkpoint speed units");
 #endif
 bool autocvar_cl_race_cptimes_onlyself; // TODO: move to race gamemode
 bool autocvar_cl_race_cptimes_showself = false;
index 332c4b74198d0feb71bc050d75d4bf56561359cc..58c29f8b93c3b1c27a5ac0455d43e3e12512c03d 100644 (file)
@@ -714,6 +714,8 @@ seta cl_jetpack_jump 1 "Activate jetpack by pressing jump in the air. 0 = Disabl
 
 seta cl_race_cptimes_showself 1 "Always show your own times as well as the current best on checkpoints in Race/CTS"
 seta cl_race_cptimes_onlyself 0 "Only show your own times on checkpoints in Race/CTS. Can be forced on by the server via g_race_cptimes_onlyself"
+seta cl_race_cptimes_showspeed 0 "Show race checkpoint speed (NOTE: ignores vertical speed)"
+seta cl_race_cptimes_showspeed_unit 1 "Show race checkpoint speed units"
 seta cl_race_checkpoint_splits_console 1 "Print checkpoint splits to console"
 seta cl_race_checkpoint_splits_hud 1 "Show race checkpoint splits on HUD in infomessages"