[url="http://gyazo.com/8d3b96c1fb9d589dc597464f1b9c150f"]This[/URL]
vs
[URL="http://gyazo.com/4d1a8052fa11ee6e161f21ce5f32ddeb"]This[/URL]
draw.DrawText(""..LocalPlayer():getDarkRPVar("job")or 0, "PropFont1", ScrW()-ScrW()+326, ScrH()-125, Color(255,255,255,255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_RIGHT)
Also if you can make my profile picture actaully fix the box when resolution is changed that'd be great
local function Avatar()
local Avatar = vgui.Create("AvatarImage")
Avatar:SetSize(ScrW() / 4 * 0.236, ScrW() / 4 * 0.236)
Avatar:SetPos(ScrW() * 0.019, ScrH() * 0.796)
Avatar:SetPlayer(LocalPlayer(), 64)
end
timer.Simple(.5, function()
Avatar()
end)
The problem with dividing the ScrW and ScrH is that for different resolutions you'll get different results, which wouldn't be a problem if you used the same calculation everywhere for the base position.
Creating HUDs with efficient method for HUDShouldDraw: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/proper_hud_creation.lua.html[/url]
How to hard-code the screen-size into your VGUI and then use a modifier to make it adjust properly to all screen resolutions: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/understanding_hardcoding_of_screensizes.lua.html[/url]
Basically just setup variables where you hard-code it to your default game-resolution. Then, you need to define 2 vars with your resolution width and height, then you divide with the ScrW and ScrH of the client playing the game. For you the result will be 1 ( meaning you multiply all width vars with the modifier for width, and you multiply all height vars with the modifier for height; additionally you'd use the modifier for the x and y position using the width and height modifiers respectively ) and nothing will change. Smaller resolutions will have a value less than 1 and larger resolutions will have a value larger than 1.
I hope this helps making it easier.
If you want something that will fire a hook clientside ( and serverside if you network it ) when the resolution changes, take a look at this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_hooks/playerchangedresolution/lua/autorun/client/cl_gm_playerchangedresolution.lua[/url]
This is the example usage bit ( notice all vars are initialized as local to the file outside of the HUDPaint; when the hook for resolution change is fired we simply update those vars and re-create the poly table [ custom function, but instead of creating the poly table each frame we only make it once and update on change ] which helps with efficiency ): [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_hooks/playerchangedresolution/example_usage.lua[/url]
So how can I apply this to the text being offset for jobs with longer titles?
You can scale the text as well with something like this:
[code]
local mat = Matrix()
mat:Scale( Vector( 1, 1, 1 ) * SCALE )
render.PushFilterMag( TEXFILTER.ANISOTROPIC )
render.PushFilterMin( TEXFILTER.ANISOTROPIC )
cam.PushModelMatrix( mat )
--draw text here
cam.PopModelMatrix()
render.PopFilterMag()
render.PopFilterMin()
[/code]
I'm confused, how does that apply to the text being offset for different jobs?
Sorry, you need to Log In to post a reply to this thread.