From 1488fd2f33a238fbb030071d525467053772b2b0 Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 12 Jan 2011 19:56:00 +0100 Subject: [PATCH] New cvar hud_panel_physics_progressbar_acceleration_mode to also allow the old way to display acceleration, which is better readable --- _hud_descriptions.cfg | 1 + hud_luminos.cfg | 1 + hud_nexuiz.cfg | 1 + qcsrc/client/autocvars.qh | 1 + qcsrc/client/hud.qc | 35 +++++++++++++++++++++++++++++++++-- qcsrc/client/hud_config.qc | 1 + 6 files changed, 38 insertions(+), 2 deletions(-) diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index c72cd8536..16ae97565 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -231,3 +231,4 @@ seta hud_panel_physics_bg_padding "" "if set to something else than \"\" = overr seta hud_panel_physics_baralign "" "0 = align bars to the left, 1 = align bars to the right, 2 = align only left bar to the right, 3 = align only right bar to the right, 4 = align bars to the center" seta hud_panel_physics_flip "" "flip speed/acceleration positions" seta hud_panel_physics_progressbar "" "enable progressbar in panel" +seta hud_panel_physics_progressbar_acceleration_mode "" "0 = progressbar increases from the center to the right if the acceleration is positive, to the left if it's negative; 1 = progressbar increases from the border in the same direction for both positive and negative accelerations" diff --git a/hud_luminos.cfg b/hud_luminos.cfg index 1352b8046..7e94d8ce0 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -229,5 +229,6 @@ seta hud_panel_physics_bg_padding "" seta hud_panel_physics_flip "0" seta hud_panel_physics_baralign "0" seta hud_panel_physics_progressbar "1" +seta hud_panel_physics_progressbar_acceleration_mode "0" menu_sync diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index 32c25f496..9969a5e27 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -229,5 +229,6 @@ seta hud_panel_physics_bg_padding "" seta hud_panel_physics_flip "0" seta hud_panel_physics_baralign "0" seta hud_panel_physics_progressbar "1" +seta hud_panel_physics_progressbar_acceleration_mode "0" menu_sync diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 38140b017..4a5696369 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -189,6 +189,7 @@ float autocvar_hud_panel_notify_flip; float autocvar_hud_panel_notify_print; float autocvar_hud_panel_notify_time; float autocvar_hud_panel_physics; +float autocvar_hud_panel_physics_progressbar_acceleration_mode; float autocvar_hud_panel_physics_acceleration_max; float autocvar_hud_panel_physics_acceleration_z; float autocvar_hud_panel_physics_baralign; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 67cd5d49a..7fa4c8626 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -427,10 +427,17 @@ if(highlightedPanel == hud_configure_active_panel && autocvar__hud_configure)\ //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag) { - if(length_ratio <= 0 || !theAlpha) + if(!length_ratio || !theAlpha) return; if(length_ratio > 1) length_ratio = 1; + if (baralign == 3) + { + if(length_ratio < -1) + length_ratio = -1; + } + else if(length_ratio < 0) + return; vector square; vector width, height; @@ -444,6 +451,17 @@ void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, flo theOrigin_y += (1 - length_ratio) * theSize_y; else if (baralign == 2) // center align theOrigin_y += 0.5 * (1 - length_ratio) * theSize_y; + else if (baralign == 3) // center align, positive values down, negative up + { + theSize_y *= 0.5; + if (length_ratio > 0) + theOrigin_y += theSize_y; + else + { + theOrigin_y += (1 + length_ratio) * theSize_y; + length_ratio = -length_ratio; + } + } theSize_y *= length_ratio; vector bH; @@ -475,6 +493,17 @@ void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, flo theOrigin_x += (1 - length_ratio) * theSize_x; else if (baralign == 2) // center align theOrigin_x += 0.5 * (1 - length_ratio) * theSize_x; + else if (baralign == 3) // center align, positive values on the right, negative on the left + { + theSize_x *= 0.5; + if (length_ratio > 0) + theOrigin_x += theSize_x; + else + { + theOrigin_x += (1 + length_ratio) * theSize_x; + length_ratio = -length_ratio; + } + } theSize_x *= length_ratio; vector bW; @@ -4273,6 +4302,8 @@ void HUD_Physics(void) speed_baralign = (autocvar_hud_panel_physics_baralign == 2); acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3); } + if (autocvar_hud_panel_physics_progressbar_acceleration_mode == 0) + acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration //draw speed if(speed && autocvar_hud_panel_physics_progressbar) @@ -4372,7 +4403,7 @@ void HUD_Physics(void) HUD_Panel_GetProgressBarColor(acceleration_neg); else HUD_Panel_GetProgressBarColor(acceleration); - HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "progressbar", fabs(acceleration)/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "progressbar", acceleration/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } drawstring_aspect(panel_pos + acceleration_offset, ftos_decimals(acceleration, 3), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); } diff --git a/qcsrc/client/hud_config.qc b/qcsrc/client/hud_config.qc index dd82a9731..b0cc07d42 100644 --- a/qcsrc/client/hud_config.qc +++ b/qcsrc/client/hud_config.qc @@ -121,6 +121,7 @@ void HUD_Panel_ExportCfg(string cfgname) HUD_Write_PanelCvar_q("_flip"); HUD_Write_PanelCvar_q("_baralign"); HUD_Write_PanelCvar_q("_progressbar"); + HUD_Write_PanelCvar_q("_acceleration_mode"); break; } HUD_Write("\n"); -- 2.39.2