Jump to content

dxDraw Help


crismar

Recommended Posts

YEs, I've read an entire philosophy about dxDraw and how their are just pixels and our mind tricks us and stuff but I'm curious.

If guiCreate has relative and absolute positionning, and same GUI looks the same across all resolutions, isn't it possible at all to make dxDrawed text also relative/absolute?

In short: I have a money system and it uses dxDraw and I have positioned money right under time (normal GtA SA hud component time), and now it simply doesn't show up/position well in some resolutions.

For instance: in 1024x768 - Looks perfect

800x600 - Doesn't even show up

1920x1080 (or well, higher then 1280x1024) - Shows somewhere in the left of the current weapon hud component. I don't want that. Could you help me up ?

Link to comment

Use something like this to calculate the position relative to the screen size:

  
_dxDrawText = dxDrawText -- keep original function as we'll need it; 
function dxDrawText(text,left,top,relative,right,bottom,color,scale,font,alignX,alignY,clip,wordBreak,postGUI,colorCoded,subPixelPositioning,fRotation,fRotationCenterX,fRotationCenterY) 
    local sx,sy = guiGetScreenSize() 
    local left = relative and left*sx or left 
    local top = relative and top*sy or top 
    local right = relative and right and right*sx or not relative and right or left 
    local bottom = relative and bottom and bottom*sy or not relative and bottom or top 
    local color = color or tocolor(255,255,255) 
    local scale = scale or 1 
    local font = font or "default" 
    local alignX = alignX or "left" 
    local alignY = alignY or "top" 
    local clip = clip or false 
    local wordBreak = wordBreak or false 
    local postGUI = postGUI or false 
    local colorCoded = colorCoded or false 
    local subPixelPositioning = subPixelPositioning or false 
    local fRotation = fRotation or 0 
    local fRotationCenterX = fRotationCenterX or 0 
    local fRotationCenterY = fRotationCenterY or 0 
    return _dxDrawText(text,left,top,right,bottom,color,scale,font,alignX,alignY,clip,wordBreak,postGUI,colorCoded,subPixelPositioning,fRotation,fRotationCenterX,fRotationCenterY) 
end 
  

The new function.

bool dxDrawText ( string text, float left, float top, bool relative [, float right=left, float bottom=top, int color=white, float scale=1, mixed font="default", string alignX="left", string alignY="top", bool clip=false, bool wordBreak=false, bool postGUI=false, bool colorCoded=false, bool subPixelPositioning=false, float fRotation=0, float fRotationCenterX=0, float fRotationCenterY=0 ] ) 

And now you can just use dxDrawText with the relative argument just like in GUI functions.

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