Backsage Posted July 31, 2016 Share Posted July 31, 2016 Well, I am trying to create a window and I want it to scale properly on all resolutions. I tried using TEDERI's method, but it won't scale properly. I tried previewing it in different resolutions, but it doesn't scale. https://forum.multitheftauto.com/viewto ... 91&t=33149 http://pastebin.com/3N8Jb3iq Link to comment
Bonus Posted August 1, 2016 Share Posted August 1, 2016 I'll show you an example local sW, sH = guiGetScreenSize() local sx, sy = sW/1920, sH/1080 addEventHandler ( "onClientRender", root, function ( ) dxCreateRectangle ( sW*0.5 - 50*sx, sH*0.5 - 50*sy, 100*sx, 100*sy, tocolor ( 255, 0, 0 ), true ) end ) This rectangle will have the same scale in every resolution. But in your code: sW*0.5-481/2 sW*0.5 is good, but 481/2 will be different in every resolution. local sW, sH = guiGetScreenSize() local sx, sy = sW/1920, sH/1080 GUIEditor.window[1] = guiCreateWindow(sW*0.5-481/2*sx, sH*0.5-412/2*sy, 481*sy, 412*sy, "", false) This will solve your problem Link to comment
Backsage Posted August 2, 2016 Author Share Posted August 2, 2016 Where did you get 1920 and 1080? I know it's a resolution, but why you chose those numbers? I tried pasting the code into gui editor, but nothing appeared. Link to comment
Bonus Posted August 2, 2016 Share Posted August 2, 2016 Its my own resolution. Use your own resolution. Link to comment
G-Stefan Posted August 8, 2016 Share Posted August 8, 2016 Well, I am trying to create a window and I want it to scale properly on all resolutions. I tried using TEDERI's method, but it won't scale properly. I tried previewing it in different resolutions, but it doesn't scale.https://forum.multitheftauto.com/viewto ... 91&t=33149 http://pastebin.com/3N8Jb3iq So if you want to create an element im the middle of the screen this might help you local screenW, screenH = guiGetScreenSize() local elemW, elemH = 300,400 --Your element width and height function testWindow() local theWindow = guiCreateWindow( (screenW - elemW)/2,(screenH-elemH)/2,elemW,elemH,"Test") end addEventHandler("onClientResourceStart, getRootElement(),testWindow) The formula to make a GUI elem in the middle of the screen is guiCreate(yourElement)( (screenWidth - elementWidth)/2,(screenHeight - elementHeight)/2,screenWidth,screenHeight,...) Link to comment
N3xT Posted August 8, 2016 Share Posted August 8, 2016 for gui, you can use this useful function centerWindow Link to comment
G-Stefan Posted August 8, 2016 Share Posted August 8, 2016 for gui, you can use this useful functioncenterWindow Is the thing i said made in a function Link to comment
Backsage Posted August 25, 2016 Author Share Posted August 25, 2016 Well, I am trying to create a window and I want it to scale properly on all resolutions. I tried using TEDERI's method, but it won't scale properly. I tried previewing it in different resolutions, but it doesn't scale.https://forum.multitheftauto.com/viewto ... 91&t=33149 http://pastebin.com/3N8Jb3iq So if you want to create an element im the middle of the screen this might help you local screenW, screenH = guiGetScreenSize() local elemW, elemH = 300,400 --Your element width and height function testWindow() local theWindow = guiCreateWindow( (screenW - elemW)/2,(screenH-elemH)/2,elemW,elemH,"Test") end addEventHandler("onClientResourceStart, getRootElement(),testWindow) The formula to make a GUI elem in the middle of the screen is guiCreate(yourElement)( (screenWidth - elementWidth)/2,(screenHeight - elementHeight)/2,screenWidth,screenHeight,...) All this does is center it to the screen. I'm talking about making it actually scale based on the resolution. How is it that this only works when using relative values, but not for absolute values? If I use the relative argument, I have to do that on every single GUI element that's on the window, including the window, so that it'll scale properly. I can't just do it for the window or else the other GUI elements will be too big. I hope you understand what I mean. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now