FlyingSpoon Posted June 27, 2015 Posted June 27, 2015 How to make Dx fit on all screens? Is there a fast way.
John Smith Posted June 27, 2015 Posted June 27, 2015 i use it this way local sw,sh = guiGetScreenSize() local x = 500/1920*sw -- position number / your resolution width * sw[screen-width] local y = 750/1080*sh -- position number / your resolution height * sh[screen-height] dxDrawText("text",x,y) -- draw text
FlyingSpoon Posted June 27, 2015 Author Posted June 27, 2015 Will this work if I have a lot of DX's ? e.g. Rectangles, Texts etc, or does it just fit for 1 Dx object.
John Smith Posted June 27, 2015 Posted June 27, 2015 With texts it will work for sure, but i suggest using allign arguments(it makes things easier) and you should make font's scale also calculated for resolution e.g local scaleX,scaleY = 1/1920*sw, 1/1080*sh -- but can slightly decrease font quality because size usually ends up being a decimal number and rectangles, you need to use some calculations depending how big rectangle is e.g -- makes rectangle on middle of screen local sw,sh = guiGetScreenSize(); local rectangleWidth,rectangleHeight = 500/1920*sw, 180/1080*sh; local rectangleX,rectangleY = sw/2 - rectangleWidth/2, sh/2 - rectangleHeight/2; function draw() dxDrawRectangle(rectangleX,rectangleY,rectangleWidth,rectangleHeight,tocolor(0,0,0,180)); end; addEventHandler("onClientRender",root,draw);
KariiiM Posted June 27, 2015 Posted June 27, 2015 -- Functions dxCreateShader() dxCreateTexture() getControlState() dxSetShaderValue() engineApplyShaderToWorldTexture() -- Events onClientRender()
xeon17 Posted June 27, 2015 Posted June 27, 2015 -- Functions dxCreateShader() dxCreateTexture() getControlState() dxSetShaderValue() engineApplyShaderToWorldTexture() -- Events onClientRender() No need for this , the example of John_Smith is just perfect.
FlyingSpoon Posted June 27, 2015 Author Posted June 27, 2015 John Smith will that place all Dx Rect all in the middle? Because I have Dx Rect in different areas, there is one way which I hate the most and is long, I thought there could be something easier.
xeon17 Posted June 27, 2015 Posted June 27, 2015 (edited) You can do it like this (Copied from my script) local sx,sy = guiGetScreenSize() local px,py = 1152,864 -- your resolution local x,y = (sx/px), (sy/py) BeerLabel:setBounds(x*64,y*27,x*91,y*15) ColaIMG:setBounds(x*10,y*96,x*43,y*47) Bar:setBounds(x*235,y*236,x*548,y*396) Edited June 27, 2015 by Guest
John Smith Posted June 27, 2015 Posted June 27, 2015 John Smith will that place all Dx Rect all in the middle?Because I have Dx Rect in different areas, there is one way which I hate the most and is long, I thought there could be something easier. This is easy man, just practice it a bit. it works for infinite number of rectangles(if your calculation is right) try out the script, change numbers and learn from it. (I have done that 29321013 times when learning how to script, and learned many things)
FlyingSpoon Posted June 28, 2015 Author Posted June 28, 2015 So how would I do it to this for example? @XeoN dxDrawRectangle(190, 236, 444, 28, tocolor(0, 0, 0, 179), false)
xeon17 Posted June 28, 2015 Posted June 28, 2015 local sx,sy = guiGetScreenSize() local px,py = 1152,864 -- your resolution local x,y = (sx/px), (sy/py) dxDrawRectangle(x*190, y*236, x*444, y*28, tocolor(0, 0, 0, 179), false)
FlyingSpoon Posted June 28, 2015 Author Posted June 28, 2015 Will this work for all screen resolutions?
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