Dear Coders,
I am currently facing an issue.
"DermaPanel:Center()" seems not to put the DFrame in the center of everybody's screen.
Isn't there any way to ask it to center it depending of the resolution of the player's screen?
(It would put it in the center automatically).
Thank you very much for you help.
~ ProGcss
If it doesn't put it in the center, where [i]does[/i] it put it?
Can you be more specific, and post the code you're using?
[lua]local panelWidth = 200
local panelHeight = 350
myPanel:SetPos( (ScrW()/2)-(panelWidth/2), (ScrH()/2)-(panelHeight/2) )[/lua]
Maybe something like that? Although there may be a better way to do it, if Center() doesn't work then that's what i'd go with.
What panel are you using?
The DFrame Center function is different from the normal Center function.
[QUOTE=Blasphemy;38303167][lua]
local panel = vgui.Create( "DPanel" );
panel:SetSize( 500, 500 );
panel:SetPos( ScrW() / 2 - panel:GetWide() / 2, ScrH() / 2 - panel:GetHeight() / 2 );
[/lua][/QUOTE]
As for DPanels the center functions does pretty much that, except that it uses the parents dimensions instead of the screen ones.
This is the code:
[img]http://img163.imageshack.us/img163/6313/charteq.png[/img]
Here is the result:
[url]http://img94.imageshack.us/img94/6254/centeringq.png[/url]
EDIT: I've just done what LuckyLuke told me. It works like a charm. Thank you everybody for your help :)
You need to Center AFTER you set the size.
Yeah, you centered it before it had a size (Not sure if the default size is (0,0) or something else) but it centered with a different size, then you set the size.
Sorry, you need to Log In to post a reply to this thread.