]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qh
Merge branch 'terencehill/kh_fix' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qh
index f880a810f6eb2c6a7dc53b797f1b3f67ea1422e1..894066028f624dfe06b4c49dd2b7c259f3700a12 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef HUD_H
 #define HUD_H
 
-#include "../common/weapons/weapons.qh"
+#include "../common/weapons/all.qh"
 
 const int HUD_PANEL_MAX = 24;
 entity hud_panel[HUD_PANEL_MAX];
@@ -113,6 +113,11 @@ string panel_bg_padding_str;
 
 class(HUDPanel) .void() panel_draw;
 
+// chat panel can be reduced / moved while the mapvote is active
+// let know the mapvote panel about chat pos and size
+float chat_posy;
+float chat_sizey;
+
 float current_player;
 
 float GetPlayerColorForce(int i);
@@ -137,25 +142,26 @@ float old_p_healthtime, old_p_armortime;
 int prev_p_health, prev_p_armor;
 
 
-#define HUD_PANELS(HUD_PANEL)                                                                                                                                                                          \
-       HUD_PANEL(WEAPONS      , HUD_Weapons      , weapons)                                                                                                                    \
-       HUD_PANEL(AMMO         , HUD_Ammo         , ammo)                                                                                                                               \
-       HUD_PANEL(POWERUPS     , HUD_Powerups     , powerups)                                                                                                                   \
-       HUD_PANEL(HEALTHARMOR  , HUD_HealthArmor  , healtharmor)                                                                                                                \
-       HUD_PANEL(NOTIFY       , HUD_Notify       , notify)                                                                                                                     \
-       HUD_PANEL(TIMER        , HUD_Timer        , timer)                                                                                                                              \
-       HUD_PANEL(RADAR        , HUD_Radar        , radar)                                                                                                                              \
-       HUD_PANEL(SCORE        , HUD_Score        , score)                                                                                                                              \
-       HUD_PANEL(RACETIMER    , HUD_RaceTimer    , racetimer)                                                                                                                  \
-       HUD_PANEL(VOTE         , HUD_Vote         , vote)                                                                                                                               \
-       HUD_PANEL(MODICONS     , HUD_ModIcons     , modicons)                                                                                                                   \
-       HUD_PANEL(PRESSEDKEYS  , HUD_PressedKeys  , pressedkeys)                                                                                                                \
-       HUD_PANEL(CHAT         , HUD_Chat         , chat)                                                                                                                               \
-       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(BUFFS        , HUD_Buffs        , buffs)
+#define HUD_PANELS(HUD_PANEL) \
+       HUD_PANEL(WEAPONS      , HUD_Weapons      , weapons) \
+       HUD_PANEL(AMMO         , HUD_Ammo         , ammo) \
+       HUD_PANEL(POWERUPS     , HUD_Powerups     , powerups) \
+       HUD_PANEL(HEALTHARMOR  , HUD_HealthArmor  , healtharmor) \
+       HUD_PANEL(NOTIFY       , HUD_Notify       , notify) \
+       HUD_PANEL(TIMER        , HUD_Timer        , timer) \
+       HUD_PANEL(RADAR        , HUD_Radar        , radar) \
+       HUD_PANEL(SCORE        , HUD_Score        , score) \
+       HUD_PANEL(RACETIMER    , HUD_RaceTimer    , racetimer) \
+       HUD_PANEL(VOTE         , HUD_Vote         , vote) \
+       HUD_PANEL(MODICONS     , HUD_ModIcons     , modicons) \
+       HUD_PANEL(PRESSEDKEYS  , HUD_PressedKeys  , pressedkeys) \
+       HUD_PANEL(CHAT         , HUD_Chat         , chat) \
+       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(MAPVOTE      , MapVote_Draw     , mapvote) \
+       // always add new panels to the end of list
 
 #define HUD_PANEL(NAME, draw_func, name)                                                                                                                                                       \
        int HUD_PANEL_##NAME;                                                                                                                                                                                   \
@@ -227,9 +233,9 @@ HUD_PANELS(HUD_PANEL)
                        panel_bg_color = autocvar_hud_panel_bg_color;                                                           \
                } else {                                                                                                    \
                        if (panel_bg_color_str == "shirt") {                                                                    \
-                               panel_bg_color = colormapPaletteColor(floor(stof(getplayerkeyvalue(current_player - 1, "colors")) / 16), 0);\
+                               panel_bg_color = colormapPaletteColor(floor(stof(getplayerkeyvalue(current_player, "colors")) / 16), 0); \
                        } else if (panel_bg_color_str == "pants") {                                                             \
-                               panel_bg_color = colormapPaletteColor(stof(getplayerkeyvalue(current_player - 1, "colors")) % 16, 1);\
+                               panel_bg_color = colormapPaletteColor(stof(getplayerkeyvalue(current_player, "colors")) % 16, 1); \
                        } else {                                                                                                \
                                panel_bg_color = stov(panel_bg_color_str);                                                          \
                        }                                                                                                       \
@@ -292,27 +298,18 @@ HUD_PANELS(HUD_PANEL)
 } while(0)
 
 // return smoothly faded pos and size of given panel when a dialog is active
-#define HUD_Panel_UpdatePosSize_ForMenu() do {                                                                      \
-       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) {                                                                 \
-                       menu_enable_size.y = menu_enable_maxsize_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 {                                                                                                        \
-               if (panel_size.x > menu_enable_maxsize_x) {                                                                 \
-                       menu_enable_size.x = menu_enable_maxsize_x;                                                             \
-                       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;                  \
+// don't center too wide panels, it doesn't work with different resolutions
+#define HUD_Panel_UpdatePosSize_ForMenu() do { \
+       vector menu_enable_size = panel_size; \
+       float max_panel_width = 0.52 * vid_conwidth; \
+       if(panel_size.x > max_panel_width) \
+       { \
+               menu_enable_size.x = max_panel_width; \
+               menu_enable_size.y = panel_size.y * (menu_enable_size.x / panel_size.x); \
+       } \
+       vector menu_enable_pos = eX * (panel_bg_border + 0.5 * max_panel_width) + eY * 0.5 * vid_conheight - 0.5 * menu_enable_size; \
+       panel_pos = (1 - autocvar__menu_alpha) * panel_pos + (autocvar__menu_alpha) * menu_enable_pos; \
+       panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size; \
 } while(0)
 
 // Scale the pos and size vectors to absolute coordinates