]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud_config.qc
Merge branch 'master' into Mario/buff_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud_config.qc
index 0f4d93291e1bfaa24af8eb8ffb4ffdce739d2143..696b1e7059e4efb8947517680e7f57e2df717ff8 100644 (file)
@@ -1,13 +1,11 @@
-#if defined(CSQC)
-       #include "../dpdefs/csprogsdefs.qh"
-       #include "defs.qh"
-       #include "../dpdefs/keycodes.qh"
-       #include "../common/constants.qh"
-       #include "autocvars.qh"
-       #include "hud.qh"
-#elif defined(MENUQC)
-#elif defined(SVQC)
-#endif
+#include "hud_config.qh"
+#include "_all.qh"
+
+#include "hud.qh"
+
+#include "../common/constants.qh"
+
+#include "../dpdefs/keycodes.qh"
 
 
 #define HUD_Write(s) fputs(fh, s)
@@ -61,7 +59,7 @@ void HUD_Panel_ExportCfg(string cfgname)
                HUD_Write("\n");
 
                // common cvars for all panels
-               float i;
+               int i;
                for (i = 0; i < HUD_PANEL_NUM; ++i)
                {
                        panel = hud_panel[i];
@@ -204,6 +202,9 @@ void HUD_Panel_ExportCfg(string cfgname)
                                        HUD_Write_PanelCvar_q("_fade_subsequent_minfontsize");
                                        HUD_Write_PanelCvar_q("_fade_minfontsize");
                                        break;
+                               case HUD_PANEL_BUFFS:
+                                       HUD_Write_PanelCvar_q("_progressbar");
+                                       HUD_Write_PanelCvar_q("_progressbar_name");
                        }
                        HUD_Write("\n");
                }
@@ -324,14 +325,10 @@ void HUD_Panel_SetPos(vector pos)
 
 // 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(vector mySize, vector resizeorigin) {
-       float i;
-
        vector targEndPos;
-
        vector dist;
-       float ratio;
-       ratio = mySize.x/mySize.y;
-
+       float ratio = mySize.x/mySize.y;
+       int i;
        for (i = 0; i < HUD_PANEL_NUM; ++i) {
                panel = hud_panel[i];
                if(panel == highlightedPanel) continue;
@@ -437,8 +434,7 @@ void HUD_Panel_SetPosSize(vector mySize)
 {
        panel = highlightedPanel;
        HUD_Panel_UpdatePosSize();
-       vector resizeorigin;
-       resizeorigin = panel_click_resizeorigin;
+       vector resizeorigin = panel_click_resizeorigin;
        vector myPos;
 
        // minimum panel size cap
@@ -571,7 +567,6 @@ void HUD_Panel_Arrow_Action(float nPrimary)
 
        if (hudShiftState & S_ALT) // resize
        {
-               highlightedAction = 1;
                if(nPrimary == K_UPARROW)
                        resizeCorner = 1;
                else if(nPrimary == K_RIGHTARROW)
@@ -608,7 +603,6 @@ void HUD_Panel_Arrow_Action(float nPrimary)
        }
        else // move
        {
-               highlightedAction = 2;
                vector pos;
                pos = panel_pos;
                if(nPrimary == K_UPARROW)
@@ -687,11 +681,12 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
        con_keys = findkeysforcommand("toggleconsole", 0);
        keys = tokenize(con_keys); // findkeysforcommand returns data for this
 
-       float hit_con_bind = 0, i;
+       bool hit_con_bind = false;
+       int i;
        for (i = 0; i < keys; ++i)
        {
                if(nPrimary == stof(argv(i)))
-                       hit_con_bind = 1;
+                       hit_con_bind = true;
        }
 
        if(bInputType == 0) {
@@ -749,15 +744,14 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                if (!menu_enabled)
                        cvar_set("_hud_configure", "0");
        }
-       else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // select and highlight another panel
+       else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // switch panel
        {
                if (bInputType == 1 || mouseClicked)
                        return true;
 
-               //FIXME: if a panel is highlighted, has the same pos_x and lays in the same level
-               //of other panels then next consecutive ctrl-tab will select the highlighted panel too
-               //(it should only after every other panel of the hud)
-               //It's a minor bug anyway, we can live with it
+               // FIXME minor bug: if a panel is highlighted, has the same pos_x and
+               // lays in the same level of another panel then the next consecutive
+               // CTRL TAB presses will reselect once more the highlighted panel
 
                entity starting_panel;
                entity old_tab_panel = tab_panel;
@@ -902,6 +896,12 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                        highlightedPanel_backup = world;
                }
        }
+       else if(nPrimary == 's' && hudShiftState & S_CTRL) // save config
+       {
+               if (bInputType == 1 || mouseClicked)
+                       return true;
+               localcmd("hud save myconfig\n");
+       }
        else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
        {
                if (bInputType == 1)
@@ -922,7 +922,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                if (highlightedPanel)
                        HUD_Panel_EnableMenu();
        }
-       else if(hit_con_bind)
+       else if(hit_con_bind || nPrimary == K_PAUSE)
                return false;
 
        return true;
@@ -930,8 +930,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
 
 float HUD_Panel_Check_Mouse_Pos(float allow_move)
 {
-       float i, j = 0, border;
-
+       int i, j = 0;
        while(j < HUD_PANEL_NUM)
        {
                i = panel_order[j];
@@ -940,7 +939,7 @@ float HUD_Panel_Check_Mouse_Pos(float allow_move)
                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
+               float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
 
                // 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)
@@ -1011,7 +1010,7 @@ void HUD_Panel_FirstInDrawQ(float id)
 
 void HUD_Panel_Highlight(float allow_move)
 {
-       float i, j = 0, border;
+       int i, j = 0;
 
        while(j < HUD_PANEL_NUM)
        {
@@ -1021,7 +1020,7 @@ void HUD_Panel_Highlight(float allow_move)
                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
+               float border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize
 
                // 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)
@@ -1182,6 +1181,8 @@ void HUD_Panel_Mouse()
        }
        else
        {
+               if(prevMouseClicked)
+                       highlightedAction = 0;
                if(menu_enabled == 2)
                        mouse_over_panel = 0;
                else
@@ -1228,7 +1229,7 @@ void HUD_Configure_DrawGrid()
 float _menu_alpha_prev;
 void HUD_Configure_Frame()
 {
-       float i;
+       int i;
        if(autocvar__hud_configure)
        {
                if(isdemo() || intermission == 2)
@@ -1237,7 +1238,7 @@ void HUD_Configure_Frame()
                        return;
                }
 
-               if(!hud_configure_prev || hud_configure_prev == -1)
+               if(!hud_configure_prev)
                {
                        if(autocvar_hud_cursormode)
                                setcursormode(1);