How can I properly account for all resolutions? (draw.RoundedBox/Polys)

[lua]local polydata = {}
polydata[1] = {}
polydata[1][1] = { x = ScrW() / 2 - 260, y = 0 }
polydata[1][2] = { x = ScrW() / 2 - 160, y = 0 }
polydata[1][3] = { x = ScrW() / 2 - 160, y = 50 }
polydata[2] = {}
polydata[2][1] = { x = ScrW() / 2 + 140, y = 0 }
polydata[2][2] = { x = ScrW() / 2 + 240, y = 0 }
polydata[2][3] = { x = ScrW() / 2 + 140, y = 50 }

hook.Add( “HUDPaint”, “PolyXP”, function()

surface.SetDrawColor( 15, 15, 15, 255 )
draw.NoTexture()
surface.DrawPoly( polydata[1] )
surface.DrawPoly( polydata[2] )
draw.RoundedBox( 0, ScrW() / 2 - 160, 0, 300, 50, Color(15,15,15) )

end )[/lua]
The code looks good and centered when it’s at 1080p.
When I change the resolution to anything else though, all hell breaks loose… Everything is in different places and not even centered relative to ScrW(). What??? How can I make that code scale properly to 100% of resolutions?

summoning Acecool
try to summon Acecool, again
Still doesn’t work.
Then i need to do the work.

https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/understanding_hardcoding_of_screensizes.lua.html
In this Tutorial, Josh ‘Acecool’ Moser, will cover the Idea of Hardcoding for Different Screensizes.

Edit://
Also a nice tip: Sometimes VGUI (at least for me) doesn’t scale correctly when i change my Resolution. Try to change Resolution and then restart GMOD.

if you’re only assigning the values once, they don’t change when your resolution changes, I don’t think there’s really an easy way to be ready for changing resolutions other than storing them once, checking them every frame, and if they change reassign all the values you’re using

Wow… I didn’t think of rejoining… I tried that and it scaled fine.