]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Introduce proper constants for cursor types (while fixing compilation units)
authorterencehill <piuntn@gmail.com>
Tue, 7 Aug 2018 14:03:53 +0000 (16:03 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 7 Aug 2018 21:49:43 +0000 (23:49 +0200)
qcsrc/client/hud/hud.qh
qcsrc/client/hud/hud_config.qc
qcsrc/client/view.qc
qcsrc/client/view.qh

index d2db294bdce8ae04294c7f9f878da58dbfccdc07..679ec1416fd869b48d8401556e89372f116c7bf4 100644 (file)
@@ -8,6 +8,7 @@ void Hud_Dynamic_Frame();
 bool HUD_Radar_Clickable();
 void HUD_Radar_Mouse();
 bool HUD_WouldShowCursor();
+bool QuickMenu_IsOpened();
 
 REGISTRY(hud_panels, BITS(6))
 #define hud_panels_from(i) _hud_panels_from(i, NULL)
index f415d751223a695343ac503857f204c39e755d13..3043e6e6860d90a0673829688f681eff6fb44e0d 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"))
@@ -253,7 +254,7 @@ void HUD_Configure_Exit_Force()
                hud_configure_menu_open = 0;
                localcmd("togglemenu\n");
        }
-       mouse_over_panel = 0;
+       cursor_type = CURSOR_NORMAL;
        cvar_set("_hud_configure", "0");
 }
 
@@ -952,7 +953,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)
@@ -969,30 +970,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)
@@ -1147,7 +1148,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
@@ -1200,10 +1201,10 @@ 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);
        }
 }
index 27fa344b39cfa437321a303cfe3f732071e4caac..8c0eee4124ea4b0dce58acafc63f6b627e5ce4e0 100644 (file)
@@ -1555,17 +1555,16 @@ void ViewLocation_Mouse()
        //draw_cursor(viewloc_mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
 }
 
-float mouse_over_panel;
 void HUD_Draw_Mouse()
 {
        float cursor_alpha = 1 - autocvar__menu_alpha;
-       if(!mouse_over_panel)
+       if(cursor_type == CURSOR_NORMAL)
                draw_cursor_normal(mousepos, '1 1 1', cursor_alpha);
-       else if(mouse_over_panel == 1)
+       else if(cursor_type == CURSOR_MOVE)
                draw_cursor(mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
-       else if(mouse_over_panel == 2)
+       else if(cursor_type == CURSOR_RESIZE)
                draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize", '1 1 1', cursor_alpha);
-       else
+       else if(cursor_type == CURSOR_RESIZE2)
                draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize2", '1 1 1', cursor_alpha);
 }
 
index 93af4255e2b95570cd5ab278b22af71110b8368e..6b3fe4430ec360889a2226139aeda99eab3d0120 100644 (file)
@@ -15,3 +15,9 @@ void TrueAim_Init();
 entity viewmodels[MAX_WEAPONSLOTS];
 
 vector viewloc_mousepos;
+
+int cursor_type;
+const int CURSOR_NORMAL = 0;
+const int CURSOR_MOVE = 1;
+const int CURSOR_RESIZE = 2;
+const int CURSOR_RESIZE2 = 3;