Jump to content

loop bug with guiGetScreenSize


iiv03

Recommended Posts

hey i have a little problem here when converting a screen from 1600x900 to 800x600

i used some scaling tutorial @IIYAMA

so i did loop and had some problem with screen sizes

my screen

p_1450rrmd02.png

screen user's 800x600:

p_1450qd8xg1.png

code:

local devScreenX = 1920 
local devScreenY = 1080

local screenX, screenY = guiGetScreenSize()

local scaleValue = screenY / devScreenY

scaleValue = math.max(scaleValue, 0.65) -- < here add the limit


addEventHandler("onClientResourceStart",resourceRoot,
function()
setPlayerHudComponentVisible("all", false)
end)
local dash = {
menu = {"Hello There","Hello There2","Hello There3","Hello There4","Hello There5","Hello There6"},
}
addEventHandler("onClientRender", root,
function ()
	-- create a scaled size
	local sizeX = scaleValue * 180
	local sizeY = scaleValue * 40
	
	-- get the center of the screen
	local centerX = screenX - screenX
	local centerY = screenY / 2
	
	-- calculate the starting point of the rectangle
	local startRectangleX = centerX
	local startRectangleY = centerY - (sizeY / 0.5)
	local offsetY = 0
	dxDrawRectangle ( startRectangleX, startRectangleY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) 
	offsetY = offsetY + startRectangleY*0.15
	dxDrawRectangle ( startRectangleX, startRectangleY+offsetY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) 
	offsetY = offsetY + startRectangleY*0.15
	dxDrawRectangle ( startRectangleX, startRectangleY+offsetY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) 
	offsetY = offsetY + startRectangleY*0.15
	dxDrawRectangle ( startRectangleX, startRectangleY+offsetY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) 
	offsetY = offsetY + startRectangleY*0.15
	dxDrawRectangle ( startRectangleX, startRectangleY+offsetY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) 
	offsetY = offsetY + startRectangleY*0.15
	dxDrawRectangle ( startRectangleX, startRectangleY+offsetY, sizeX, sizeY, tocolor ( 0, 0, 0, 180 ) ) 
	--[[local offsetY = 0
	local posY = startRectangleY * 0.022
	dxDrawText("Hello There!", startRectangleX, startRectangleY+posY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top")
	offsetY = offsetY + startRectangleY * 0.17
	dxDrawText("Hello There!", startRectangleX, startRectangleY+offsetY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top")
	offsetY = offsetY + startRectangleY * 0.15
	dxDrawText("Hello There!", startRectangleX, startRectangleY+offsetY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top")
	offsetY = offsetY + startRectangleY * 0.155
	dxDrawText("Hello There!", startRectangleX, startRectangleY+offsetY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top")
	offsetY = offsetY + startRectangleY * 0.145
	dxDrawText("Hello There!", startRectangleX, startRectangleY+offsetY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top")
	offsetY = offsetY + startRectangleY * 0.15
	dxDrawText("Hello There!", startRectangleX, startRectangleY+offsetY, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top")]] -- THIS WORK WITHOUT LOOP
	local posY = startRectangleY * 1.88
	for i,v in ipairs(dash.menu) do
	dxDrawText(v, startRectangleX, posY-startRectangleY+i*57, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top")
	end
end)

 

Edited by xFabel
Link to comment
  • Moderators

(Mobile)

 

dxDrawText(v, startRectangleX, posY-startRectangleY+i*57, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top")

>

This is not scaled.  Take a closer look at how you did that with the rectangle.

 

 

dxDrawText(v, startRectangleX, posY-startRectangleY+i*57, sizeX, sizeY,tocolor(255,255,255,255),1,"default-bold","right","top")

>

dxDrawText doesn't make use of sizes. But end points. (startpoint + size = endpoint)

 

Overall,

> mirror what you did with the rectangle.

> use endpoints instead of the size.

> center the text vertically. Between the 2 startpoints and the 2 endpoints.

 

  • Thanks 1
Link to comment

thank you for answer :grin:

but what u mean between start and end point?

	dxDrawText(v, startRectangleX, startRectangleY, sizeX,startRectangleY+sizeY+i,tocolor(255,255,255,255),1,"default-bold","right","center") -- loop

almost like this

but when i hit (i)*70 the text goes down below

It's like I'm moving Y and I haven't touched it

Edited by xFabel
Link to comment
  • Moderators
3 hours ago, xFabel said:

but what u mean between start and end point?

startX = 0

startY = 0

sizeX = 100

sizeY = 20

endX = startX + sizeX

endY = startY + sizeY

dxDrawText("text", startX, startY, endX, endY, ...

 

 

 

 

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