Jump to content

LUA Resolution Problem


Veo

Recommended Posts

Dear MTA:SA Community

 

 

I have the issue, that i want do with

dxGetTextWidth & dxDrawRectangle 

a Background, for the Map Text, it looks like that.

https://i.imgur.com/HjwgkeY.png

It works fine in 1920x1080, but if i Change it to 1360x768, then it looks like this

https://i.imgur.com/dFflYj5.png

 

Heres some Code:

 

===============

function resY(value)
    return (value/1080) * y
end

function resX(value)
    return (value/1920) * s
end

===============

local length = dxGetTextWidth(_MapName,resY(1),fonts["normal"][3])
rectangle = dxDrawRectangle(s*0.008,y*0.957,length+55,y*0.030, tocolor ( 0, 266, 0, 250 ) )

 

Link to comment
  • Moderators

The IIYAMA rule: Scale EVERYTHING only over the Y as. Except for the X position.

We are very lucky that they hardly design monitors with a portrait orientation... else it would have blown off my mind.

 


 

This could be one of your issues, an absolute value:

dxDrawRectangle(s*0.008,y*0.957, length + 55,y*0.030, tocolor ( 0, 266, 0, 250 ) )

dxDrawRectangle(s*0.008,y*0.957,length + resY(55),y*0.030, tocolor ( 0, 266, 0, 250 ) )

 

Link to comment
8 minutes ago, IIYAMA said:

The IIYAMA rule: Scale EVERYTHING only over the Y as. Except for the X position.

We are very lucky that they hardly design monitors with a portrait orientation... else it would have blown off my mind.

 


 

This could be one of your issues, an absolute value:

dxDrawRectangle(s*0.008,y*0.957, length + 55,y*0.030, tocolor ( 0, 266, 0, 250 ) )


dxDrawRectangle(s*0.008,y*0.957,length + resY(55),y*0.030, tocolor ( 0, 266, 0, 250 ) )

 

Thanks, i tried. but its still the same issue..

Edited by Veo
Link to comment

Well, I always use this code to draw DX stuff, and I recommend you to try it so

local sx,sy = guiGetScreenSize()
local px,py = 1366,768 --Put your resolution here
local x,y =  (sx/px),(sy/py)

--Example code
dxDrawRectangle(x*0, y*0, x*1366, y*80, tocolor(0, 0, 0, 170), false)
dxDrawText("Test", x*0, y*0, x*1366, y*80, tocolor(255, 255, 255, 255), 1.5, "pricedown", "center", "center", false, false, false, false, false)

It always fits in all resolutions.

  • Like 1
Link to comment
6 hours ago, Erknneto said:

Well, I always use this code to draw DX stuff, and I recommend you to try it so


local sx,sy = guiGetScreenSize()
local px,py = 1366,768 --Put your resolution here
local x,y =  (sx/px),(sy/py)

--Example code
dxDrawRectangle(x*0, y*0, x*1366, y*80, tocolor(0, 0, 0, 170), false)
dxDrawText("Test", x*0, y*0, x*1366, y*80, tocolor(255, 255, 255, 255), 1.5, "pricedown", "center", "center", false, false, false, false, false)

It always fits in all resolutions.

I want that for all resolutions, Not just for 1360

Link to comment
2 hours ago, Dimos7 said:

@Veo did you try my code?

Yes, i do.

 

Here:
GmyQrcE.png

			local x,y = guiGetScreenSize()
			local sw, sh =guiGetScreenSize() 
			local length = dxGetTextWidth(_MapName,resY(1),fonts["normal"][3])
			rectangle = dxDrawRectangle(s*0.008,y*0.957,length + sx*55,y*0.030, tocolor ( 0, 266, 0, 250 ) )

 

Link to comment
14 hours ago, Veo said:

I want that for all resolutions, Not just for 1360

That code works for all resolutions, just put your resolution there and edit. It will work fine in all resolutions, just edit in your resolution and test in others.

Edited by Erknneto
Link to comment
14 hours ago, Veo said:
21 hours ago, Erknneto said:

Well, I always use this code to draw DX stuff, and I recommend you to try it so



local sx,sy = guiGetScreenSize()
local px,py = 1366,768 --Put your resolution here
local x,y =  (sx/px),(sy/py)

--Example code
dxDrawRectangle(x*0, y*0, x*1366, y*80, tocolor(0, 0, 0, 170), false)
dxDrawText("Test", x*0, y*0, x*1366, y*80, tocolor(255, 255, 255, 255), 1.5, "pricedown", "center", "center", false, false, false, false, false)

It always fits in all resolutions.

I want that for all resolutions, Not just for 1360

it WILL fit in each resolution - this is the simplest way. Your coordinates will be multiplied by (for example x: 1366/player_resolution) -> Bigger resolution x>0, smaller - 0<x<1

You can try it yourself by changing in-game/pc resolutions. By the way you should multiply dxDrawText's scale too

Link to comment
local sw, sh =guiGetScreenSize() 
local sx, sy = sw/1920, sh/1080 dxDrawRectangle(sx*0.008,sy*0.957,length + sx*55,sy*0.030, tocolor ( 0, 266, 0, 250 ) )
1 hour ago, Veo said:

Yes, i do.

 

Here:
GmyQrcE.png


			local x,y = guiGetScreenSize()
			local sw, sh =guiGetScreenSize() 
			local length = dxGetTextWidth(_MapName,resY(1),fonts["normal"][3])
			rectangle = dxDrawRectangle(s*0.008,y*0.957,length + sx*55,y*0.030, tocolor ( 0, 266, 0, 250 ) )

 

That wasn't my code

Edited by Dimos7
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...