From 3678fa9a1af46f1a8bf7dbf787e94bbfabaf9d0a Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 1 Oct 2011 13:26:06 +0200 Subject: [PATCH] Physics panel updates: acceleration progressbar can now be scaled to display better acceleration values (hud_panel_physics_acceleration_progressbar_nonlinear does it without going out of the panel bounds, thing that happens by setting hud_panel_physics_acceleration_progressbar_scale to a value > 1); also text height can now be scaled thanks to hud_panel_physics_text_scale. --- defaultXonotic.cfg | 3 +++ qcsrc/client/autocvars.qh | 3 +++ qcsrc/client/hud.qc | 52 ++++++++++++++++++++++++++++++++++----- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index a0d50e3e7a..88bdda0432 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1486,6 +1486,9 @@ seta hud_panel_physics_topspeed 1 "also show top speed" seta hud_panel_physics_topspeed_time 4 "how many seconds the top speed takes to fade out" seta hud_panel_physics_acceleration_max 1.5 "acceleration progressbar gets completely filled up by this value (in g)" seta hud_panel_physics_acceleration_vertical 0 "include the acceleration on the Z-axis" +seta hud_panel_physics_acceleration_progressbar_scale 0 "multiply acceleration progressbar values by this factor (allow progressbar to go out of panel bounds)"; +seta hud_panel_physics_acceleration_progressbar_nonlinear 1 "use a non linear function to display acceleration progressbar values (amplify more smaller values)"; +seta hud_panel_physics_text_scale 0.7 "scale text height by this factor"; seta hud_showbinds 1 "what to show in the HUD to indicate certain keys to press: 0 display commands, 1 bound keys, 2 both" seta hud_showbinds_limit 2 "maximum number of bound keys to show for a command. 0 for unlimited" diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 7451ee7c30..87d1809fc7 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -249,6 +249,8 @@ float autocvar_hud_panel_notify_print; float autocvar_hud_panel_notify_time; float autocvar_hud_panel_physics; float autocvar_hud_panel_physics_acceleration_progressbar_mode; +float autocvar_hud_panel_physics_acceleration_progressbar_scale; +float autocvar_hud_panel_physics_acceleration_progressbar_nonlinear; float autocvar_hud_panel_physics_acceleration_max; float autocvar_hud_panel_physics_progressbar; float autocvar_hud_panel_physics_acceleration_vertical; @@ -259,6 +261,7 @@ float autocvar_hud_panel_physics_speed_unit; float autocvar_hud_panel_physics_speed_unit_show; float autocvar_hud_panel_physics_speed_vertical; float autocvar_hud_panel_physics_text; +float autocvar_hud_panel_physics_text_scale; float autocvar_hud_panel_physics_topspeed; float autocvar_hud_panel_physics_topspeed_time; float autocvar_hud_panel_powerups; diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 043b5ea98a..32883b8dc4 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4186,6 +4186,16 @@ void HUD_Physics(void) panel_size -= '2 2 0' * panel_bg_padding; } + float acceleration_progressbar_scale; + if(autocvar_hud_panel_physics_progressbar && autocvar_hud_panel_physics_acceleration_progressbar_scale > 1) + acceleration_progressbar_scale = autocvar_hud_panel_physics_acceleration_progressbar_scale; + + float text_scale; + if (autocvar_hud_panel_physics_text_scale <= 0) + text_scale = 1; + else + text_scale = min(autocvar_hud_panel_physics_text_scale, 1); + //compute speed float speed, conversion_factor; string unit; @@ -4245,7 +4255,7 @@ void HUD_Physics(void) //compute layout float panel_ar = panel_size_x/panel_size_y; vector speed_offset, acceleration_offset; - if (panel_ar >= 5) + if (panel_ar >= 5 && !acceleration_progressbar_scale) { panel_size_x *= 0.5; if (autocvar_hud_panel_physics_flip) @@ -4290,11 +4300,12 @@ void HUD_Physics(void) if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2) { tmp_size_x = panel_size_x * 0.75; - tmp_size_y = panel_size_y; + tmp_size_y = panel_size_y * text_scale; if (speed_baralign) tmp_offset_x = panel_size_x - tmp_size_x; //else //tmp_offset_x = 0; + tmp_offset_y = (panel_size_y - tmp_size_y) / 2; drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); //draw speed unit @@ -4306,7 +4317,8 @@ void HUD_Physics(void) { //tmp_offset_y = 0; tmp_size_x = panel_size_x * (1 - 0.75); - tmp_size_y = panel_size_y * 0.4; + tmp_size_y = panel_size_y * 0.4 * text_scale; + tmp_offset_y = (panel_size_y * 0.4 - tmp_size_y) / 2; drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); } } @@ -4367,7 +4379,8 @@ void HUD_Physics(void) //top speed tmp_offset_y = panel_size_y * 0.4; tmp_size_x = panel_size_x * (1 - 0.75); - tmp_size_y = panel_size_y - tmp_offset_y; + tmp_size_y = (panel_size_y - tmp_offset_y) * text_scale; + tmp_offset_y += (panel_size_y - tmp_offset_y - tmp_size_y) / 2; drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL); } else @@ -4382,10 +4395,37 @@ void HUD_Physics(void) HUD_Panel_GetProgressBarColor(acceleration_neg); else HUD_Panel_GetProgressBarColor(acceleration); - HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "accelbar", acceleration/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + + f = acceleration/autocvar_hud_panel_physics_acceleration_max; + if (autocvar_hud_panel_physics_acceleration_progressbar_nonlinear) + f = sqrt(f); + + if (acceleration_progressbar_scale) // allow progressbar to go out of panel bounds + { + tmp_size = acceleration_progressbar_scale * panel_size_x * eX + panel_size_y * eY; + + if (acceleration_baralign == 1) + tmp_offset_x = panel_size_x - tmp_size_x; + else if (acceleration_baralign == 2 || acceleration_baralign == 3) + tmp_offset_x = (panel_size_x - tmp_size_x) / 2; + else + tmp_offset_x = 0; + tmp_offset_y = 0; + } + else + { + tmp_size = panel_size; + tmp_offset = '0 0 0'; + } + + HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset + tmp_offset, tmp_size, "accelbar", f, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } + tmp_size_x = panel_size_x; + tmp_size_y = panel_size_y * text_scale; + tmp_offset_x = 0; + tmp_offset_y = (panel_size_y - tmp_size_y) / 2; if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3) - drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(acceleration, 2), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); } // CenterPrint (#16) -- 2.39.2