Jump to content

Resolution problem


naotriix

Recommended Posts

Hello,

I have a problem with resolution on my server, i use resolution 1920 x 1080 and i have this result:

http://www.casimages.com/i/14111905024020354.png

http://www.casimages.com/i/141119050238131537.png

But i have players who use 800 x 600 and have this result:

http://www.casimages.com/i/141119050144969278.png

http://www.casimages.com/i/141119050233578220.png

On the 800 x 600 time left time passed too much big and can't see all the menu on the userpanel.

How i can fix that ?

Link to post

Divide the width/height with the source resolution, and then multiply it by their resolution.

For example;

local screenX, screenY = guiGetScreenSize(); -- This will get the player's resolution, 800x600 in their case - 1920x1080 in your case. 

Now, lets say you made something that is 600 pixel wide and 300 pixels high. And you created this while on a 1920x1080 resolution, you would do;

exampleWidth = (600/1920)*screenX; 
exampleHeight = (300/1080)*screenY; 

This would make the size relative, instead of absolute. Do note however, that this solution does not always work. You will particularly notice this with text.

Edit:

To further demonstrate, this is what it should look like;

local screenX, screenY = guiGetScreenSize(); 
  
function dxAbsoluteExampleWindow_Handler() 
    dxDrawRectangle(480, 240, 969, 570, tocolor(35, 35, 35, 255), false); 
    dxDrawRectangle(480, 240, 969, 47, tocolor(55, 55, 55, 255), false); 
    dxDrawText("Example DX Window", 485, 244, 1442, 281, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false); 
end 
  
function dxRelativeExampleWindow_Handler() 
    dxDrawRectangle(0.25*screenX, 0.22222222222222*screenY, 0.5046875*screenX, 0.52777777777778*screenY, tocolor(35, 35, 35, 255), false); 
    dxDrawRectangle(0.25*screenX, 0.22222222222222*screenY, 0.5046875*screenX, 0.043518518518519*screenY, tocolor(55, 55, 55, 255), false); 
    dxDrawText("Example DX Window", 0.25260416666667*screenX, 0.22592592592593*screenY, 0.75104166666667*screenX, 0.26018518518519*screenY, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false); 
end 

I use a website where you can run Lua code to make the process very fast and straight forward, since doing it all manually is a very tedious process. Especially with DX functions.

Simply paste this code(into the website linked above) and enter the appropriate values. Then copy the output and you're golden.

local sX, sY, wX, hY = 480, 240, 969, 570; -- Paste the absolute values here 
local sourceWidth = 1920;    -- Change those to the source values. 
local sourceHeight = 1080;   -- Change those to the source values. 
local nSX, nSY, nWX, nHY = (sX/sourceWidth), (sY/sourceHeight), (wX/sourceWidth), (hY/sourceHeight); 
  
for i=0, 47 do 
   print(""); -- This is just to clear the print window, so you don't confused what to copy. 
end 
  
print(tostring(nSX).."*screenX, "..tostring(nSY).."*screenY, "..tostring(nWX).."*screenX, "..tostring(nHY).."*screenY"); 

Link to post

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