#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];
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);
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; \
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); \
} \
} 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