Jump to content

[QUESTION] How to make GUI elements fit every resolution?


koragg

Recommended Posts

I already know how to fix dxDrawText functions for any resolution but is it possible to make the same for GUI windows? I have, for example, a map shop but it's ok only on my resolution (FHD). How can I make it rescale itself properly on smaller/bigger resolutions so that it will always be in the same spot and the same size on any screen resolution? I tried the same way as I did for dxDrawText but it doesn't work as good. Partially it works but not good enough.

Link to comment

Hello. Now... guis have a Relative argument, but that's :~ty, so DO NOT use it. Instead, you can do it like:

local sx, sy = guiGetScreenSize()

guiCreateWindow(sx*0.5, sy*0.5, sx*0.2, sy*0.2, "Window", false)

This makes your gui's TOP LEFT CORNER be at the screen's 50% at width and height too, and your gui's size will be 20% of the screen at width and height as well. IMPORTANT: if you use this technique, make sure that the relative argument is set to FALSE.

Edited by StormFighter
I made some mistakes
Link to comment
20 minutes ago, StormFighter said:

Hello. Now... guis have a Relative argument, but that's :~ty, so DO NOT use it. Instead, you can do it like:


local sx, sy = guiGetScreenSize()

guiCreateWindow(sx*0.5, sy*0.5, sx*0.2, sy*0.2, "Window", false)

This makes your gui's TOP LEFT CORNER be at the screen's fifth percent at width and height too, and your gui's size will be 2% of the screen at width and height as well. IMPORTANT: if you use this technique, make sure that the relative argument is set to FALSE.

That's basically the same as a relative GUI and something * 0.2 = 20%, not 2%.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...