]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/hud.qc
Merge branch 'master' into terencehill/hud_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / hud.qc
index c87cb5a89cd853e3561826106d9b31fd2dd4ac2c..d200e2c6c522e67f05b009f301f9a03f5677d9db 100644 (file)
@@ -1,12 +1,12 @@
 #include "hud.qh"
 
+#include "panel/scoreboard.qh"
 #include "hud_config.qh"
 #include "../mapvoting.qh"
-#include "../scoreboard.qh"
 #include "../teamradar.qh"
 #include <common/t_items.qh>
 #include <common/deathtypes/all.qh>
-#include <common/items/all.qc>
+#include <common/items/_mod.qh>
 #include <common/mapinfo.qh>
 #include <common/vehicles/all.qh>
 #include <common/mutators/mutator/waypoints/all.qh>
@@ -335,8 +335,6 @@ void DrawNumIcon(vector myPos, vector mySize, float x, string icon, bool vertica
        DrawNumIcon_expanding(myPos, mySize, x, icon, vertical, icon_right_align, color, theAlpha, 0);
 }
 
-#include "all.inc"
-
 /*
 ==================
 Main HUD system
@@ -358,39 +356,60 @@ void HUD_Vehicle()
        }
 }
 
-bool HUD_Panel_CheckFlags(int showflags)
-{
-    TC(int, showflags);
-       if ( HUD_Minigame_Showpanels() )
-               return showflags & PANEL_SHOW_MINIGAME;
-       if(intermission == 2)
-               return showflags & PANEL_SHOW_MAPVOTE;
-       return showflags & PANEL_SHOW_MAINGAME;
-}
+bool HUD_Minigame_Showpanels();
 
 void HUD_Panel_Draw(entity panent)
 {
        panel = panent;
-       if(autocvar__hud_configure)
+       if (autocvar__hud_configure)
+       {
+               if (!(panel.panel_configflags & PANEL_CONFIG_MAIN))
+                       return;
+               panel_fade_alpha = 1;
+               Hud_Panel_GetPanelEnabled();
+               panel.panel_draw();
+               return;
+       }
+
+       bool draw_allowed = false;
+       if (HUD_Minigame_Showpanels())
+       {
+               if (panel.panel_showflags & PANEL_SHOW_MINIGAME)
+                       draw_allowed = true;
+       }
+       else if(intermission == 2)
        {
-               if(panel.panel_configflags & PANEL_CONFIG_MAIN)
-                       panel.panel_draw();
+               if(panel.panel_showflags & PANEL_SHOW_MAPVOTE)
+                       draw_allowed = true;
        }
-       else if(HUD_Panel_CheckFlags(panel.panel_showflags))
+       else if (panel.panel_showflags & PANEL_SHOW_MAINGAME)
+               draw_allowed = true;
+
+       if (draw_allowed)
+       {
+               if (panel.panel_showflags & PANEL_SHOW_WITH_SB)
+                       panel_fade_alpha = 1;
+               else
+               {
+                       panel_fade_alpha = 1 - scoreboard_fade_alpha;
+                       if(!panel_fade_alpha)
+                               return;
+               }
                panel.panel_draw();
+       }
 }
 
 void HUD_Reset()
 {
        // reset gametype specific icons
-       if(gametype == MAPINFO_TYPE_CTF)
-               HUD_Mod_CTF_Reset();
+       if(gametype.m_modicons_reset)
+               gametype.m_modicons_reset();
 }
 
-float autocvar_hud_dynamic_shake;
-float autocvar_hud_dynamic_shake_damage_max;
-float autocvar_hud_dynamic_shake_damage_min;
-float autocvar_hud_dynamic_shake_scale;
+float autocvar_hud_dynamic_shake = 1;
+float autocvar_hud_dynamic_shake_damage_max = 130;
+float autocvar_hud_dynamic_shake_damage_min = 10;
+float autocvar_hud_dynamic_shake_scale = 0.2;
 float hud_dynamic_shake_x[10] = {0,    1, -0.7,  0.5, -0.3,  0.2, -0.1,  0.1,  0.0, 0};
 float hud_dynamic_shake_y[10] = {0,  0.4,  0.8, -0.2, -0.6,  0.0,  0.3,  0.1, -0.1, 0};
 bool Hud_Shake_Update()
@@ -414,6 +433,7 @@ bool Hud_Shake_Update()
        return true;
 }
 
+entity CSQCModel_server2csqc(int i);
 void calc_followmodel_ofs(entity view);
 void Hud_Dynamic_Frame()
 {
@@ -446,12 +466,15 @@ void Hud_Dynamic_Frame()
 
        if(autocvar_hud_dynamic_shake > 0)
        {
+               static float old_health = 0;
+               float health = max(-1, STAT(HEALTH));
                if(hud_dynamic_shake_factor == -1) // don't allow the effect for this frame
+               {
                        hud_dynamic_shake_factor = 0;
+                       old_health = health;
+               }
                else
                {
-                       static float old_health = 0;
-                       float health = max(-1, STAT(HEALTH));
                        float new_hud_dynamic_shake_factor = 0;
                        if (old_health - health >= autocvar_hud_dynamic_shake_damage_min
                                && autocvar_hud_dynamic_shake_damage_max > autocvar_hud_dynamic_shake_damage_min
@@ -490,34 +513,18 @@ void Hud_Dynamic_Frame()
 void HUD_Main()
 {
        int i;
-       // global hud theAlpha fade
-       if(menu_enabled == 1)
+       if(hud_configure_menu_open == 1)
                hud_fade_alpha = 1;
        else
-               hud_fade_alpha = (1 - autocvar__menu_alpha);
-
-       if(scoreboard_fade_alpha)
-               hud_fade_alpha = (1 - scoreboard_fade_alpha);
+               hud_fade_alpha = 1 - autocvar__menu_alpha;
 
        HUD_Configure_Frame();
 
        Hud_Dynamic_Frame();
 
-       // panels that we want to be active together with the scoreboard
-       // they must fade only when the menu does
        if(scoreboard_fade_alpha == 1)
-       {
-               HUD_Panel_Draw(HUD_PANEL(CENTERPRINT));
-               return;
-       }
-
-       if(!autocvar__hud_configure && !hud_fade_alpha)
-       {
-               hud_fade_alpha = 1;
-               HUD_Panel_Draw(HUD_PANEL(VOTE));
-               hud_fade_alpha = 0;
-               return;
-       }
+               if(autocvar__menu_alpha == 1)
+                       return;
 
        // Drawing stuff
        if (hud_skin_prev != autocvar_hud_skin)
@@ -549,11 +556,11 @@ void HUD_Main()
                {
                        string hud_dock_color = autocvar_hud_dock_color;
                        if(hud_dock_color == "shirt") {
-                               f = stof(getplayerkeyvalue(current_player, "colors"));
+                               f = entcs_GetClientColors(current_player);
                                color = colormapPaletteColor(floor(f / 16), 0);
                        }
                        else if(hud_dock_color == "pants") {
-                               f = stof(getplayerkeyvalue(current_player, "colors"));
+                               f = entcs_GetClientColors(current_player);
                                color = colormapPaletteColor(f % 16, 1);
                        }
                        else
@@ -599,7 +606,7 @@ void HUD_Main()
                        }
                }
                if (warning)
-                       LOG_TRACE("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
+                       LOG_TRACE("Automatically fixed wrong/missing panel numbers in _hud_panelorder");
 
                cvar_set("_hud_panelorder", s);
                if(hud_panelorder_prev)
@@ -628,8 +635,9 @@ void HUD_Main()
                HUD_Panel_Draw(HUD_PANEL(CHAT));
        if(hud_panel_quickmenu)
                HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
+       HUD_Panel_Draw(HUD_PANEL(SCOREBOARD));
 
-       if (scoreboard_active || intermission == 2)
+       if (intermission == 2)
                HUD_Reset();
 
        HUD_Configure_PostDraw();