Quantcast Keep Examine windows on screen - EQ2Interface
EQ2Interface.com
Search Downloads


Go Back   EQ2Interface > Developer Discussion > XML Modification Help & Info

Reply
Thread Tools Search this Thread Display Modes
  #1  
Unread 08-16-2012, 04:22 PM
Drumstix42's Avatar
Drumstix42 Drumstix42 is offline
A Griffon
Featured
 
Join Date: Oct 2004
Server: Antonia Bayle
Posts: 3,284
Send a message via AIM to Drumstix42 Send a message via MSN to Drumstix42 Send a message via Yahoo to Drumstix42
Default 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
__________________
"I'm afraid you're guilty of thought-crime. Don't bother getting the door, we'll let ourselves in..."
<Donate to DrumsUI> < [DrumsUI] Updater > < [DrumsUI] Full Interface> < Drumstix42 on Twitch.tv
>

Last edited by Drumstix42 : 08-16-2012 at 04:37 PM.
Reply With Quote
  #2  
Unread 08-16-2012, 07:05 PM
lordebon lordebon is offline
Fetish Core author
This person is a EQ2Map developer.
Featured
 
Join Date: Jun 2005
Server: Antonia Bayle
Posts: 2,653
Default

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:12 AM.


Our Network
EQInterface | EQ2Interface | War.MMOUI | WoWInterface | VGInterface | LoTROInterface | MMOInterface