]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Put back checks of ratio in CheckResize algorithm.
authorterencehill <piuntn@gmail.com>
Sun, 20 Jun 2010 13:11:46 +0000 (15:11 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 20 Jun 2010 13:11:46 +0000 (15:11 +0200)
They are used to decide which side limits the resizing, not to keep the aspect ratio.

qcsrc/client/hud.qc

index 9a8059e84cd4108cf870bd614f1dbbb0bdbcb621..6e5e897575d11e47415910bca0963a2418a130f9 100644 (file)
@@ -1005,7 +1005,10 @@ vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
        vector targPos;
        vector targSize;
        vector targEndPos;
+
        vector dist;
+       float ratio;
+       ratio = mySize_x/mySize_y;
 
        for (i = 0; i < HUD_PANEL_NUM; ++i) {
                if(i == id || !HUD_Panel_CheckActive(i))
@@ -1017,7 +1020,7 @@ vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
                targEndPos = targPos + targSize;
 
                // resizeorigin is WITHIN target panel, just abort any collision testing against that particular panel to produce expected behaviour!
-               if(resizeorigin_x > targPos_x && resizeorigin_x < targPos_x + targSize_x && resizeorigin_y > targPos_y && resizeorigin_y < targPos_y + targSize_y)
+               if(resizeorigin_x > targPos_x && resizeorigin_x < targEndPos_x && resizeorigin_y > targPos_y && resizeorigin_y < targEndPos_y)
                        continue;
 
                if (resizeCorner == 1)
@@ -1040,7 +1043,7 @@ vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
                        // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
                        dist_x = resizeorigin_x - targEndPos_x;
                        dist_y = resizeorigin_y - targEndPos_y;
-                       if (dist_y < 0)
+                       if (dist_y < 0 || dist_x / dist_y > ratio)
                                mySize_x = min(mySize_x, dist_x);
                        else
                                mySize_y = min(mySize_y, dist_y);
@@ -1058,7 +1061,7 @@ vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
 
                        dist_x = targPos_x - resizeorigin_x;
                        dist_y = resizeorigin_y - targEndPos_y;
-                       if (dist_y < 0)
+                       if (dist_y < 0 || dist_x / dist_y > ratio)
                                mySize_x = min(mySize_x, dist_x);
                        else
                                mySize_y = min(mySize_y, dist_y);
@@ -1076,7 +1079,7 @@ vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
 
                        dist_x = resizeorigin_x - targEndPos_x;
                        dist_y = targPos_y - resizeorigin_y;
-                       if (dist_y < 0)
+                       if (dist_y < 0 || dist_x / dist_y > ratio)
                                mySize_x = min(mySize_x, dist_x);
                        else
                                mySize_y = min(mySize_y, dist_y);
@@ -1094,7 +1097,7 @@ vector HUD_Panel_CheckResize(float id, vector mySize, vector resizeorigin) {
 
                        dist_x = targPos_x - resizeorigin_x;
                        dist_y = targPos_y - resizeorigin_y;
-                       if (dist_y < 0)
+                       if (dist_y < 0 || dist_x / dist_y > ratio)
                                mySize_x = min(mySize_x, dist_x);
                        else
                                mySize_y = min(mySize_y, dist_y);