Jump to content

dxdraw question


Recommended Posts

Posted

I just created login/register in guieditor.

I have an problem

800x600 resolution

http://imageshack.us/photo/my-images/33 ... 51955.png/

When it should look like this:

1280x1024

http://imageshack.us/photo/my-images/68 ... 52042.png/

How can i fix it?

The gui is in right place, but not the dxdraw

dxdraw code:

  
        dxDrawRectangle(340.0,255.0,630.0,347.0,tocolor(0,0,0,100),false) 
        dxDrawText("Password:",439.0,434.0,626.0,472.0,tocolor(255,255,255,255),1.0,"bankgothic","left","top",false,false,false) 
        dxDrawText("Username:",441.0,363.0,628.0,401.0,tocolor(255,255,255,255),1.0,"bankgothic","left","top",false,false,false) 
        dxDrawText("MTA Party Server",483.0,282.0,915.0,349.0,tocolor(51,204,255,255),1.7,"pricedown","left","top",false,false,false) 
  

I want to make it compatible for all screen resolutions

Posted

looks like you're using relative positions/sizes for gui and absolute for dxdraw.

you need to scale it, something like this:

  
-- calculate scaling for current screen size, by dividing it by your original size (1280x1024) 
  screenWidth, screenHeight = guiGetScreenSize() 
  scaleX = screenWidth/1280 
  scaleY = screenHeight/1024 
  
-- and then multiply your positions/sizes: 
  dxDrawRectangle(340*scaleX, 255*scaleY, 630*scaleX, *scaleY, tocolor(0,0,0,100), false) 
  dxDrawText("Password:", 439*scaleX, 434*scaleY, 626*scaleX, 472*scaleY, tocolor(255,255,255,255), scaleX, "bankgothic") 
  dxDrawText("Username:", 441*scaleX, 363*scaleY, 628*scaleX, 401*scaleY, tocolor(255,255,255,255), scaleX, "bankgothic") 
  dxDrawText("MTA Party Server", 483*scaleX, 282*scaleY, 915*scaleX, 349*scaleY, tocolor(51,204,255,255), 1.7*scaleX, "pricedown") 
  

Posted
looks like you're using relative positions/sizes for gui and absolute for dxdraw.

you need to scale it, something like this:

  
-- calculate scaling for current screen size, by dividing it by your original size (1280x1024) 
  screenWidth, screenHeight = guiGetScreenSize() 
  scaleX = screenWidth/1280 
  scaleY = screenHeight/1024 
  
-- and then multiply your positions/sizes: 
  dxDrawRectangle(340*scaleX, 255*scaleY, 630*scaleX, *scaleY, tocolor(0,0,0,100), false) 
  dxDrawText("Password:", 439*scaleX, 434*scaleY, 626*scaleX, 472*scaleY, tocolor(255,255,255,255), scaleX, "bankgothic") 
  dxDrawText("Username:", 441*scaleX, 363*scaleY, 628*scaleX, 401*scaleY, tocolor(255,255,255,255), scaleX, "bankgothic") 
  dxDrawText("MTA Party Server", 483*scaleX, 282*scaleY, 915*scaleX, 349*scaleY, tocolor(51,204,255,255), 1.7*scaleX, "pricedown") 
  

Thank you, it works!

Posted

Sorry for the double post.

For example, when i click the register button, how can i stop the dxd from further rendering?

  
addEventHandler("onClientRender",root, 
    function() 
    local screenWidth, screenHeight = guiGetScreenSize() 
    local scaleX = screenWidth/1280 
    local scaleY = screenHeight/1024 
  
    dxDrawRectangle(340*scaleX, 255*scaleY, 630*scaleX, 347*scaleY, tocolor(0,0,0,100), false) 
    dxDrawText("Password:", 439*scaleX, 434*scaleY, 626*scaleX, 472*scaleY, tocolor(255,255,255,255), scaleX, "bankgothic") 
    dxDrawText("Username:", 441*scaleX, 363*scaleY, 628*scaleX, 401*scaleY, tocolor(255,255,255,255), scaleX, "bankgothic") 
    dxDrawText("MTA Party Server", 483*scaleX, 282*scaleY, 915*scaleX, 349*scaleY, tocolor(51,204,255,255), 1.7*scaleX, "pricedown") 
  
    end 
) 
  

Posted

first, you dont need to get screen size and scaling multipliers every frame. its is unlikely that they will change. get them at script start and leave them.

second:

local screenWidth, screenHeight = guiGetScreenSize() 
local scaleX = screenWidth/1280 
local scaleY = screenHeight/1024 
  
  
function renderLoginWindow() 
  dxDrawRectangle(340*scaleX, 255*scaleY, 630*scaleX, 347*scaleY, tocolor(0,0,0,100), false) 
  dxDrawText("Password:", 439*scaleX, 434*scaleY, 626*scaleX, 472*scaleY, tocolor(255,255,255,255), scaleX, "bankgothic") 
  dxDrawText("Username:", 441*scaleX, 363*scaleY, 628*scaleX, 401*scaleY, tocolor(255,255,255,255), scaleX, "bankgothic") 
  dxDrawText("MTA Party Server", 483*scaleX, 282*scaleY, 915*scaleX, 349*scaleY, tocolor(51,204,255,255), 1.7*scaleX, "pricedown") 
end 
addEventHandler("onClientRender", root, renderLoginWindow) 
  
-- then, after clicking the button, remove the event handler 
removeEventHandler("onClientRender", root, renderLoginWindow) 

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