CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
-
+ CALL_ACCUMULATED_FUNCTION(RegisterHUD_Panels);
+
WaypointSprite_Load();
// precaches
return;
}
}
- else
- hud_configure_active_panel = HUD_PANEL_WEAPONS;
// update generic hud functions
- HUD_Panel_UpdateCvars(weapons);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
draw_beginBoldFont();
if(!autocvar_hud_panel_ammo) return;
if(spectatee_status == -1) return;
}
- else
- hud_configure_active_panel = HUD_PANEL_AMMO;
- HUD_Panel_UpdateCvars(ammo);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
draw_beginBoldFont();
}
else
{
- hud_configure_active_panel = HUD_PANEL_POWERUPS;
-
strength_time = 15;
shield_time = 27;
superweapons_time = 13;
}
- HUD_Panel_UpdateCvars(powerups);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
draw_beginBoldFont();
}
else
{
- hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
-
health = 150;
armor = 75;
fuel = 20;
}
- HUD_Panel_UpdateCvars(healtharmor);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
vector pos, mySize;
pos = panel_pos;
{
if(!autocvar_hud_panel_notify) return;
}
- else
- hud_configure_active_panel = HUD_PANEL_NOTIFY;
- HUD_Panel_UpdateCvars(notify);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
vector pos, mySize;
pos = panel_pos;
{
if(!autocvar_hud_panel_timer) return;
}
- else
- hud_configure_active_panel = HUD_PANEL_TIMER;
- HUD_Panel_UpdateCvars(timer);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
draw_beginBoldFont();
if (autocvar_hud_panel_radar != 2 && !teamplay) return;
}
}
- else
- hud_configure_active_panel = HUD_PANEL_RADAR;
- HUD_Panel_UpdateCvars(radar);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
-
+
float f = 0;
if (hud_panel_radar_maximized && !autocvar__hud_configure)
if(!autocvar_hud_panel_score) return;
if(spectatee_status == -1 && (gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
}
- else
- hud_configure_active_panel = HUD_PANEL_SCORE;
- HUD_Panel_UpdateCvars(score);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
vector pos, mySize;
pos = panel_pos;
if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
if(spectatee_status == -1) return;
}
- else
- hud_configure_active_panel = HUD_PANEL_RACETIMER;
- HUD_Panel_UpdateCvars(racetimer);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
draw_beginBoldFont();
float vote_alpha;
float vote_change; // "time" when vote_active changed
-void HUD_VoteWindow(void)
+void HUD_Vote(void)
{
if(autocvar_cl_allow_uid2name == -1 && (gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE || (serverflags & SERVERFLAG_PLAYERSTATS)))
{
}
else
{
- hud_configure_active_panel = HUD_PANEL_VOTE;
-
vote_yescount = 3;
vote_nocount = 2;
vote_needed = 4;
if(!vote_alpha)
return;
- HUD_Panel_UpdateCvars(vote);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
if(uid2name_dialog)
if(!autocvar_hud_panel_modicons) return;
if (gametype != MAPINFO_TYPE_CTF && gametype != MAPINFO_TYPE_KEYHUNT && gametype != MAPINFO_TYPE_NEXBALL && gametype != MAPINFO_TYPE_CTS && gametype != MAPINFO_TYPE_RACE && gametype != MAPINFO_TYPE_CA && gametype != MAPINFO_TYPE_FREEZETAG && gametype != MAPINFO_TYPE_KEEPAWAY && gametype != MAPINFO_TYPE_DOMINATION) return;
}
- else
- hud_configure_active_panel = HUD_PANEL_MODICONS;
- HUD_Panel_UpdateCvars(modicons);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
draw_beginBoldFont();
// Draw pressed keys (#11)
//
-void HUD_DrawPressedKeys(void)
+void HUD_PressedKeys(void)
{
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_pressedkeys) return;
if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
}
- else
- hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
-
- HUD_Panel_UpdateCvars(pressedkeys);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
vector pos, mySize;
pos = panel_pos;
if(autocvar__con_chat_maximized)
if(!hud_draw_maximized) return;
}
- else
- hud_configure_active_panel = HUD_PANEL_CHAT;
- HUD_Panel_UpdateCvars(chat);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
{
if(!autocvar_hud_panel_engineinfo) return;
}
- else
- hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
- HUD_Panel_UpdateCvars(engineinfo);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
vector pos, mySize;
pos = panel_pos;
{
if(!autocvar_hud_panel_infomessages) return;
}
- else
- hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
- HUD_Panel_UpdateCvars(infomessages);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
vector pos, mySize;
pos = panel_pos;
if(spectatee_status == -1 && (autocvar_hud_panel_physics == 1 || autocvar_hud_panel_physics == 3)) return;
if(autocvar_hud_panel_physics == 3 && !(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
}
- else
- hud_configure_active_panel = HUD_PANEL_PHYSICS;
- HUD_Panel_UpdateCvars(physics);
+ HUD_Panel_UpdateCvars();
HUD_Panel_ApplyFadeAlpha();
draw_beginBoldFont();
}
else
{
- hud_configure_active_panel = HUD_PANEL_CENTERPRINT;
-
if (!hud_configure_prev)
reset_centerprint_messages();
if (time > hud_configure_cp_generation_time)
}
}
- HUD_Panel_UpdateCvars(centerprint);
+ HUD_Panel_UpdateCvars();
// this panel doesn't fade when showing the scoreboard
if(autocvar__menu_alpha)
HUD_Mod_CTF_Reset();
}
-#define HUD_DrawPanel(id)\
-switch (id) {\
- case (HUD_PANEL_RADAR):\
- HUD_Radar(); break;\
- case (HUD_PANEL_WEAPONS):\
- HUD_Weapons(); break;\
- case (HUD_PANEL_AMMO):\
- HUD_Ammo(); break;\
- case (HUD_PANEL_POWERUPS):\
- HUD_Powerups(); break;\
- case (HUD_PANEL_HEALTHARMOR):\
- HUD_HealthArmor(); break;\
- case (HUD_PANEL_NOTIFY):\
- HUD_Notify(); break;\
- case (HUD_PANEL_TIMER):\
- HUD_Timer(); break;\
- case (HUD_PANEL_SCORE):\
- HUD_Score(); break;\
- case (HUD_PANEL_RACETIMER):\
- HUD_RaceTimer(); break;\
- case (HUD_PANEL_VOTE):\
- HUD_VoteWindow(); break;\
- case (HUD_PANEL_MODICONS):\
- HUD_ModIcons(); break;\
- case (HUD_PANEL_PRESSEDKEYS):\
- HUD_DrawPressedKeys(); break;\
- case (HUD_PANEL_CHAT):\
- HUD_Chat(); break;\
- case (HUD_PANEL_ENGINEINFO):\
- HUD_EngineInfo(); break;\
- case (HUD_PANEL_INFOMESSAGES):\
- HUD_InfoMessages(); break;\
- case (HUD_PANEL_PHYSICS):\
- HUD_Physics(); break;\
- case (HUD_PANEL_CENTERPRINT):\
- HUD_CenterPrint(); break;\
-} ENDS_WITH_CURLY_BRACE
-
void HUD_Main (void)
{
float i;
// they must call HUD_Panel_ApplyFadeAlpha(); only when showing the menu
if(scoreboard_fade_alpha == 1)
{
- HUD_CenterPrint();
+ (panel = HUD_PANEL(CENTERPRINT)).panel_draw();
return;
}
hud_draw_maximized = 0;
// draw panels in order specified by panel_order array
for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
- HUD_DrawPanel(panel_order[i]);
+ (panel = hud_panel[panel_order[i]]).panel_draw();
hud_draw_maximized = 1; // panels that may be maximized must check this var
// draw maximized panels on top
if(hud_panel_radar_maximized)
- HUD_Radar();
+ (panel = HUD_PANEL(RADAR)).panel_draw();
if(autocvar__con_chat_maximized)
- HUD_Chat();
+ (panel = HUD_PANEL(CHAT)).panel_draw();
if(autocvar__hud_configure)
{
if(tab_panel != -1)
{
- HUD_Panel_UpdatePosSizeForId(tab_panel)
+ panel = hud_panel[tab_panel];
+ HUD_Panel_UpdatePosSize()
drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
}
if(highlightedPanel != -1)
{
- HUD_Panel_UpdatePosSizeForId(highlightedPanel);
+ panel = hud_panel[highlightedPanel];
+ HUD_Panel_UpdatePosSize()
HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha));
}
if(!hud_configure_prev || hud_configure_prev == -1)
{
if(autocvar_hud_cursormode) { setcursormode(1); }
hudShiftState = 0;
+ for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
+ hud_panel[panel_order[i]].update_time = time;
}
}
else if (hud_configure_prev && autocvar_hud_cursormode)
-float panel_order[HUD_PANEL_NUM];
+#define HUD_PANEL_MAX 24
+entity hud_panel[HUD_PANEL_MAX];
+#define HUD_PANEL_FIRST 0
+float HUD_PANEL_NUM;
+float HUD_PANEL_LAST;
+
+float panel_order[HUD_PANEL_MAX];
string hud_panelorder_prev;
float hud_draw_maximized;
var float highlightedPanel_copied = -1; //this is good only to know if there is something copied
var vector panel_size_copied;
-var float hud_configure_active_panel; // this panel has recently referred the UpdateCvars macro
-var string panel_name;
+entity panel;
+.string panel_name;
+.float panel_id;
+.vector current_panel_pos;
+.vector current_panel_size;
+.string current_panel_bg;
+.float current_panel_bg_alpha;
+.float current_panel_bg_border;
+.vector current_panel_bg_color;
+.float current_panel_bg_color_team;
+.float current_panel_bg_padding;
+.float current_panel_fg_alpha;
+.float update_time;
var float panel_enabled;
var vector panel_pos;
var vector panel_size;
var float panel_bg_padding;
var string panel_bg_padding_str;
+.string panel_cvar;
+.void() panel_draw;
+
float current_player;
+
+#define HUD_PANELS \
+ 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)
+
+#define HUD_PANEL(NAME,draw_func,name) \
+ float HUD_PANEL_##NAME; \
+ void ##draw_func(void); \
+ void RegisterHUD_Panel_##NAME() \
+ { \
+ HUD_PANEL_LAST = HUD_PANEL_##NAME = HUD_PANEL_NUM; \
+ entity hud_panelent = spawn(); \
+ hud_panel[HUD_PANEL_##NAME] = hud_panelent; \
+ hud_panelent.panel_name = #name; \
+ hud_panelent.panel_id = HUD_PANEL_##NAME; \
+ hud_panelent.panel_draw = ##draw_func; \
+ ++HUD_PANEL_NUM; \
+ } \
+ ACCUMULATE_FUNCTION(RegisterHUD_Panels, RegisterHUD_Panel_##NAME)
+
+HUD_PANELS
+#undef HUD_PANEL
+
+#define HUD_PANEL(NAME) hud_panel[HUD_PANEL_##NAME]
+
+
// Because calling lots of functions in QC apparently cuts fps in half on many machines:
// ----------------------
// MACRO HELL STARTS HERE
// the check doesn't allow to fade this panel when showing the panel-specific menu dialog
#define HUD_Panel_ApplyFadeAlpha()\
-if(!(menu_enabled == 2 && highlightedPanel == hud_configure_active_panel))\
+if(!(menu_enabled == 2 && panel.panel_id == highlightedPanel))\
{\
panel_bg_alpha *= hud_fade_alpha;\
panel_fg_alpha *= hud_fade_alpha;\
if(autocvar__hud_configure) {\
if(!panel_enabled)\
panel_bg_alpha = 0.25;\
- else if(menu_enabled == 2 && highlightedPanel == hud_configure_active_panel)\
+ else if(menu_enabled == 2 && panel.panel_id == highlightedPanel)\
panel_bg_alpha = (1 - autocvar__menu_alpha) * max(cvar("hud_configure_bg_minalpha"), panel_bg_alpha) + autocvar__menu_alpha * panel_bg_alpha;\
else\
panel_bg_alpha = max(cvar("hud_configure_bg_minalpha"), panel_bg_alpha);\
}\
}
-// Update all common cvars of given panel name
-#define HUD_Panel_UpdateCvars(name) \
-panel_enabled = autocvar_hud_panel_##name; \
-panel_pos = stov(cvar_string("hud_panel_" #name "_pos")); \
-panel_size = stov(cvar_string("hud_panel_" #name "_size")); \
-panel_bg_str = cvar_string("hud_panel_" #name "_bg"); \
-panel_bg_color_str = cvar_string("hud_panel_" #name "_bg_color"); \
-panel_bg_color_team_str = cvar_string("hud_panel_" #name "_bg_color_team"); \
-panel_bg_alpha_str = cvar_string("hud_panel_" #name "_bg_alpha"); \
-panel_bg_border_str = cvar_string("hud_panel_" #name "_bg_border"); \
-panel_bg_padding_str = cvar_string("hud_panel_" #name "_bg_padding"); \
-HUD_Panel_GetStringVars()\
-if(menu_enabled == 2 && hud_configure_active_panel == highlightedPanel) {\
- HUD_Panel_GetMenuSize()\
- HUD_Panel_GetMenuPos()\
+#define HUD_Panel_UpdateCvars() \
+panel_enabled = cvar(strcat("hud_panel_", panel.panel_name)); \
+if(panel.update_time < time) { \
+ panel_pos = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_pos"))); \
+ panel_size = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_size"))); \
+ panel_bg_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg")); \
+ panel_bg_color_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color")); \
+ panel_bg_color_team_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color_team")); \
+ panel_bg_alpha_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_alpha")); \
+ 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_GetStringVars()\
+ if(menu_enabled == 2 && panel.panel_id == highlightedPanel) {\
+ HUD_Panel_GetMenuSize()\
+ HUD_Panel_GetMenuPos()\
+ } \
+ 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 + 2; \
+} 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_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; \
} ENDS_WITH_CURLY_BRACE
-// FTEQCC I HATE YOU WHY DO YOU MAKE ME DO THIS??? :(
-// max macro length is 1024 characters, I must split it up :(
-
-// Update all common cvars of given panel id
-#define HUD_Panel_UpdateCvarsForId_Part2(id) \
-switch(id) { \
- case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdateCvars(infomessages) break; \
- case HUD_PANEL_PHYSICS: HUD_Panel_UpdateCvars(physics); break;\
- case HUD_PANEL_CENTERPRINT: HUD_Panel_UpdateCvars(centerprint); break;\
-}
-
-#define HUD_Panel_UpdateCvarsForId(id) \
-switch(id) { \
- case HUD_PANEL_WEAPONS: HUD_Panel_UpdateCvars(weapons) break; \
- case HUD_PANEL_AMMO: HUD_Panel_UpdateCvars(ammo) break; \
- case HUD_PANEL_POWERUPS: HUD_Panel_UpdateCvars(powerups) break; \
- case HUD_PANEL_HEALTHARMOR: HUD_Panel_UpdateCvars(healtharmor) break; \
- case HUD_PANEL_NOTIFY: HUD_Panel_UpdateCvars(notify) break; \
- case HUD_PANEL_TIMER: HUD_Panel_UpdateCvars(timer) break; \
- case HUD_PANEL_RADAR: HUD_Panel_UpdateCvars(radar) break; \
- case HUD_PANEL_SCORE: HUD_Panel_UpdateCvars(score) break; \
- case HUD_PANEL_RACETIMER: HUD_Panel_UpdateCvars(racetimer) break; \
- case HUD_PANEL_VOTE: HUD_Panel_UpdateCvars(vote) break; \
- case HUD_PANEL_MODICONS: HUD_Panel_UpdateCvars(modicons) break; \
- case HUD_PANEL_PRESSEDKEYS: HUD_Panel_UpdateCvars(pressedkeys) break; \
- case HUD_PANEL_CHAT: HUD_Panel_UpdateCvars(chat) break; \
- case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdateCvars(engineinfo) break; \
- default: HUD_Panel_UpdateCvarsForId_Part2(id)\
-}
-
-#define HUD_Panel_UpdatePosSize(name) \
-panel_pos = stov(cvar_string("hud_panel_" #name "_pos")); \
-panel_size = stov(cvar_string("hud_panel_" #name "_size")); \
+#define HUD_Panel_UpdatePosSize() {\
+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_GetScaledVectors()\
-if(menu_enabled == 2 && hud_configure_active_panel == highlightedPanel) {\
+if(menu_enabled == 2 && panel.panel_id == highlightedPanel) {\
HUD_Panel_GetMenuSize()\
HUD_Panel_GetMenuPos()\
}\
-panel_bg_border_str = cvar_string("hud_panel_" #name "_bg_border"); \
-HUD_Panel_GetBorder()
-
-// Update pos and size of given panel id
-#define HUD_Panel_UpdatePosSizeForId_Part2(id) \
-switch(id) { \
- case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdatePosSize(infomessages) break;\
- case HUD_PANEL_PHYSICS: HUD_Panel_UpdatePosSize(physics); break;\
- case HUD_PANEL_CENTERPRINT: HUD_Panel_UpdatePosSize(centerprint); break;\
-}
+panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border")); \
+HUD_Panel_GetBorder() \
+} ENDS_WITH_CURLY_BRACE
-#define HUD_Panel_UpdatePosSizeForId(id) \
-switch(id) { \
- case HUD_PANEL_WEAPONS: HUD_Panel_UpdatePosSize(weapons) break;\
- case HUD_PANEL_AMMO: HUD_Panel_UpdatePosSize(ammo) break;\
- case HUD_PANEL_POWERUPS: HUD_Panel_UpdatePosSize(powerups) break;\
- case HUD_PANEL_HEALTHARMOR: HUD_Panel_UpdatePosSize(healtharmor) break;\
- case HUD_PANEL_NOTIFY: HUD_Panel_UpdatePosSize(notify) break;\
- case HUD_PANEL_TIMER: HUD_Panel_UpdatePosSize(timer) break;\
- case HUD_PANEL_RADAR: HUD_Panel_UpdatePosSize(radar) break;\
- case HUD_PANEL_SCORE: HUD_Panel_UpdatePosSize(score) break;\
- case HUD_PANEL_RACETIMER: HUD_Panel_UpdatePosSize(racetimer) break;\
- case HUD_PANEL_VOTE: HUD_Panel_UpdatePosSize(vote) break;\
- case HUD_PANEL_MODICONS: HUD_Panel_UpdatePosSize(modicons) break;\
- case HUD_PANEL_PRESSEDKEYS: HUD_Panel_UpdatePosSize(pressedkeys) break;\
- case HUD_PANEL_CHAT: HUD_Panel_UpdatePosSize(chat) break;\
- case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdatePosSize(engineinfo) break;\
- default: HUD_Panel_UpdatePosSizeForId_Part2(id)\
-}
#define KN_MAX_ENTRIES 10
// q: quoted, n: not quoted
#define HUD_Write_Cvar_n(cvar) HUD_Write(strcat("seta ", cvar, " ", cvar_string(cvar), "\n"))
#define HUD_Write_Cvar_q(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
-#define HUD_Write_PanelCvar_n(cvar_suf) HUD_Write_Cvar_n(strcat("hud_panel_", panel_name, cvar_suf))
-#define HUD_Write_PanelCvar_q(cvar_suf) HUD_Write_Cvar_q(strcat("hud_panel_", panel_name, cvar_suf))
+#define HUD_Write_PanelCvar_n(cvar_suf) HUD_Write_Cvar_n(strcat("hud_panel_", panel.panel_name, cvar_suf))
+#define HUD_Write_PanelCvar_q(cvar_suf) HUD_Write_Cvar_q(strcat("hud_panel_", panel.panel_name, cvar_suf))
// Save the config
void HUD_Panel_ExportCfg(string cfgname)
{
float i;
for (i = 0; i < HUD_PANEL_NUM; ++i)
{
- HUD_Panel_GetName(i);
+ panel = hud_panel[i];
HUD_Write_PanelCvar_n("");
HUD_Write_PanelCvar_q("_pos");
if(i == highlightedPanel || !panel_enabled)
continue;
- HUD_Panel_UpdatePosSizeForId(i);
+ panel = hud_panel[i];
+ HUD_Panel_UpdatePosSize()
panel_pos -= '1 1 0' * panel_bg_border;
panel_size += '2 2 0' * panel_bg_border;
void HUD_Panel_SetPos(vector pos)
{
- HUD_Panel_UpdatePosSizeForId(highlightedPanel);
+ panel = hud_panel[highlightedPanel];
+ HUD_Panel_UpdatePosSize()
vector mySize;
mySize = panel_size;
string s;
s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
- HUD_Panel_GetName(highlightedPanel);
- cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
+ cvar_set(strcat("hud_panel_", hud_panel[highlightedPanel].panel_name, "_pos"), s);
}
// check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
if(i == highlightedPanel || !panel_enabled)
continue;
- HUD_Panel_UpdatePosSizeForId(i);
+ panel = hud_panel[i];
+ HUD_Panel_UpdatePosSize()
panel_pos -= '1 1 0' * panel_bg_border;
panel_size += '2 2 0' * panel_bg_border;
void HUD_Panel_SetPosSize(vector mySize)
{
- HUD_Panel_UpdatePosSizeForId(highlightedPanel);
+ panel = hud_panel[highlightedPanel];
+ HUD_Panel_UpdatePosSize()
vector resizeorigin;
resizeorigin = panel_click_resizeorigin;
local noref vector myPos; // fteqcc sucks
//if(cvar("hud_configure_checkcollisions_debug"))
//drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
- HUD_Panel_GetName(highlightedPanel);
+ entity e = hud_panel[highlightedPanel];
string s;
s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
- cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
+ cvar_set(strcat("hud_panel_", e.panel_name, "_size"), s);
s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
- cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
+ cvar_set(strcat("hud_panel_", e.panel_name, "_pos"), s);
}
float pressed_key_time;
step = (step / 64) * (1 + 2 * (time - pressed_key_time));
}
- HUD_Panel_UpdatePosSizeForId(highlightedPanel);
+ panel = hud_panel[highlightedPanel];
+ HUD_Panel_UpdatePosSize()
highlightedPanel_initial_pos = panel_pos;
highlightedPanel_initial_size = panel_size;
HUD_Panel_SetPos(pos);
}
- HUD_Panel_UpdatePosSizeForId(highlightedPanel);
+ panel = hud_panel[highlightedPanel];
+ HUD_Panel_UpdatePosSize()
if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size)
{
vector prevMouseClickedPos; // pos during previous left mouse click, to check for doubleclicks
void HUD_Panel_EnableMenu();
-float tab_panels[HUD_PANEL_NUM];
+float tab_panels[HUD_PANEL_MAX];
float tab_panel, tab_backward;
vector tab_panel_pos;
void HUD_Panel_FirstInDrawQ(float id);
if (tab_panel == -1) //first press of TAB
{
if (highlightedPanel != -1)
- HUD_Panel_UpdatePosSizeForId(highlightedPanel)
+ if (highlightedPanel)
+ {
+ panel = hud_panel[highlightedPanel];
+ HUD_Panel_UpdatePosSize()
+ }
else
panel_pos = '0 0 0';
starting_panel = highlightedPanel; //can be -1, it means no starting panel
{
if (i == tab_panels[i] || i == starting_panel)
continue;
- HUD_Panel_UpdatePosSizeForId(i)
+ panel = hud_panel[i];
+ HUD_Panel_UpdatePosSize()
if (panel_pos_y >= level && (panel_pos_y - level) < level_height)
if ( ( !tab_backward && panel_pos_x >= start_pos_x && (panel_pos_x < candidate_pos_x || (panel_pos_x == candidate_pos_x && panel_pos_y <= candidate_pos_y)) )
|| ( tab_backward && panel_pos_x <= start_pos_x && (panel_pos_x > candidate_pos_x || (panel_pos_x == candidate_pos_x && panel_pos_y >= candidate_pos_y)) ) )
if (highlightedPanel != -1)
{
- HUD_Panel_GetName(highlightedPanel);
- cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
+ entity e = hud_panel[highlightedPanel];
+ cvar_set(strcat("hud_panel_", e.panel_name), ftos(!(panel_enabled)));
}
else
cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
if (highlightedPanel != -1)
{
- HUD_Panel_UpdatePosSizeForId(highlightedPanel);
+ panel = hud_panel[highlightedPanel];
+ HUD_Panel_UpdatePosSize()
panel_size_copied = panel_size;
highlightedPanel_copied = highlightedPanel;
}
if (highlightedPanel_copied == -1 || highlightedPanel == -1)
return true;
- HUD_Panel_UpdatePosSizeForId(highlightedPanel);
+ panel = hud_panel[highlightedPanel];
+ HUD_Panel_UpdatePosSize()
// reduce size if it'd go beyond screen boundaries
vector tmp_size = panel_size_copied;
highlightedPanel_backup = highlightedPanel;
s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight));
- HUD_Panel_GetName(highlightedPanel);
- cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
+ entity e = hud_panel[highlightedPanel];
+ cvar_set(strcat("hud_panel_", e.panel_name, "_size"), s);
}
else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
{
//restore previous values
if (highlightedPanel_backup != -1)
{
- HUD_Panel_GetName(highlightedPanel_backup);
+ entity e = hud_panel[highlightedPanel_backup];
s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
- cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
+ cvar_set(strcat("hud_panel_", e.panel_name, "_pos"), s);
s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
- cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
+ cvar_set(strcat("hud_panel_", e.panel_name, "_size"), s);
highlightedPanel_backup = -1;
}
}
i = panel_order[j];
j += 1;
- HUD_Panel_UpdatePosSizeForId(i);
+ panel = hud_panel[i];
+ HUD_Panel_UpdatePosSize()
border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
i = panel_order[j];
j += 1;
- HUD_Panel_UpdatePosSizeForId(i);
+ panel = hud_panel[i];
+ HUD_Panel_UpdatePosSize()
border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
{
menu_enabled = 2;
menu_enabled_time = time;
- HUD_Panel_GetName(highlightedPanel);
- localcmd("menu_showhudoptions ", panel_name, "\n");
+ localcmd("menu_showhudoptions ", hud_panel[highlightedPanel].panel_name, "\n");
}
float mouse_over_panel;
void HUD_Panel_Mouse()
reset_tab_panels();
}
HUD_Panel_Highlight(mouseClicked & S_MOUSE1); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
- // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
+ // and calls HUD_Panel_UpdatePosSize() for the highlighted panel
if (highlightedPanel != -1)
{
highlightedPanel_initial_pos = panel_pos;
}
}
else
- HUD_Panel_UpdatePosSizeForId(highlightedPanel);
+ {
+ panel = hud_panel[highlightedPanel];
+ HUD_Panel_UpdatePosSize()
+ }
if (highlightedPanel != -1)
{
float WR_PLAYERDEATH = 13; // (SVQC) does not need to do anything
float WR_GONETHINK = 14; // (SVQC) logic to run every frame, also if no longer having the weapon as long as the switch away has not been performed
+#ifdef MENUQC
float HUD_PANEL_WEAPONS = 0;
float HUD_PANEL_AMMO = 1;
float HUD_PANEL_POWERUPS = 2;
float HUD_PANEL_PHYSICS = 15;
float HUD_PANEL_CENTERPRINT = 16;
float HUD_PANEL_NUM = 17; // always last panel id + 1, please increment when adding a new panel
-
-string HUD_PANELNAME_WEAPONS = "weapons";
-string HUD_PANELNAME_AMMO = "ammo";
-string HUD_PANELNAME_POWERUPS = "powerups";
-string HUD_PANELNAME_HEALTHARMOR = "healtharmor";
-string HUD_PANELNAME_NOTIFY = "notify";
-string HUD_PANELNAME_TIMER = "timer";
-string HUD_PANELNAME_RADAR = "radar";
-string HUD_PANELNAME_SCORE = "score";
-string HUD_PANELNAME_RACETIMER = "racetimer";
-string HUD_PANELNAME_VOTE = "vote";
-string HUD_PANELNAME_MODICONS = "modicons";
-string HUD_PANELNAME_PRESSEDKEYS = "pressedkeys";
-string HUD_PANELNAME_CHAT = "chat";
-string HUD_PANELNAME_ENGINEINFO = "engineinfo";
-string HUD_PANELNAME_INFOMESSAGES = "infomessages";
-string HUD_PANELNAME_PHYSICS = "physics";
-string HUD_PANELNAME_CENTERPRINT = "centerprint";
+#endif
#define SERVERFLAG_ALLOW_FULLBRIGHT 1
#define SERVERFLAG_TEAMPLAY 2
string get_model_parameters_desc;
float get_model_parameters(string mod, float skn); // call with string_null to clear; skin -1 means mod is the filename of the txt file and is to be split
-// stupid stupid stupid FTEQCC has a max limit on macro sizes, let's work around by splitting the macro into two macros! :(
-#define HUD_Panel_GetName_Part2(id) \
-switch(id) {\
- case HUD_PANEL_ENGINEINFO: panel_name = HUD_PANELNAME_ENGINEINFO; break; \
- case HUD_PANEL_INFOMESSAGES: panel_name = HUD_PANELNAME_INFOMESSAGES; break; \
- case HUD_PANEL_PHYSICS: panel_name = HUD_PANELNAME_PHYSICS; break; \
- case HUD_PANEL_CENTERPRINT: panel_name = HUD_PANELNAME_CENTERPRINT; break; \
-} ENDS_WITH_CURLY_BRACE
-
-// Get name of specified panel id
-#define HUD_Panel_GetName(id) \
-switch(id) { \
- case HUD_PANEL_WEAPONS: panel_name = HUD_PANELNAME_WEAPONS; break; \
- case HUD_PANEL_AMMO: panel_name = HUD_PANELNAME_AMMO; break; \
- case HUD_PANEL_POWERUPS: panel_name = HUD_PANELNAME_POWERUPS; break; \
- case HUD_PANEL_HEALTHARMOR: panel_name = HUD_PANELNAME_HEALTHARMOR; break; \
- case HUD_PANEL_NOTIFY: panel_name = HUD_PANELNAME_NOTIFY; break; \
- case HUD_PANEL_TIMER: panel_name = HUD_PANELNAME_TIMER; break; \
- case HUD_PANEL_RADAR: panel_name = HUD_PANELNAME_RADAR; break; \
- case HUD_PANEL_SCORE: panel_name = HUD_PANELNAME_SCORE; break; \
- case HUD_PANEL_RACETIMER: panel_name = HUD_PANELNAME_RACETIMER; break; \
- case HUD_PANEL_VOTE: panel_name = HUD_PANELNAME_VOTE; break; \
- case HUD_PANEL_MODICONS: panel_name = HUD_PANELNAME_MODICONS; break; \
- case HUD_PANEL_PRESSEDKEYS: panel_name = HUD_PANELNAME_PRESSEDKEYS; break; \
- case HUD_PANEL_CHAT: panel_name = HUD_PANELNAME_CHAT; break; \
- default: HUD_Panel_GetName_Part2(id)\
-}
-
vector vec2(vector v);
#ifndef MENUQC