From: terencehill Date: Tue, 16 Nov 2021 16:51:20 +0000 (+0100) Subject: Show full fuel bar with a low alpha, fade it in until fuel reaches the middle of... X-Git-Tag: xonotic-v0.8.5~297 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6922c215091775cf0f875ea5ccc047b706f92f6c;p=xonotic%2Fxonotic-data.pk3dir.git Show full fuel bar with a low alpha, fade it in until fuel reaches the middle of the bar (like the oxygen bar) --- 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;