]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qh
Merge branch 'master' into Mario/buffs
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qh
index 857f4173d16a3fd6d3f7266aa9cb071a6e1c1fea..55d4bd0db8c9fdd71265993fea3dd372549c83c9 100644 (file)
@@ -9,6 +9,8 @@ string hud_panelorder_prev;
 
 float hud_draw_maximized;
 float hud_panel_radar_maximized;
+float chat_panel_modified;
+float radar_panel_modified;
 
 vector mousepos;
 vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
@@ -77,7 +79,6 @@ entity panel;
 var float panel_enabled;
 var vector panel_pos;
 var vector panel_size;
-var string panel_bg;
 var string panel_bg_str; // "_str" vars contain the raw value of the cvar, non-"_str" contains what hud.qc code should use
 var vector panel_bg_color;
 var string panel_bg_color_str;
@@ -113,11 +114,12 @@ float current_player;
        HUD_PANEL(ENGINEINFO   , HUD_EngineInfo   , engineinfo) \
        HUD_PANEL(INFOMESSAGES , HUD_InfoMessages , infomessages) \
        HUD_PANEL(PHYSICS      , HUD_Physics      , physics) \
-       HUD_PANEL(CENTERPRINT  , HUD_CenterPrint  , centerprint)
+       HUD_PANEL(CENTERPRINT  , HUD_CenterPrint  , centerprint) \
+       HUD_PANEL(BUFFS        , HUD_Buffs        , buffs) 
 
 #define HUD_PANEL(NAME,draw_func,name) \
        float HUD_PANEL_##NAME; \
-       void ##draw_func(void); \
+       void draw_func(void); \
        void RegisterHUD_Panel_##NAME() \
        { \
                HUD_PANEL_LAST = HUD_PANEL_##NAME = HUD_PANEL_NUM; \
@@ -126,10 +128,10 @@ float current_player;
                hud_panelent.classname = "hud_panel"; \
                hud_panelent.panel_name = #name; \
                hud_panelent.panel_id = HUD_PANEL_##NAME; \
-               hud_panelent.panel_draw = ##draw_func; \
+               hud_panelent.panel_draw = draw_func; \
                ++HUD_PANEL_NUM; \
        } \
-       ACCUMULATE_FUNCTION(RegisterHUD_Panels, RegisterHUD_Panel_##NAME)
+       ACCUMULATE_FUNCTION(RegisterHUD_Panels, RegisterHUD_Panel_##NAME);
 
 HUD_PANELS
 #undef HUD_PANEL
@@ -143,9 +145,10 @@ HUD_PANELS
 // ----------------------
 // Little help for the poor people who have to make sense of this: Start from the bottom ;)
 
-// Get value for panel_bg: if "" fetch default, else use panel_bg_str
+// Get value for panel.current_panel_bg: if "" fetch default, else use panel_bg_str
 // comment on last line of macro: // we probably want to see a background in config mode at all times...
 #define HUD_Panel_GetBg()\
+string panel_bg;\
 if(!autocvar__hud_configure && panel_bg_str == "0") {\
        panel_bg = "0";\
 } else {\
@@ -165,7 +168,10 @@ if(!autocvar__hud_configure && panel_bg_str == "0") {\
                        }\
                }\
        }\
-}
+}\
+if(panel.current_panel_bg)\
+       strunzone(panel.current_panel_bg);\
+panel.current_panel_bg = strzone(panel_bg);
 
 // Get value for panel_bg_color: if "" fetch default, else use panel_bg_color. Convert pants, shirt or teamcolor into a vector.
 #define HUD_Panel_GetColor()\
@@ -198,14 +204,6 @@ if(panel_bg_color_team_str == "") {\
        panel_bg_color_team = stof(panel_bg_color_team_str);\
 }
 
-// the check doesn't allow to fade this panel when showing the panel-specific menu dialog
-#define HUD_Panel_ApplyFadeAlpha()\
-if(!(menu_enabled == 2 && panel == highlightedPanel))\
-{\
-       panel_bg_alpha *= hud_fade_alpha;\
-       panel_fg_alpha *= hud_fade_alpha;\
-} ENDS_WITH_CURLY_BRACE
-
 // Get value for panel_bg_alpha: if "" fetch default, else use panel_bg_alpha. Also do various menu dialog fadeout/in checks, and minalpha checks
 // comment on line 3 of macro: // do not set a minalpha cap when showing the config dialog for this panel
 #define HUD_Panel_GetBgAlpha()\
@@ -247,23 +245,12 @@ if(panel_bg_padding_str == "") {\
 }\
 panel_bg_padding = min(min(panel_size_x, panel_size_y)/2 - 5, panel_bg_padding);
 
-// return smoothly faded pos of given panel when a dialog is active
-var vector menu_enable_panelpos;
-#define HUD_Panel_GetMenuPos() \
-if(panel_size_x > panel_size_y)\
-       menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * panel_size_x + eY * 0.82 * vid_conheight;\
-else\
-       menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * panel_size_y + eX * 0.7 * vid_conwidth;\
-panel_pos = (1 - autocvar__menu_alpha) * panel_pos + (autocvar__menu_alpha) * menu_enable_panelpos;
-
-// return smoothly faded size of given panel when a dialog is active
-//var vector menu_enable_maxsize;
-var float menu_enable_maxsize_x;
-var float menu_enable_maxsize_y;
-var vector menu_enable_size;
-#define HUD_Panel_GetMenuSize()\
-menu_enable_maxsize_x = 0.3 * vid_conwidth;\
-menu_enable_maxsize_y = 0.18 * vid_conheight;\
+// return smoothly faded pos and size of given panel when a dialog is active
+#define HUD_Panel_UpdatePosSize_ForMenu()\
+vector menu_enable_pos;\
+vector menu_enable_size = '0 0 0';\
+float menu_enable_maxsize_x = 0.3 * vid_conwidth;\
+float menu_enable_maxsize_y = 0.18 * vid_conheight;\
 if(panel_size_x > panel_size_y)\
 {\
        if(panel_size_y > menu_enable_maxsize_y)\
@@ -272,6 +259,7 @@ if(panel_size_x > panel_size_y)\
                menu_enable_size_x = panel_size_x * (menu_enable_maxsize_y/panel_size_y);\
                panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size;\
        }\
