]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/hud_config.qc
Merge branch 'master' into martin-t/limit
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / hud_config.qc
index a1f1cc7ecfd6d7e069b4a2d5d90f41a8b4810a14..27a33c408b50de484b40dbbd9722b47972756e4e 100644 (file)
@@ -5,6 +5,7 @@
 #include <client/autocvars.qh>
 #include <client/defs.qh>
 #include <client/miscfunctions.qh>
+#include <client/view.qh>
 
 #define HUD_Write(s) fputs(fh, s)
 #define HUD_Write_Cvar(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
@@ -44,6 +45,7 @@ void HUD_Panel_ExportCfg(string cfgname)
                HUD_Write_Cvar("hud_progressbar_health_color");
                HUD_Write_Cvar("hud_progressbar_armor_color");
                HUD_Write_Cvar("hud_progressbar_fuel_color");
+               HUD_Write_Cvar("hud_progressbar_oxygen_color");
                HUD_Write_Cvar("hud_progressbar_nexball_color");
                HUD_Write_Cvar("hud_progressbar_speed_color");
                HUD_Write_Cvar("hud_progressbar_acceleration_color");
@@ -96,6 +98,7 @@ void HUD_Panel_ExportCfg(string cfgname)
                                        HUD_Write_Cvar("hud_panel_weapons_timeout_speed_in");
                                        HUD_Write_Cvar("hud_panel_weapons_timeout_speed_out");
                                        HUD_Write_Cvar("hud_panel_weapons_onlyowned");
+                                       HUD_Write_Cvar("hud_panel_weapons_orderbyimpulse");
                                        HUD_Write_Cvar("hud_panel_weapons_noncurrent_alpha");
                                        HUD_Write_Cvar("hud_panel_weapons_noncurrent_scale");
                                        HUD_Write_Cvar("hud_panel_weapons_selection_radius");
@@ -239,11 +242,11 @@ void HUD_Panel_ExportCfg(string cfgname)
 
                HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
 
-               LOG_INFOF(_("^2Successfully exported to %s! (Note: It's saved in data/data/)\n"), filename);
+               LOG_INFOF(_("^2Successfully exported to %s! (Note: It's saved in data/data/)"), filename);
                fclose(fh);
        }
        else
-               LOG_INFOF(_("^1Couldn't write to %s\n"), filename);
+               LOG_INFOF(_("^1Couldn't write to %s"), filename);
 }
 
 void HUD_Configure_Exit_Force()
@@ -253,6 +256,7 @@ void HUD_Configure_Exit_Force()
                hud_configure_menu_open = 0;
                localcmd("togglemenu\n");
        }
+       cursor_type = CURSOR_NORMAL;
        cvar_set("_hud_configure", "0");
 }
 
@@ -660,12 +664,10 @@ void HUD_Panel_Arrow_Action(float nPrimary)
        }
 }
 
-void HUD_Panel_EnableMenu();
 entity tab_panels[hud_panels_MAX];
 entity tab_panel;
 vector tab_panel_pos;
 float tab_backward;
-void HUD_Panel_FirstInDrawQ(float id);
 void reset_tab_panels()
 {
        for (int i = 0; i < hud_panels_COUNT; ++i)
@@ -762,7 +764,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                if (bInputType == 1)
                        return true;
                if (!hud_configure_menu_open)
-                       cvar_set("_hud_configure", "0");
+                       HUD_Configure_Exit_Force();
        }
        else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // switch panel
        {
@@ -953,7 +955,7 @@ LABEL(find_tab_panel)
        return true;
 }
 
-float HUD_Panel_Check_Mouse_Pos(float allow_move)
+int HUD_Panel_Check_Mouse_Pos(bool allow_move)
 {
        int i, j = 0;
        while(j < hud_panels_COUNT)
@@ -970,30 +972,30 @@ float HUD_Panel_Check_Mouse_Pos(float allow_move)
                // 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)
                {
-                       return 1;
+                       return CURSOR_MOVE;
                }
                // 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)
                {
-                       return 2;
+                       return CURSOR_RESIZE;
                }
                // 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)
                {
-                       return 3;
+                       return CURSOR_RESIZE2;
                }
                // 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)
                {
-                       return 3;
+                       return CURSOR_RESIZE2;
                }
                // 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)
                {
-                       return 2;
+                       return CURSOR_RESIZE;
                }
        }
