overhotspot at the margins

Started by kantor_98, Thu 31/08/2006 14:23:24

Previous topic - Next topic

kantor_98

I use a GUI with @overhotspot@ for the display of different areas, objects, etc. But if the object is close to one of the margins (especially in the right margin) the GUI is only partial displayed. How can I make a script to move the GUI in the left part of the mouse if I am to close to the margin ?

Alynn

How I do this is I check the mouse position if it is higher than the middle of the screen it displays the gui below the cursor. If the mouse position is lower than the middle of the screen it displays to the top of the cursor. And the same with the left and right sides.

Easiest way to do this is a check in your repeatedly_execute for the game (if you want this behavior when your popup guis are up then you can place it in your Rep Ex Always)

Psudocode
int guiPosY;
int guiPosX;
if (mouse.y > Screen.Height/2) guiPosY = mouse.y - 10;
else guiPosY = mouse.y+10;
if (mouse.x > Screen.Width/2) guiPosX = mouse.x -10;
else guiPosX = mouse.x+10;

SetGuiPosition(gDescription, guiPosX, guiPosY);

And that should do what you want (and by psudocode I mean this is generally how you do it, you need to actually use the real script code to make it work correctly).

Ishmael

I always do it by checking if the mouse distance from the right edge is greater than the screen width, and if so, substract the GUI width from the screen width and use that value as the X co-ordinate. Same for the bottom, but with height and Y-co-ordinate.

And I have a GUI that changes width according to the text that's in it, that is.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

SMF spam blocked by CleanTalk