#include "hud.qh"
#include "panel/scoreboard.qh"
#include <client/autocvars.qh>
-#include <client/defs.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
#include <client/view.qh>
// Save the config
HUD_Write("\n");
// common cvars for all panels
- for (int i = 0; i < hud_panels_COUNT; ++i)
+ for (int i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
{
- panel = hud_panels_from(i);
+ panel = REGISTRY_GET(hud_panels, i);
HUD_Write_PanelCvar("_pos");
HUD_Write_PanelCvar("_size");
HUD_Write_PanelCvar("_bg_alpha");
HUD_Write_PanelCvar("_bg_border");
HUD_Write_PanelCvar("_bg_padding");
- panel.panel_export(panel, fh);
+ panel.panel_export(fh);
HUD_Write("\n");
}
- MUTATOR_CALLHOOK(HUD_WriteCvars, fh);
HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
vector myCenter, targCenter;
vector myTarget = myPos;
int i;
- for (i = 0; i < hud_panels_COUNT; ++i) {
- panel = hud_panels_from(i);
+ for (i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
+ panel = REGISTRY_GET(hud_panels, i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
if(panel == highlightedPanel) continue;
HUD_Panel_UpdatePosSize();
vector dist;
float ratio = mySize.x/mySize.y;
int i;
- for (i = 0; i < hud_panels_COUNT; ++i) {
- panel = hud_panels_from(i);
+ for (i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
+ panel = REGISTRY_GET(hud_panels, i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
if(panel == highlightedPanel) continue;
HUD_Panel_UpdatePosSize();
}
}
-entity tab_panels[hud_panels_MAX];
+entity tab_panels[REGISTRY_MAX(hud_panels)];
entity tab_panel;
vector tab_panel_pos;
float tab_backward;
void reset_tab_panels()
{
- for (int i = 0; i < hud_panels_COUNT; ++i)
+ for (int i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
tab_panels[i] = NULL;
}
float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
k=0;
while(++k)
{
- for(i = 0; i < hud_panels_COUNT; ++i)
+ for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
{
- panel = hud_panels_from(i);
+ panel = REGISTRY_GET(hud_panels, i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
continue;
if (panel == tab_panels[i] || panel == starting_panel)
int HUD_Panel_Check_Mouse_Pos(bool allow_move)
{
int i, j = 0;
- while(j < hud_panels_COUNT)
+ while(j < REGISTRY_COUNT(hud_panels))
{
i = panel_order[j];
j += 1;
- panel = hud_panels_from(i);
+ panel = REGISTRY_GET(hud_panels, i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
HUD_Panel_UpdatePosSize();
int i;
int place = -1;
// find out where in the array our current id is, save into place
- for(i = 0; i < hud_panels_COUNT; ++i)
+ for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
{
if(panel_order[i] == id)
{
}
// place last if we didn't find a place for it yet (probably new panel, or screwed up cvar)
if(place == -1)
- place = hud_panels_COUNT - 1;
+ place = REGISTRY_COUNT(hud_panels) - 1;
// move all ids up by one step in the array until "place"
for(i = place; i > 0; --i)
// let's save them into the cvar by some strcat trickery
string s = "";
- for(i = 0; i < hud_panels_COUNT; ++i)
+ for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
{
s = strcat(s, ftos(panel_order[i]), " ");
}
{
int i, j = 0;
- while(j < hud_panels_COUNT)
+ while(j < REGISTRY_COUNT(hud_panels))
{
i = panel_order[j];
j += 1;
- panel = hud_panels_from(i);
+ panel = REGISTRY_GET(hud_panels, i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
continue;
HUD_Panel_UpdatePosSize();
// move
if(allow_move && mousepos.x > panel_pos.x && mousepos.y > panel_pos.y && mousepos.x < panel_pos.x + panel_size.x && mousepos.y < panel_pos.y + panel_size.y)
{
- highlightedPanel = hud_panels_from(i);
+ highlightedPanel = REGISTRY_GET(hud_panels, i);
HUD_Panel_FirstInDrawQ(i);
highlightedAction = 1;
panel_click_distance = mousepos - panel_pos;
// resize from topleft border
else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
{
- highlightedPanel = hud_panels_from(i);
+ highlightedPanel = REGISTRY_GET(hud_panels, i);
HUD_Panel_FirstInDrawQ(i);
highlightedAction = 2;
resizeCorner = 1;
// resize from topright border
else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
{
- highlightedPanel = hud_panels_from(i);
+ highlightedPanel = REGISTRY_GET(hud_panels, i);
HUD_Panel_FirstInDrawQ(i);
highlightedAction = 2;
resizeCorner = 2;
// resize from bottomleft border
else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + panel_size.y + border)
{
- highlightedPanel = hud_panels_from(i);
+ highlightedPanel = REGISTRY_GET(hud_panels, i);
HUD_Panel_FirstInDrawQ(i);
highlightedAction = 2;
resizeCorner = 3;
// resize from bottomright border
else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + panel_size.y + border)
{
- highlightedPanel = hud_panels_from(i);
+ highlightedPanel = REGISTRY_GET(hud_panels, i);
HUD_Panel_FirstInDrawQ(i);
highlightedAction = 2;
resizeCorner = 4;
if(!hud_configure_prev)
{
hudShiftState = 0;
- for(i = hud_panels_COUNT - 1; i >= 0; --i)
- hud_panels_from(panel_order[i]).update_time = time;
+ for(i = REGISTRY_COUNT(hud_panels) - 1; i >= 0; --i)
+ REGISTRY_GET(hud_panels, panel_order[i]).update_time = time;
}
// NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled