Jump to content

Question related to GUI's and dxDraw's.


Dreft

Recommended Posts

How to make GUI's and dxDraw's that they fit to different screens ?

I know that I need to use guiGetScreenSize, but I don't know how to calculate to correct values..

For example, if on 800x600 screen I create GUI which is on top of the corner, on 1280x1024 screen it won't be there, it will be lower. Is there some formula which can be used when calculating correct GUI's and dxDraw's coordinates to find, for different screen resolutions ?

Link to comment

gui functions have a relative parameter, when you set that to true it will create the elements in relative sizes to the users screen, for dx functions you can simply use basic maths knowledge. for example to get something appear in the middle of the screen you could do

local sx,sy = guiGetScreenSize()
local sizex,sizey = 200,100
local posx = 0.5*sx-0.5*sizex
local posy = 0.5*sy-0.5*sizey

on a side note i don't recommend the relative parameter of gui functions, in best case just don't create windows which are too big for small resolutions, or check the resolution and create a matching window for all sizes separately

Link to comment

i'd make it like this:

screenX, screenY = guiGetScreenSize()
mX, mY = screenX/800, screenY/600
 
--and then multiply your x/y values that you have for 800x600 to fit current resolution
dxDrawImage(50*mX, 100*mY, ...

i'm not sure if you have to round them though for dx functions.

Link to comment
<..>for dx functions you can simply use basic maths knowledge. for example to get something appear in the middle of the screen you could do
local sx,sy = guiGetScreenSize()
local sizex,sizey = 200,100
local posx = 0.5*sx-0.5*sizex
local posy = 0.5*sy-0.5*sizey

Hm..

dxDrawText( "someText", 102.0,236.0,1086.0,306.0,tocolor(r,g,b,a),2.0,"pricedown","center","center",false,false,false)

This writing text in ~center of the screen, but near top.

If I do:

local sx,sy = guiGetScreenSize()
local sizex,sizey = 1086,306
local posx = 0.5*sx-0.5*sizex
local posy = 0.5*sy-0.5*sizey
dxDrawText( "someText", 102.0,236.0,posx,posy,tocolor(r,g,b,a),2.0,"pricedown","center","center",false,false,false)

Then text appears on the right(or left, i don't remember) on my screen :\ What I'm doing wrong ?

Link to comment
in this case you can simply use this:
local sx,sy = guiGetScreenSize()
local r,g,b,a = 255,255,255,255
local topoffset = 25
dxDrawText("someText",0,topoffset,sx,sy,tocolor(r,g,b,a),2.0,"pricedown","center","top",false,false,false)

Thanks a lot :)

Link to comment
in this case you can simply use this:
local sx,sy = guiGetScreenSize()
local r,g,b,a = 255,255,255,255
local topoffset = 25
dxDrawText("someText",0,topoffset,sx,sy,tocolor(r,g,b,a),2.0,"pricedown","center","top",false,false,false)

Erm, this always draw text at the center, but what if I want that text appear in some other place, for example top, right corner ?

Link to comment

with dxDraws everything Ok. But now I have problem with GUI windows.

this is my GUI:

Window = guiCreateWindow(0.3398,0.7591,0.327,0.1657,"Pasirinkite isvaizda | Choose skin",true)
guiSetAlpha(Window,0.69999998807907)
guiWindowSetMovable(Window,false)
guiWindowSetSizable(Window,false)
Left_Button = guiCreateButton(17,29,66,43,"<<<",false,Window)
Right_Button = guiCreateButton(248,29,66,43,">>>",false,Window)
EditBox = guiCreateEdit(89,32,56,36,"123",false,Window)
guiEditSetMaxLength(EditBox,3)
OK_Button = guiCreateButton(149,35,50,29,"OK",false,Window)
Confirm_Button = guiCreateButton(33,86,265,29,"PATVIRTINTI | APPLY",false,Window)

This is how it looks on 1024x768 screen(It's correct, everything there, where it need to be) - http://pics.lt/images/mta-screen%202010 ... -13-23.png

This is how it looks on 1280x1024 screen(It's not correct, window is too big :/) - http://pics.lt/images/mta-screen%202010 ... -14-16.png

Is there anything I can do, that on 1024x768 and 1280x1024 GUI will be in same place and same size ?

EDIT: NVM, fixed :)

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...