From: Des - Date: Tue, 3 Dec 2024 10:11:34 +0000 (+0000) Subject: Add support for showing speed in splits to racetimer X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7800ff7c808a07d1ba4571444cbd3afe2c4f8c22;p=xonotic%2Fxonotic-data.pk3dir.git Add support for showing speed in splits to racetimer --- diff --git a/qcsrc/client/hud/panel/racetimer.qc b/qcsrc/client/hud/panel/racetimer.qc index 514a9c258..e26b72bc3 100644 --- a/qcsrc/client/hud/panel/racetimer.qc +++ b/qcsrc/client/hud/panel/racetimer.qc @@ -1,4 +1,5 @@ #include "racetimer.qh" +#include "physics.qh" #include #include @@ -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); diff --git a/qcsrc/client/hud/panel/racetimer.qh b/qcsrc/client/hud/panel/racetimer.qh index 054fe8287..b471209b6 100644 --- a/qcsrc/client/hud/panel/racetimer.qh +++ b/qcsrc/client/hud/panel/racetimer.qh @@ -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; diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 698c70b2d..66d10cdae 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -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; diff --git a/xonotic-client.cfg b/xonotic-client.cfg index 332c4b741..58c29f8b9 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -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"