+       menu_enable_pos = eX * 0.5 * vid_conwidth - eX * 0.5 * panel_size_x + eY * (vid_conheight - menu_enable_maxsize_y);\
 }\
 else\
 {\
@@ -281,7 +269,9 @@ else\
                menu_enable_size_y = panel_size_y * (menu_enable_maxsize_x/panel_size_x);\
                panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size;\
        }\
-}
+       menu_enable_pos = eY * 0.5 * vid_conheight - eY * 0.5 * panel_size_y + eX * (vid_conwidth - menu_enable_maxsize_x);\
+}\
+panel_pos = (1 - autocvar__menu_alpha) * panel_pos + (autocvar__menu_alpha) * menu_enable_pos;
 
 // Scale the pos and size vectors to absolute coordinates
 #define HUD_Panel_ScalePosSize()\
@@ -302,7 +292,7 @@ if(panel.update_time <= time) { \
        panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border")); \
        panel_bg_padding_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_padding")); \
        HUD_Panel_GetBg()\
-       if (panel_bg != "0") {\
+       if (panel.current_panel_bg != "0") {\
                HUD_Panel_GetColorTeam()\
                HUD_Panel_GetColor()\
                HUD_Panel_GetBgAlpha()\
@@ -310,32 +300,30 @@ if(panel.update_time <= time) { \
        }\
        HUD_Panel_GetFgAlpha()\
        HUD_Panel_GetPadding()\
+       panel.current_panel_bg_alpha = panel_bg_alpha; \
+       panel.current_panel_fg_alpha = panel_fg_alpha; \
        if(menu_enabled == 2 && panel == highlightedPanel) {\
-               HUD_Panel_GetMenuSize()\
-               HUD_Panel_GetMenuPos()\
-       } \
+               HUD_Panel_UpdatePosSize_ForMenu()\
+       } else {\
+               panel_bg_alpha *= hud_fade_alpha;\
+               panel_fg_alpha *= hud_fade_alpha;\
+       }\
        panel.current_panel_pos = panel_pos; \
        panel.current_panel_size = panel_size; \
-       if(panel.current_panel_bg != "") \
-               strunzone(panel.current_panel_bg); \
-       panel.current_panel_bg = strzone(panel_bg); \
-       panel.current_panel_bg_alpha = panel_bg_alpha; \
        panel.current_panel_bg_border = panel_bg_border; \
        panel.current_panel_bg_color = panel_bg_color; \
        panel.current_panel_bg_color_team = panel_bg_color_team; \
        panel.current_panel_bg_padding = panel_bg_padding; \
-       panel.current_panel_fg_alpha = panel_fg_alpha; \
        panel.update_time = (autocvar__hud_configure) ? time : time + autocvar_hud_panel_update_interval; \
 } else { \
        panel_pos = panel.current_panel_pos; \
        panel_size = panel.current_panel_size; \
-       panel_bg = panel.current_panel_bg; \
-       panel_bg_alpha = panel.current_panel_bg_alpha; \
+       panel_bg_alpha = panel.current_panel_bg_alpha * hud_fade_alpha; \
        panel_bg_border = panel.current_panel_bg_border; \
        panel_bg_color = panel.current_panel_bg_color; \
        panel_bg_color_team = panel.current_panel_bg_color_team; \
        panel_bg_padding = panel.current_panel_bg_padding; \
-       panel_fg_alpha = panel.current_panel_fg_alpha; \
+       panel_fg_alpha = panel.current_panel_fg_alpha * hud_fade_alpha; \
 } ENDS_WITH_CURLY_BRACE
 
 #define HUD_Panel_UpdatePosSize() {\
@@ -344,19 +332,23 @@ panel_pos = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_pos"))); \
 panel_size = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_size"))); \
 HUD_Panel_ScalePosSize()\
 if(menu_enabled == 2 && panel == highlightedPanel) {\
-       HUD_Panel_GetMenuSize()\
-       HUD_Panel_GetMenuPos()\
+       HUD_Panel_UpdatePosSize_ForMenu()\
 }\
 panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border")); \
 HUD_Panel_GetBorder() \
 } ENDS_WITH_CURLY_BRACE
 
+#define NOTIFY_MAX_ENTRIES 10
+#define NOTIFY_ICON_MARGIN 0.02
 
-#define KN_MAX_ENTRIES 10
+float notify_index;
+float notify_count;
+float notify_times[NOTIFY_MAX_ENTRIES];
+string notify_attackers[NOTIFY_MAX_ENTRIES];
+string notify_victims[NOTIFY_MAX_ENTRIES];
+string notify_icons[NOTIFY_MAX_ENTRIES];
 
-float kn_index;
-float notify_times[KN_MAX_ENTRIES];
-string notify_icon[KN_MAX_ENTRIES];
-string notify_attackers[KN_MAX_ENTRIES];
-string notify_victims[KN_MAX_ENTRIES];
 void HUD_Notify_Push(string icon, string attacker, string victim);
+
+var void HUD_ModIcons_GameType(vector pos, vector size);
+void HUD_ModIcons_SetFunc();