EQ2Interface

EQ2Interface (https://www.eq2interface.com/forums/index.php)
-   XML Modification Help & Info (https://www.eq2interface.com/forums/forumdisplay.php?f=22)
-   -   Keep Examine windows on screen (https://www.eq2interface.com/forums/showthread.php?t=16599)

Drumstix42 08-16-2012 04:22 PM

Keep Examine windows on screen
 
I've grown tired of Examine window popups showing partially offscreen (or in some cases completely off screen) when they get displayed.

I came up with a little code to check if the window is off the screen on all 4 edges: top, right, bottom & left. If it is found to be offscreen, it will be centered on the axis that it is off-screen, or both. If the window is actually taller/wider than the screen's resolution for whatever reason, it will simply be placed at the top or left of the screen so the title is visible.

Code:

gHeight=Parent.Parent.Height
gWidth=Parent.Parent.Width

iTop=Parent.Top
iBottom=(iTop + Parent.Height)
iLeft=Parent.Left
iRight=(iLeft + Parent.Width)

iNewTop=(gHeight - Parent.Height)
iNewTop=(iNewTop / 2)
iNewTop=int(iNewTop)
iNewTopPos=(iNewTop > 0)
iNewTop=(iNewTopPos ? iNewTop : 1)

bCheckTop=(iTop < 0)
bCheckBottom=(iBottom > gHeight)
bCheckVertical=(bCheckTop || bCheckBottom)
Parent.Top=(bCheckVertical ? iNewTop : iTop)

iNewLeft=(gWidth - Parent.Width)
iNewLeft=(iNewLeft / 2)
iNewLeft=int(iNewLeft)
iNewLeftPos=(iNewLeft > 0)
iNewLeft=(iNewLeftPos ? iNewLeft : 1)

bCheckLeft=(iLeft < 0)
bCheckRight=(iRight > gWidth)
bCheckHorizontal=(bCheckLeft || bCheckRight)
Parent.Left=(bCheckHorizontal ? iNewLeft : iLeft)

Can put this in the OnShow of each Examine window (Item, Spell, etc), or make a button that gets pressed OnShow of each window.
It took a few more lines of code to "center" the window, but I figured it looked cleaner than just setting it to the very top or left.

Below is the same code commented just for sake of knowing what each segment does without figuring it out:

Code:

gHeight=Parent.Parent.Height // global height (resoultion of in-game window)
gWidth=Parent.Parent.Width // global width (resoultion of in-game window)

iTop=Parent.Top // Top position of window
iBottom=(iTop + Parent.Height) // Bottom position of window
iLeft=Parent.Left // Left position of window
iRight=(iLeft + Parent.Width) // Right position of window

// Attempt to center window on Y-axis
iNewTop=(gHeight - Parent.Height)
iNewTop=(iNewTop / 2)
iNewTop=int(iNewTop)
iNewTopPos=(iNewTop > 0) // did it end up off screen because too tall?
iNewTop=(iNewTopPos ? iNewTop : 1) // if too high, set Top to 1

bCheckTop=(iTop < 0) // Off top of screen?
bCheckBottom=(iBottom > gHeight) // Off bottom of screen?
bCheckVertical=(bCheckTop || bCheckBottom) // Final check for the Y-axis
Parent.Top=(bCheckVertical ? iNewTop : iTop) // Set new location, or keep old location

// Attempt to center window on X-axis
iNewLeft=(gWidth - Parent.Width)
iNewLeft=(iNewLeft / 2)
iNewLeft=int(iNewLeft)
iNewLeftPos=(iNewLeft > 0) // did it end up off screen because too wide?
iNewLeft=(iNewLeftPos ? iNewLeft : 1) // if too far left, set Left to 1

bCheckLeft=(iLeft < 0) // Off left of screen?
bCheckRight=(iRight > gWidth) // Off right of screen?
bCheckHorizontal=(bCheckLeft || bCheckRight) // Final check for X-axis
Parent.Left=(bCheckHorizontal ? iNewLeft : iLeft) // Set new location, or keep old location


lordebon 08-16-2012 07:05 PM

Nice. The examine window off screen bug never seems to get fixed, so this should be an ideal workaround.


All times are GMT -5. The time now is 04:27 PM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI