From 6922c215091775cf0f875ea5ccc047b706f92f6c Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 16 Nov 2021 17:51:20 +0100 Subject: [PATCH] Show full fuel bar with a low alpha, fade it in until fuel reaches the middle of the bar (like the oxygen bar) --- _hud_common.cfg | 1 + qcsrc/client/hud/panel/healtharmor.qc | 14 ++++++++++++-- qcsrc/client/hud/panel/healtharmor.qh | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index 2d5aa2cfa..c5d37c1dc 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -84,6 +84,7 @@ seta hud_panel_ammo_hide_ondeath 0 "hide this panel when dead" seta hud_panel_powerups_hide_ondeath 0 "hide this panel when dead" +seta hud_panel_healtharmor_fuelbar_startalpha "0.3" "start alpha of the fuel bar" seta hud_panel_healtharmor_oxygenbar_startalpha "0.2" "start alpha of the oxygen bar" seta hud_panel_healtharmor_maxhealth "200" "when you have this much health, the health status bar is full" seta hud_panel_healtharmor_maxarmor "200" "when you have this much armor, the armor status bar is full" diff --git a/qcsrc/client/hud/panel/healtharmor.qc b/qcsrc/client/hud/panel/healtharmor.qc index bc5b68b0a..f84a37330 100644 --- a/qcsrc/client/hud/panel/healtharmor.qc +++ b/qcsrc/client/hud/panel/healtharmor.qc @@ -110,6 +110,16 @@ void HUD_HealthArmor() air_alpha = bound(0, start_alpha + (1 - start_alpha) * (1 - f), 1); } + float fuel_alpha; + if (!fuel) + fuel_alpha = 0; + else + { + float start_alpha = autocvar_hud_panel_healtharmor_fuelbar_startalpha; + float f = (100 - fuel) / 50; + fuel_alpha = bound(0, start_alpha + (1 - start_alpha) * f, 1); + } + int baralign = autocvar_hud_panel_healtharmor_baralign; int iconalign = autocvar_hud_panel_healtharmor_iconalign; @@ -142,7 +152,7 @@ void HUD_HealthArmor() DrawNumIcon(pos, mySize, hp, biggercount, false, false, iconalign, HUD_Get_Num_Color(hp, maxtotal, true), 1); if(fuel) - HUD_Panel_DrawProgressBar(pos, vec2(mySize.x, 0.2 * mySize.y), "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(pos, vec2(mySize.x, 0.2 * mySize.y), "progressbar", fuel / 100, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_fuel_color, fuel_alpha * panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); if(air_time) HUD_Panel_DrawProgressBar(pos + eY * 0.8 * mySize.y, vec2(mySize.x, 0.2 * mySize.y), "progressbar", air_time / 10, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_oxygen_color, air_alpha * panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); } @@ -298,7 +308,7 @@ void HUD_HealthArmor() else if (panel_ar < 1/4) mySize.y *= 2; //restore full panel size if (fuel) - HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel / 100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, fuel_alpha * panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); if (air_time) { if (panel_ar > 1 && panel_ar < 4) diff --git a/qcsrc/client/hud/panel/healtharmor.qh b/qcsrc/client/hud/panel/healtharmor.qh index 538d18780..47a101738 100644 --- a/qcsrc/client/hud/panel/healtharmor.qh +++ b/qcsrc/client/hud/panel/healtharmor.qh @@ -10,6 +10,7 @@ bool autocvar_hud_panel_healtharmor_hide_ondeath = false; int autocvar_hud_panel_healtharmor_iconalign; int autocvar_hud_panel_healtharmor_maxarmor; int autocvar_hud_panel_healtharmor_maxhealth; +float autocvar_hud_panel_healtharmor_fuelbar_startalpha = 0.3; float autocvar_hud_panel_healtharmor_oxygenbar_startalpha = 0.2; bool autocvar_hud_panel_healtharmor_progressbar; string autocvar_hud_panel_healtharmor_progressbar_armor; -- 2.39.2