]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/healtharmor.qc
Experimental status effects system: general backend for buffs and debuffs networked...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / healtharmor.qc
index 36e3a8d907656a3ef28489cc324c9e303b70ec7e..bc5b68b0a94c53bf9b0c782482c3eaa3586e6d4f 100644 (file)
@@ -1,12 +1,25 @@
 #include "healtharmor.qh"
 
-#include <client/defs.qh>
-#include <client/miscfunctions.qh>
-
+#include <client/draw.qh>
 #include <common/deathtypes/all.qh>
 
 // Health/armor (#3)
 
+void HUD_HealthArmor_Export(int fh)
+{
+       // allow saving cvars that aesthetically change the panel into hud skin files
+       HUD_Write_Cvar("hud_panel_healtharmor_combined");
+       HUD_Write_Cvar("hud_panel_healtharmor_flip");
+       HUD_Write_Cvar("hud_panel_healtharmor_iconalign");
+       HUD_Write_Cvar("hud_panel_healtharmor_baralign");
+       HUD_Write_Cvar("hud_panel_healtharmor_progressbar");
+       HUD_Write_Cvar("hud_panel_healtharmor_progressbar_health");
+       HUD_Write_Cvar("hud_panel_healtharmor_progressbar_armor");
+       HUD_Write_Cvar("hud_panel_healtharmor_progressbar_gfx");
+       HUD_Write_Cvar("hud_panel_healtharmor_progressbar_gfx_smooth");
+       HUD_Write_Cvar("hud_panel_healtharmor_text");
+}
+
 void HUD_HealthArmor()
 {
        int armor, health, fuel, air_time;
@@ -81,6 +94,22 @@ void HUD_HealthArmor()
                mySize -= '2 2 0' * panel_bg_padding;
        }
 
+       float air_alpha;
+       if (!STAT(AIR_FINISHED))
+               air_alpha = 0;
+       else if (time > STAT(AIR_FINISHED))
+       {
+               air_alpha = blink_synced(0.5, 0.5, 7, STAT(AIR_FINISHED), -1);
+               air_time = 10;
+       }
+       else
+       {
+               float fade_time = 10 / 2;
+               float start_alpha = autocvar_hud_panel_healtharmor_oxygenbar_startalpha;
+               float f = (STAT(AIR_FINISHED) - time - fade_time) / fade_time;
+               air_alpha = bound(0, start_alpha + (1 - start_alpha) * (1 - f), 1);
+       }
+
        int baralign = autocvar_hud_panel_healtharmor_baralign;
        int iconalign = autocvar_hud_panel_healtharmor_iconalign;
 
@@ -110,12 +139,12 @@ void HUD_HealthArmor()
                                drawpic_aspect_skin(pos + eX * mySize.x - eX * 0.5 * mySize.y, "health", '0.5 0.5 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                }
                if(autocvar_hud_panel_healtharmor_text)
-                       DrawNumIcon(pos, mySize, hp, biggercount, 0, iconalign, HUD_Get_Num_Color(hp, maxtotal), 1);
+                       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);
                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, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
+                       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);
        }
        else
        {
@@ -201,16 +230,13 @@ void HUD_HealthArmor()
 
                                        if (health <= autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth)
                                        {
-                                               float BLINK_FACTOR = 0.15;
-                                               float BLINK_BASE = 0.85;
-                                               float BLINK_FREQ = 9;
-                                               pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
+                                               pain_health_alpha = blink(0.85, 0.15, 9);
                                        }
                                }
                                HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * pain_health_alpha, DRAWFLAG_NORMAL);
                        }
                        if(autocvar_hud_panel_healtharmor_text)
-                               DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1);
+                               DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, false, health_iconalign, HUD_Get_Num_Color(health, maxhealth, true), 1);
                }
 
                //if(armor)
@@ -257,7 +283,7 @@ void HUD_HealthArmor()
                        }
                        if(!autocvar_hud_panel_healtharmor_progressbar || p_armor)
                        if(autocvar_hud_panel_healtharmor_text)
-                               DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1);
+                               DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, false, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor, true), 1);
                }
 
                vector cell_size = mySize;
@@ -283,7 +309,7 @@ void HUD_HealthArmor()
                                        pos.x += cell_size.x - mySize.x;
                                else
                                        pos.y += cell_size.y - mySize.y;
-                               HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", air_time / 10, is_vertical, air_align, autocvar_hud_progressbar_oxygen_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
+                               HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", air_time / 10, is_vertical, air_align, autocvar_hud_progressbar_oxygen_color, air_alpha * panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
                        }
                }
        }