• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

display_set_gui_size mouseover

K

kABUSE

Guest
I want a game that works in all resolutions but I want 16:9 to be used for the menu buttons, while the room and window itself still have the custom resolution (NO black bars)

So I prepare all menus in my game in 3840x2160.

They are then scaled down to the users desired resolution while keeping the 16:9 aspect ratio.

The If clause in the code below determines the new aspect ratio and compares it to 16:9. First case for aspect ratios where the height is lower than 16:9 (for example 1920x1079, 2000x800 etc.) else case for the height being equal to or higher than 16:9 (1920x1080+, 1280x1024 etc.)

It works fine. gui_x_offset and gui_y_offset is the number of pixels, the menu buttons need to be moved to be centered.

mouse_x_converter and mouse_y_converter are the things in question. They are supposed to be used to convert to the actual mouse position after applying display_set_gui_size, as all mouse-over events are broken (mouse_x and mouse_y are not scaled with display_set_gui_size).


Code:
        if ((3840/view_wport[0])*view_hport[0] < 2160)
        {
        display_set_gui_size(2160*aspectratio,2160);
        gui_x_offset = ((2160*aspectratio)-3840)/2;
        gui_y_offset = 0;

        mouse_x_converter = ???
        mouse_y_converter = 1
        }
        else
        {
        display_set_gui_size(3840,3840/aspectratio);
        gui_x_offset = 0;
        gui_y_offset = ((3840/aspectratio)-2160)/2;

        mouse_x_converter = 1
        mouse_y_converter = ???
        }
It looks like this in 3840x2160 (16:9):


It looks like this in 3000x1000 (27:9)


It looks like this in 1000x1000 (1:1)


This looks EXACTLY how I wanted it to be.

But for the love of god, I can't get the mouseover-part of the menu buttons working after I have used display_set_gui_size.

I am using the following to determine mouseover for the buttons and I am trying hard to get a working formula for mouse_x_converter/mouse_y_converter:

Code:
if (mouse_x * mouse_x_converter < (x + width/2)) && (mouse_x * mouse_x_converter > (x - width/2)) && (mouse_y * mouse_y_converter < (y + (height)/2)) && (mouse_y * mouse_y_converter > (y - height/2))
{
mouseover = true
}
else
{
mouseover = false
}
This is the closest estimate I have gotten for mouse_y using trial and error, mspaint and countless calculations but it's still several pixels off for many resolutions:
Code:
mouse_y_converter = (2160/(2160-(gui_y_offset*2) / 16 * 9))
Please help me. I am stuck with this for days. Is there maybe a built-in way to determine button-mouseover after applying display_set_gui_size?

All help is greatly appreciated.
 
Last edited by a moderator:
T

TimothyAllen

Guest
that are mouse functions that give you the mouse position with respect to the GUI. Use those.
 
K

kABUSE

Guest
device_mouse_x_to_gui and device_mouse_y_to_gui fixed this instantly.


💩💩💩💩 my life... and I have wasted the entire day to fix this.



Thanks TimothyAllen, you are great, as always. This was like the 4th time you've saved my ass.
 
Top