]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
In case the clicked panel is inside another panel and we aren't moving it, avoid...
authorterencehill <piuntn@gmail.com>
Sun, 22 Aug 2010 22:42:59 +0000 (00:42 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 22 Aug 2010 22:42:59 +0000 (00:42 +0200)
Thanks to this change, ctrl-z code is now less complicated and don't suffer of a bug in the above described situation

qcsrc/client/hud.qc

index 563de31a15f7726c1c341ad87701aa1cbd75393e..5c69b9f7f6666fe06287a31eafab79c7affce78d 100644 (file)
@@ -1306,7 +1306,7 @@ void HUD_Panel_Highlight()
 }
 
 float highlightcheck;
-float would_backup;
+vector prev_pos, prev_size;
 void HUD_Panel_Mouse()
 {
        // TODO: needs better check... is there any float that contains the current state of the menu? _menu_alpha isn't apparently updated the frame the menu gets enabled
@@ -1335,22 +1335,29 @@ void HUD_Panel_Mouse()
 
        if(mouseClicked)
        {
-               vector prev_pos, prev_size;
                if(prevMouseClicked == 0)
                {
                        HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
                                                                        // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
-                       would_backup = TRUE;
-               }
-               else if (would_backup)
-               {
-                       // this is not the actual backup! Saving pos and size values
-                       // only to check later if they are different from new values
                        prev_pos = panel_pos;
                        prev_size = panel_size;
                }
+               else
+                       HUD_Panel_UpdatePosSizeForId(highlightedPanel)
 
-               hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
+               if (prev_pos != panel_pos || prev_size != panel_size)
+               {
+                       hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
+                       // backup!
+                       panel_pos_backup = prev_pos;
+                       panel_size_backup = prev_size;
+                       highlightedPanel_backup = highlightedPanel;
+               }
+               else
+                       // in case the clicked panel is inside another panel and we aren't
+                       // moving it, avoid the immediate "fix" of its position/size
+                       // (often unwanted and hateful) by disabling collisions check
+                       hud_configure_checkcollisions = false;
 
                if(highlightedAction == 1)
                        HUD_Panel_SetPos(mousepos - panel_click_distance);
@@ -1373,18 +1380,6 @@ void HUD_Panel_Mouse()
                        HUD_Panel_SetPosSize(mySize);
                }
 
-               HUD_Panel_UpdatePosSizeForId(highlightedPanel)
-               if (prevMouseClicked)
-               if (would_backup)
-               if (prev_pos != panel_pos || prev_size != panel_size)
-               {
-                       // backup!
-                       panel_pos_backup = prev_pos;
-                       panel_size_backup = prev_size;
-                       highlightedPanel_backup = highlightedPanel;
-                       would_backup = FALSE;
-               }
-
                // doubleclick check
                if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
                {