From bd4a219833bb16f5d868ab954ee1f2d9b4c882fd Mon Sep 17 00:00:00 2001 From: FruitieX Date: Mon, 14 Jun 2010 15:40:21 +0300 Subject: [PATCH] resize mostly works in a sane way now, can almost enable by default. If bottom of panel A touches the top of panel B, and you try to resize panel A upwards it'll still fail a lot --- qcsrc/client/hud.qc | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 3a30921b6..8afffe252 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -1028,13 +1028,10 @@ void HUD_Panel_SetPos(float id, vector pos) } // check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector -vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize) +vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize, vector resizeorigin) { float i; - vector myTarget; - myTarget = mySize; - vector targPos; vector targSize; vector myCenter; @@ -1046,9 +1043,6 @@ vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize) if(i == id || !HUD_Panel_CheckActive(i)) continue; - targPos = HUD_Panel_GetPos(i); - targSize = HUD_Panel_GetSize(i); - targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id); targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id); @@ -1073,40 +1067,39 @@ vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize) if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of target panel) { if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side - myTarget_x = targPos_x - myPos_x; + mySize_x = targPos_x - myPos_x; else // push it upwards - myTarget_y = targPos_y - myPos_y; + mySize_y = targPos_y - resizeorigin_y; } else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right { if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side - myTarget_x = targPos_x + targSize_x; + mySize_x = resizeorigin_x - (targPos_x + targSize_x); else // push it upwards - myTarget_y = targPos_y - myPos_y; + mySize_y = targPos_y - resizeorigin_y; } else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left { if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side - myTarget_x = targPos_x - myPos_x; + mySize_x = targPos_x - resizeorigin_x; else // push it downwards - myTarget_y = targPos_y + targSize_y; + mySize_y = resizeorigin_y - (targPos_y + targSize_y); } else if(myCenter_x > targCenter_x && myCenter_y > targCenter_y) // bottom right { if(targPos_x + targSize_x - myPos_x < targPos_y + targSize_y - myPos_y) // push it to the side - myTarget_x = targPos_x + targSize_x; + mySize_x = resizeorigin_x - (targPos_x + targSize_x); else // push it downwards - myTarget_y = targPos_y + targSize_y; + mySize_y = resizeorigin_y - (targPos_y + targSize_y); } } - return myTarget; + return mySize; } void HUD_Panel_SetPosSize(float id, vector resizeorigin) { vector mySize, myPos; - vector oldPos; if(resizeCorner == 1) { mySize_x = resizeorigin_x - (mousepos_x - panel_click_distance_x); @@ -1165,12 +1158,8 @@ void HUD_Panel_SetPosSize(float id, vector resizeorigin) mySize_x = min(vid_conwidth - myPos_x, mySize_x); mySize_y = min(vid_conheight - myPos_y, mySize_y); - if(cvar("hud_configure_checkcollisions")) { - oldPos = myPos; - mySize = HUD_Panel_CheckResize(id, myPos, mySize); - myPos = HUD_Panel_CheckMove(id, myPos, mySize); // touching myPos won't do anything... unless we make it change mySize somehow, see next line - mySize = mySize - myPos + oldPos; // TODO: this is still borked in some situations :( - } + if(cvar("hud_configure_checkcollisions")) + mySize = HUD_Panel_CheckResize(id, myPos, mySize, resizeorigin); if(cvar("hud_configure_grid")) { -- 2.39.2