]> 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)
committerFruitieX <rasse@rasse-lappy.localdomain>
Tue, 29 Jun 2010 08:07:11 +0000 (11:07 +0300)
They are used to decide which side limits the resizing, not to keep the aspect ratio.

qcsrc/client/hud.qc

index 41440c6d180c3d6cba9cf5ac676b7912cdd23e69..19932a3ec29d40e0c6d9a51c386604c02dbd2189 100644 (file)
@@ -913,7 +913,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))
@@ -925,7 +928,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)
@@ -948,7 +951,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);
@@ -966,7 +969,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);
@@ -984,7 +987,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);
@@ -1002,7 +1005,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);