-       return 0;
+       return CURSOR_NORMAL;
 }
 
 // move a panel to the beginning of the panel order array (which means it gets drawn last, on top of everything else)
@@ -1029,9 +1031,7 @@ void HUD_Panel_FirstInDrawQ(float id)
                s = strcat(s, ftos(panel_order[i]), " ");
        }
        cvar_set("_hud_panelorder", s);
-       if(hud_panelorder_prev)
-               strunzone(hud_panelorder_prev);
-       hud_panelorder_prev = strzone(autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
+       strcpy(hud_panelorder_prev, autocvar__hud_panelorder); // prevent HUD_Main from doing useless update, we already updated here
 }
 
 void HUD_Panel_Highlight(float allow_move)
@@ -1115,15 +1115,11 @@ void HUD_Panel_EnableMenu()
        hud_configure_menu_open = 2;
        localcmd("menu_showhudoptions ", highlightedPanel.panel_name, "\n");
 }
-float mouse_over_panel;
 void HUD_Panel_Mouse()
 {
        if(autocvar__menu_alpha == 1)
                return;
 
-       if (!autocvar_hud_cursormode)
-               update_mousepos();
-
        if(mouseClicked)
        {
                if(prevMouseClicked == 0)
@@ -1154,7 +1150,7 @@ void HUD_Panel_Mouse()
                                        prevMouseClickedTime = time;
                                        prevMouseClickedPos = mousepos;
                                }
-                               mouse_over_panel = HUD_Panel_Check_Mouse_Pos(mouseClicked & S_MOUSE1);
+                               cursor_type = HUD_Panel_Check_Mouse_Pos(mouseClicked & S_MOUSE1);
                        }
                }
                else
@@ -1207,25 +1203,12 @@ void HUD_Panel_Mouse()
                if(prevMouseClicked)
                        highlightedAction = 0;
                if(hud_configure_menu_open == 2)
-                       mouse_over_panel = 0;
+                       cursor_type = CURSOR_NORMAL;
                else
-                       mouse_over_panel = HUD_Panel_Check_Mouse_Pos(true);
-               if (mouse_over_panel && !tab_panel)
+                       cursor_type = HUD_Panel_Check_Mouse_Pos(true);
+               if (cursor_type != CURSOR_NORMAL && !tab_panel) // mouse over a panel?
                        drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
        }
-       // draw cursor after performing move/resize to have the panel pos/size updated before mouse_over_panel
-       float cursor_alpha = 1 - autocvar__menu_alpha;
-
-       if(!mouse_over_panel)
-               draw_cursor_normal(mousepos, '1 1 1', cursor_alpha);
-       else if(mouse_over_panel == 1)
-               draw_cursor(mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
-       else if(mouse_over_panel == 2)
-               draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize", '1 1 1', cursor_alpha);
-       else
-               draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize2", '1 1 1', cursor_alpha);
-
-       prevMouseClicked = mouseClicked;
 }
 void HUD_Configure_DrawGrid()
 {
@@ -1262,8 +1245,6 @@ void HUD_Configure_Frame()
 
                if(!hud_configure_prev)
                {
-                       if(autocvar_hud_cursormode)
-                               setcursormode(1);
                        hudShiftState = 0;
                        for(i = hud_panels_COUNT - 1; i >= 0; --i)
                                hud_panels_from(panel_order[i]).update_time = time;
@@ -1283,8 +1264,6 @@ void HUD_Configure_Frame()
        {
                if(hud_configure_menu_open)
                        hud_configure_menu_open = 0;
-               if(autocvar_hud_cursormode)
-                       setcursormode(0);
                hud_dynamic_shake_factor = -1;
        }
 }