float i;
for (i = 0; i < HUD_PANEL_NUM; ++i)
{
-// HUD_Panel_GetName(i)
-// HUD_Panel_UpdateCvarsForId(i)
+ HUD_Panel_GetName(i)
+ HUD_Panel_UpdateCvarsForId(i)
fputs(fh, strcat("seta hud_", panel_name, " ", ftos(cvar(strcat("hud_", panel_name))), "\n"));
fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
vector HUD_Panel_GetMenuSize(float id)
{
vector mySize;
- mySize = stov(cvar_string(strcat("hud_", panel_name, "_size")));
+ mySize = panel_size;
mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
vector HUD_Panel_GetMenuPos(float id)
{
vector pos;
- pos = stov(cvar_string(strcat("hud_", panel_name, "_pos")));
+ pos = panel_pos;
pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
stov(cvar_string(strcat("hud_progressbar_", item, "_color")))
// check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
-vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
+vector HUD_Panel_CheckMove(vector myPos, vector mySize)
{
float i;
for (i = 0; i < HUD_PANEL_NUM; ++i) {
HUD_Panel_UpdateCvarsForId(i)
- if(i == id || !panel_enabled)
+ if(i == highlightedPanel || !panel_enabled)
continue;
targPos = panel_pos;
return myTarget;
}
-void HUD_Panel_SetPos(float id, vector pos)
+void HUD_Panel_SetPos(vector pos)
{
- vector oldPos;
- oldPos = panel_pos;
-
vector mySize;
mySize = panel_size;
if(autocvar_hud_configure_checkcollisions)
- pos = HUD_Panel_CheckMove(id, pos, mySize);
+ pos = HUD_Panel_CheckMove(pos, mySize);
pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
pos_y = bound(0, pos_y, vid_conheight - mySize_y);
string s;
s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
+ HUD_Panel_GetName(highlightedPanel);
cvar_set(strcat("hud_", 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
-vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
+vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
float i;
float targBorder;
ratio = mySize_x/mySize_y;
for (i = 0; i < HUD_PANEL_NUM; ++i) {
- if(i == id || !panel_enabled)
+ HUD_Panel_UpdateCvarsForId(i);
+
+ if(i == highlightedPanel || !panel_enabled)
continue;
targPos = panel_pos;
return mySize;
}
-void HUD_Panel_SetPosSize(float id, vector mySize)
+void HUD_Panel_SetPosSize(vector mySize)
{
+ HUD_Panel_UpdatePosSizeForId(highlightedPanel)
vector resizeorigin;
resizeorigin = panel_click_resizeorigin;
vector myPos;
mySize_x = max(0.025 * vid_conwidth, mySize_x);
mySize_y = max(0.025 * vid_conheight, mySize_y);
- if(id == HUD_PANEL_CHAT) // some panels have their own restrictions, like the chat panel (which actually only moves the engine chat print around). Looks bad if it's too small.
+ if(highlightedPanel == HUD_PANEL_CHAT) // some panels have their own restrictions, like the chat panel (which actually only moves the engine chat print around). Looks bad if it's too small.
{
mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
}
if(autocvar_hud_configure_checkcollisions)
- mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin);
+ mySize = HUD_Panel_CheckResize(mySize, resizeorigin);
// minimum panel size cap, do this once more so we NEVER EVER EVER have a panel smaller than this, JUST IN CASE above code still makes the panel eg negative (impossible to resize back without changing cvars manually then)
mySize_x = max(0.025 * vid_conwidth, mySize_x);
if(cvar("hud_configure_checkcollisions_debug"))
drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
+ HUD_Panel_GetName(highlightedPanel);
string s;
s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
cvar_set(strcat("hud_", panel_name, "_size"), s);
} else { // resizeCorner == 4
mySize_y += step;
}
- HUD_Panel_SetPosSize(highlightedPanel, mySize);
+ HUD_Panel_SetPosSize(mySize);
}
else // move
{
else // if(nPrimary == K_RIGHTARROW)
pos_x += step;
- HUD_Panel_SetPos(highlightedPanel, pos);
+ HUD_Panel_SetPos(pos);
}
}
for(i = 0; i < HUD_PANEL_NUM; ++i)
{
+ HUD_Panel_UpdateCvarsForId(i);
+
panelPos = panel_pos;
panelSize = panel_size;
border = 10; // FORCED border so a small border size doesn't mean you can't resize
hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
if(highlightedAction == 1)
- HUD_Panel_SetPos(highlightedPanel, mousepos - panel_click_distance);
+ HUD_Panel_SetPos(mousepos - panel_click_distance);
else if(highlightedAction == 2)
{
vector mySize;
mySize_x = mousepos_x - (panel_click_resizeorigin_x - panel_click_distance_x);
mySize_y = mousepos_y - (panel_click_resizeorigin_y - panel_click_distance_y);
}
- HUD_Panel_SetPosSize(highlightedPanel, mySize);
+ HUD_Panel_SetPosSize(mySize);
}
// doubleclick check
newPos_x = myPos_x;
}
+ HUD_Panel_GetName(id);
vector picpos, numpos;
float iconalign;
iconalign = cvar(strcat("hud_", panel_name, "_iconalign"));
// 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()\
if(panel_bg_color_str == "") {\
- panel_bg_color_str = autocvar_hud_bg_color;\
+ panel_bg_color = autocvar_hud_bg_color;\
} if(teamplay && panel_bg_color_team) {\
panel_bg_color = colormapPaletteColor(mod(stof(getplayerkey(player_localentnum - 1, "colors")), 16), 1) * panel_bg_color_team;\
} else {\
case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdateCvars(engineinfo) break; \
}
+#define HUD_Panel_UpdatePosSize(name) \
+panel_pos = autocvar_hud_##name##_pos; \
+panel_size = autocvar_hud_##name##_size; \
+HUD_Panel_GetScaledVectors()
+
+// Update pos and size of given panel id
+#define HUD_Panel_UpdatePosSizeForId(id) \
+switch(id) { \
+ case HUD_PANEL_WEAPONICONS: HUD_Panel_UpdatePosSize(weaponicons) break; \
+ case HUD_PANEL_INVENTORY: HUD_Panel_UpdatePosSize(inventory) 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; \
+}
+
/* These cvars have to be placed separately wherever they are needed.
panel_accuracy_yellow = autocvar_hud_##name##_accuracy_yellow; \
panel_onlycurrent = autocvar_hud_##name##_onlycurrent; \
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
-string HUD_Panel_GetName(float id)
+
+// Get name of specified panel id
+#define HUD_Panel_GetName(id) \
+switch(id) { \
+ case HUD_PANEL_WEAPONICONS: panel_name = HUD_PANELNAME_WEAPONICONS; break; \
+ case HUD_PANEL_INVENTORY: panel_name = HUD_PANELNAME_INVENTORY; 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; \
+ case HUD_PANEL_ENGINEINFO: panel_name = HUD_PANELNAME_ENGINEINFO; break; \
+}