harryh Posted April 30, 2014 Share Posted April 30, 2014 How do I do this. I currently have this which I got from the wiki but it doesn't work. As the GUI is off the screen. local sW, sH = guiGetScreenSize() showCursor(true) modwindow = guiCreateWindow(sW*442, sH*181, sW*506, sH*420, "Autoparts Modshop", false) Link to comment
K4stic Posted April 30, 2014 Share Posted April 30, 2014 because you do a big fail example if your screen sW is 1024 then sW*442 is same as 1024x442 the others values are same by same example i mean Link to comment
harryh Posted April 30, 2014 Author Share Posted April 30, 2014 because you do a big fail example if your screen sW is 1024 then sW*442 is same as 1024x442 the others values are same by same example i mean If you not going to help, please don't comment... I just looked at the wiki and thats what it said. Not my fault. Link to comment
-.Paradox.- Posted April 30, 2014 Share Posted April 30, 2014 (edited) The following will center gui on all resolutions local x, y = guiGetScreenSize() local Width = ( x - 541 )/2 local Height = ( y - 332 )/2 testWindow = guiCreateWindow(Width, Height, 541, 332, "test window", false) you can replace 541 and 332 with everything you want, i added them just for test Edited April 30, 2014 by Guest Link to comment
tosfera Posted May 1, 2014 Share Posted May 1, 2014 Easiest way to do this is using values between 0 and 1. As an example; local x, y = guiGetScreenSize(); testWindow = guiCreateWindow ( x * 0.4, y * 0.3, x * 0.2, y * 0.35, "test window", false ); This will create a window at the center of the screen, with a width of 0.2, and a height of 0.35. It will always look good on every screen! Link to comment
Moderators Citizen Posted May 1, 2014 Moderators Share Posted May 1, 2014 Easiest way to do this is using values between 0 and 1. As an example; local x, y = guiGetScreenSize(); testWindow = guiCreateWindow ( x * 0.4, y * 0.3, x * 0.2, y * 0.35, "test window", false ); This will create a window at the center of the screen, with a width of 0.2, and a height of 0.35. It will always look good on every screen! And the most easiest way to do this is using values between 0 and 1 AND not translating it in absolute values: testWindow = guiCreateWindow ( 0.4, 0.3, 0.2, 0.35, "test window", true) (And no need to use ; too) Link to comment
-.Paradox.- Posted May 1, 2014 Share Posted May 1, 2014 I think the problem is already solved, I tested my code and it's working... Link to comment
Moderators Citizen Posted May 1, 2014 Moderators Share Posted May 1, 2014 I think the problem is already solved, I tested my code and it's working... It wasn't about the the resolution of his problem, it's about to let you guys know relative values doesn't need to be translated in absolute ones when using gui functions. It just add code that is already written in the original functions ... (And it's not because your solution is working that it's a good solution ...) Link to comment
harryh Posted May 1, 2014 Author Share Posted May 1, 2014 I think the problem is already solved, I tested my code and it's working... It wasn't about the the resolution of his problem, it's about to let you guys know relative values doesn't need to be translated in absolute ones when using gui functions. It just add code that is already written in the original functions ... (And it's not because your solution is working that it's a good solution ...) How do you know where 0.4, 0.8 etc etc. will be on the screen? Link to comment
lLinux Posted May 2, 2014 Share Posted May 2, 2014 How do I do this. I currently have this which I got from the wiki but it doesn't work. As the GUI is off the screen. local sW, sH = guiGetScreenSize() showCursor(true) modwindow = guiCreateWindow(sW*442, sH*181, sW*506, sH*420, "Autoparts Modshop", false) Use your resolution, example: your resolution is 1366 x 768 (Is mine) local sW, sH = guiGetScreenSize() showCursor(true) modwindow = guiCreateWindow((442/1366)*sW, (181/768)*sH, (506/1366)*sW, (420/768)*sH, "Autoparts Modshop", false) Sorry for my bad English 1 Link to comment
Moderators Citizen Posted May 2, 2014 Moderators Share Posted May 2, 2014 I think the problem is already solved, I tested my code and it's working... It wasn't about the the resolution of his problem, it's about to let you guys know relative values doesn't need to be translated in absolute ones when using gui functions. It just add code that is already written in the original functions ... (And it's not because your solution is working that it's a good solution ...) How do you know where 0.4, 0.8 etc etc. will be on the screen? It's really simple but maybe hard to get it at the begining. So here is what you have to know: on the horizontal axis: 0 (0%) is the left side of your screen (of every screens) and 1(100%) is the right side of your screen (of every screens too). on the vertical axis: 0 (0%) is the top side of your screen (of every screens) and 1 (100%) is the bottom side of your screen (of every screens too). So instead of using pixels to place and size your gui elements (which will not be rendered the same on every resolutions) then you use percentages of the screen. The gui elements are placed using the top left corner of that gui element. So if you place it at 1, 1 (100%, 100%) then your gui element will be rendered out of the screen. So to place it correctly at the bottom right corner, you have to use: 100 - , 100 - So as another example, if you wan to create a window pefectly centered on every screens: guiCreateWindow(50% - 30%/2, 50% - 40%/2, 30%, 40%, "My window", true) --just for comprehension -- so: guiCreateWindow(0.5 - 0.15, 0.5 - 0.2, 0.3, 0.4, "My window", true) -- will work guiCreateWindow(0.5 - 0.15, 0.5 - 0.2, 0.3, 0.4, "My window", true) -- will work too Note: 0.5 = 50% 0.15 is half of 0.3 0.2 is half of 0.4 Link to comment
harryh Posted May 3, 2014 Author Share Posted May 3, 2014 How can I get the position of top right corner of screen? Link to comment
Grim_The_X_Reaperr Posted May 3, 2014 Share Posted May 3, 2014 BLAH And the most easiest way to do this is using values between 0 and 1 AND not translating it in absolute values: testWindow = guiCreateWindow ( 0.4, 0.3, 0.2, 0.35, "test window", true) (And no need to use ; too) i think he just added that out of habbit from doing C# or C ++ Link to comment
Moderators Citizen Posted May 3, 2014 Moderators Share Posted May 3, 2014 How can I get the position of top right corner of screen? If you had read and understand what I just wrote, then you would find out by yourself... If you want to place a window of size 20% ,30% (width and height) at the top right corner for every resolutions: x: 100% - 20%/2 means the right side of the screen y: 0% means the top side of your screen width: 20% height: 30% 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