From: otta8634 Date: Wed, 25 Sep 2024 07:21:42 +0000 (+0800) Subject: Add a cvar to force layout type in physics hud X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=86168e4923937d67524dc3224106dcdebd1e5acd;p=xonotic%2Fxonotic-data.pk3dir.git Add a cvar to force layout type in physics hud Previously it was aligned vertical or horizontally automatically, unless _acceleration_progressbar_scale was >1 Added a new cvar (hud_panel_physics_force_layout) to force layout type --- diff --git a/_hud_common.cfg b/_hud_common.cfg index 302c107d1..1e1264a61 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -113,6 +113,7 @@ seta hud_panel_physics_acceleration_max_slick "-1" "acceleration progressbar get seta hud_panel_physics_update_interval "0.016" "how often (in seconds) numeric values get updated on screen" seta hud_panel_physics_jumpspeed "0" "also show jump speed, replacing the speed unit text (NOTE: ignores vertical speed)" seta hud_panel_physics_jumpspeed_time "1" "how many seconds the jump speed takes to fade out" +seta hud_panel_physics_force_layout "0" "1 = force speed and acceleration to be side-by-side, 2 = force them to be above one another" 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" diff --git a/qcsrc/client/hud/panel/physics.qc b/qcsrc/client/hud/panel/physics.qc index ed6dd242f..4fbdb95cb 100644 --- a/qcsrc/client/hud/panel/physics.qc +++ b/qcsrc/client/hud/panel/physics.qc @@ -26,6 +26,7 @@ void HUD_Physics_Export(int fh) HUD_Write_Cvar("hud_panel_physics_acceleration_progressbar_nonlinear"); HUD_Write_Cvar("hud_panel_physics_text"); HUD_Write_Cvar("hud_panel_physics_text_scale"); + HUD_Write_Cvar("hud_panel_physics_force_layout"); } vector acc_prev_vel; @@ -129,7 +130,8 @@ void HUD_Physics() // compute layout float panel_ar = panel_size.x / panel_size.y; vector speed_offset = '0 0 0', acceleration_offset = '0 0 0'; - if (panel_ar >= 5 && !acceleration_progressbar_scale) // speed and accel are drawn side-by-side + if (autocvar_hud_panel_physics_force_layout == PHYSICS_LAYOUT_HORIZONTAL + || (autocvar_hud_panel_physics_force_layout != PHYSICS_LAYOUT_VERTICAL && panel_ar >= 5 && !acceleration_progressbar_scale)) { panel_size.x *= 0.5; if (autocvar_hud_panel_physics_flip) @@ -137,7 +139,7 @@ void HUD_Physics() else acceleration_offset.x = panel_size.x; } - else + else // speed and accel are drawn on top of one another (vvv), rather than side by side (^^^) { panel_size.y *= 0.5; if (autocvar_hud_panel_physics_flip) diff --git a/qcsrc/client/hud/panel/physics.qh b/qcsrc/client/hud/panel/physics.qh index e27f5f3ac..6f647e1e1 100644 --- a/qcsrc/client/hud/panel/physics.qh +++ b/qcsrc/client/hud/panel/physics.qh @@ -24,6 +24,7 @@ bool autocvar_hud_panel_physics_topspeed; float autocvar_hud_panel_physics_topspeed_time; bool autocvar_hud_panel_physics_jumpspeed = false; float autocvar_hud_panel_physics_jumpspeed_time = 1; +int autocvar_hud_panel_physics_force_layout = 0; vector autocvar_hud_progressbar_acceleration_color; vector autocvar_hud_progressbar_acceleration_neg_color; @@ -45,6 +46,10 @@ const int PHYSICS_TEXT_BOTH = 1; const int PHYSICS_TEXT_SPEED = 2; const int PHYSICS_TEXT_ACCEL = 3; +const int PHYSICS_LAYOUT_AUTOMATIC = 0; +const int PHYSICS_LAYOUT_HORIZONTAL = 1; +const int PHYSICS_LAYOUT_VERTICAL = 2; + // 1 m/s^2 = 0.0254 qu/s^2; 1 g = 9.80665 m/s^2 const float ACCEL2GRAV = 0.00259007918096393775; // converts qu/s^2 acceleration to m/s^2, relative to real-world gravity // equivalent to 0.0254 / 9.80665