Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Center GUI per screenwidth (https://forums.graalonline.com/forums/showthread.php?t=134268775)

sssssssssss 09-29-2013 10:37 PM

Center GUI per screenwidth
 
I'm having an extremely hard time centering a gui control per screenwidth, so when screen width changes it's still centered. I know the GraalControl resize, and I'm using it.

The problem is just finding how to center it. I can get it close to center, but then when I resize Graal's window it gets all screwed up, even with the same center script. I've tried a multitude of things, but this is the most recent....

PHP Code:

= (screenwidth getimgwidth("roak_mainmenu_backdrop1.png")) - 230

The above is a bit unnecessary, but again, I've tried many things, including just splitting screen width subtracting a number. It just keeps "offsetting" from center as I change Graal's window size.....

Am I missing something?

BlueMelon 09-29-2013 10:53 PM

Try this:
PHP Code:

= (screenwidth getimgwidth("roak_mainmenu_backdrop1.png")) / 2

Same goes for height.

sssssssssss 09-29-2013 11:05 PM

omg ty :)

I feel dumb.

Jakov_the_Jakovasaur 09-29-2013 11:11 PM

wouldnt getimgwidth(imagename) return 0 if the image file hasn't been downloaded yet?
or are you ensuring the image is pre-loaded?

cbk1994 09-29-2013 11:49 PM

Quote:

Originally Posted by Jakov_the_Jakovasaur (Post 1722954)
wouldnt getimgwidth(imagename) return 0 if the image file hasn't been downloaded yet?
or are you ensuring the image is pre-loaded?

Test it, but in the past, yes, it would return zero (but it would also trigger the downloading of the image, so you could keep trying it until it worked). If the image is not going to be changing much, you might as well just hardcode it as a constant in the script. Otherwise you'll have to wait for it to download (or if it's really important, you can force it to be pre-downloaded, e.g. via update packages or a script that triggers the download of certain images on login).

sssssssssss 09-30-2013 02:03 AM

I did end up putting it in a var. It does happen some times still it seems at least...


All times are GMT +2. The time now is 08:04 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.