RoundedBoxEx is not going to the center for all resolutions?

So, I have tried many things for this to work. As well as


self:Center

However I have also tried this (and other variations):


-- Frame
	self:SetSize( 1115, 725 )
	self:SetTitle( "" )
	self:SetVisible( true )
	self:SetDraggable( false )
	self:ShowCloseButton( false )
	self:SetDeleteOnClose( false )
	self:MakePopup()
	self:SetPos(ScrW() / 2 - 557.5, ScrH() / 2 - 362.5)
	self.Paint = function( pnl, w, h )
		draw.RoundedBoxEx( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 255, 255, 255, 255 ))
	end

So I set the position of the box to the center (The screen size divided by 2, then half the length of the box minus the ScrW()/2 to put it in the center) however, that has not worked well… it works for a lower resolutions, but when I make it higher it changes to the corner?

Thanks in advanced!

1115 x 725 is wrong because not all monitors are that big or they’re even larger, resulting in skewed positions.

I’m not sure if there’s a certain “rule” you should work on a resolution to do vgui / huds, anyway try this:

[lua]
– Frame
self:SetSize( ScrW() / (ScrW() / 1115), ScrH() / (ScrH() / 725) )
self:SetTitle( “” )
self:SetVisible( true )
self:SetDraggable( false )
self:ShowCloseButton( false )
self:SetDeleteOnClose( false )
self:MakePopup()
self:Center()
self.Paint = function( pnl, w, h )
draw.RoundedBoxEx( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 255, 255, 255, 255 ))
end
[/lua]

Sorry, I ment to specify. The


self:SetSize( 1115, 725 )

is the size of the box then it draws in that box

[editline]20th February 2015[/editline]

Haha, I managed to fix it. If anyone else has this problem they can just use


self:Center()

and when you change screen resolutions, re-join the server and then it is fine. I think if you do it mid game and do not rejoin it messes up and you have to rejoin xD

Hey there, please see Developer Discussion for help threads, thanks!