Jump to content

[HELP] How to fit dx elements to all resolution?


Tokio

Recommended Posts

  • Moderators
1 hour ago, Tokio said:

What wrong??? How can i fix this problem??

Absolute values like 290px and 240px do not scale, without a multiplier.

 

There is a tutorial for scaling DX (+useful for other user interfaces).

 

Link to comment
  • Moderators
6 minutes ago, Tokio said:

uhm, what is multiplier?

It is nothing magic. Just a value you use to multiply another value, so it gets bigger, smaller or unchanged.

 

local bananas = 100

local multiplier = 0.5 -- = 50%


bananas = bananas * multiplier

print(bananas) -- 50 bananas

 

 

 

 

 

Edited by IIYAMA
  • Haha 1
Link to comment
12 hours ago, IIYAMA said:

It is nothing magic. Just a value you use to multiply another value, so it gets bigger, smaller or unchanged.

 


local bananas = 100

local multiplier = 0.5 -- = 50%


bananas = bananas * multiplier

print(bananas) -- 50 bananas

 

 

 

 

 

I used a multiplier but didn't help much

Link to comment
6 hours ago, IIYAMA said:

I did send you a tutorial in my last reply, so I assume you did read it and applied it to you code?

This one.

Well show me what you did.

The dxdrawtext why move in 1920x1080?

dxDrawText("SuperFun - Szórakozó szerver",(sx_-1910) * xm, (sy_/2+20) * ym, 1130 * xm, 75 * ym, tocolor(255,255,255,255),1.00,font2,"center","center")

 

Link to comment

I use another way which I think is easier to use:

 

local sX, sY = guiGetScreenSize()

--IMAGINE THAT WE WILL DRAW A RECTANGLE
myXRes = Your width value of your resolution
myYRes = Your height value of your resolution


function drawMyRectangle()
  	dxDrawRectangle((position/myXRes)*sX, (position/myYRes)*sY, (sizeX/myXRes)*sX, (sizeY/myYRes)*sY, tocolor(20, 190, 50, 200), false)
end
addEventHandler("onClientRender", root, drawMyRectangle)

Hope I help you!

Link to comment
  • Moderators
1 hour ago, Tokio said:

The dxdrawtext why move in 1920x1080?


dxDrawText("SuperFun - Szórakozó szerver",(sx_-1910) * xm, (sy_/2+20) * ym, 1130 * xm, 75 * ym, tocolor(255,255,255,255),1.00,font2,"center","center")

 

You subtract an absolute values from the player his resolution, before applying the multiplier.

(sx_-1910) * xm

That is not a logic calculation.


 

 

At least follow the tutorial:

local devScreenX = 1440
local devScreenY = 900

local screenX, screenY = guiGetScreenSize()

local scaleValue = screenY / devScreenY

 

 

This is more or less how I do it and keep things clean. (untested)

local box = {
	startX = screenX * 0.25,
	startY = screenY * 0.25,
	width = screenX * 0.5,
	height = 500 * scaleValue
}

box.endX = box.startX + box.width
box.endY = box.startY + box.height


dxDrawRectangle ( box.startX, box.startY, box.width, box.height, tocolor(0,0,0) )
dxDrawText("SuperFun - Szórakozó szerver", box.startX + 10 * scaleValue, box.startY, box.endY - 100 * scaleValue, box.startY + 50 * scaleValue, tocolor(255,255,255,255), 1.00 --[[* scaleValue]], font2, "left", "center")

 

 

 

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