How do I make my derma button open a PANEL?
cl_init.lua:
[CODE]
function teammenuderma()
frame = vgui.Create("DFrame")
frame:SetSize( 1000, 720)
frame:Center()
frame:SetSizable( true )
frame:SetVisible(true)
frame:ShowCloseButton(false)
frame:SetDraggable(false)
frame:SetMinHeight( 100 )
frame:SetMinWidth( 100 )
frame:SetTitle("")
frame:MakePopup()
frame:SetPaintShadow( true )
frame.Paint = function(s, w, h)
draw.RoundedBox(0,0,0,w,h,Color(76,88,68,255))
surface.DrawOutlinedRect( 2, 2, w-4, h-4)
end
local mainpanel = vgui.Create( "DPanel", frame)
mainpanel:SetPos( 3, 35 )
mainpanel:SetSize( 1000 - 6 , 720 - 35 - 3 )
mainpanel.Paint = function( s, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 62, 69, 57 ) )
end
local colsheet = vgui.Create( "DColumnSheet", mainpanel )
colsheet:Dock( FILL )
local label = vgui.Create( "DLabel", frame )
label:SetFont( "MyFont" )
label:SetText( "SELECT TEAM" )
label:SetPos( 5, 5 )
label:SizeToContents()
label:SetTextColor( Color(255,255,255))
local icon = vgui.Create( "DModelPanel", mainpanel )
icon:SetPos( 300, 35 )
icon:SetSize( 1000 - 6, 720 - 35 - 3 )
icon:SetModel( "models/player/combine_soldier.mdl" )
local but1 = vgui.Create( "DImageButton", mainpanel)
but1:SetPos( 300, 35 )
but1:SetSize( 1000 - 6, 720 - 35 - 3)
function but1:Paint( w, h )
if( but1:IsDown() ) then
but1:SetColor( Color( 0,0,0,0 ) )
elseif( but1:IsHovered() ) then
but1:SetColor( Color( 0,0,0,0 ) )
else
but1:SetColor( Color( 0,0,0,0 ) )
end
end
but1.DoClick = function()
frame:Close()
vgui.Create("menu_lobby") -- It does not show my PANEL
end
local icon = vgui.Create( "DModelPanel", mainpanel )
icon:SetPos( -300, 35 )
icon:SetSize( 1000 - 6, 720 - 35 - 3 )
icon:SetModel("models/player/Group03/male_01.mdl")
end
net.Receive( "teammenu", teammenuderma )[/CODE]
cl_lobby.lua
[CODE]
local PANEL = {
Init = function( self )
self:SetSize( 1000, 720)
self:Center()
self:SetVisible(true)
self:MakePopup()
local x,y = self:GetSize()
local label = vgui.Create( "DLabel", frame )
label:SetFont( "MyFont" )
label:SetText( "Plan Your Attack" )
label:SetPos( 5, 5 )
label:SizeToContents()
label:SetTextColor( Color(255,255,255))
local mainpanel = vgui.Create( "DPanel", frame)
mainpanel:SetPos( 3, 35 )
mainpanel:SetSize( x - 6 , y - 35 - 3 )
mainpanel.Paint = function( s, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 62, 69, 57 ) )
end
local colsheet = vgui.Create( "DColumnSheet", mainpanel )
colsheet:Dock( FILL )
local sheet1 = vgui.Create( "DPanel", colsheet )
sheet1:Dock( FILL )
sheet1.Paint = function( s, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 59, 66, 54 ) )
end
colsheet:AddSheet( "Team Chat", sheet1 )
local textbox = vgui.Create("DTextEntry", sheet1)
textbox:Dock( TOP )
textbox:DockMargin( 15, 10, 15, 10 )
textbox:DockPadding( 290, 10, 290, 10 )
textbox:SetTall( 20 )
textbox:SetWide( 450 )
textbox:SetEnterAllowed( true )
textbox.OnEnter = function()
local ply = LocalPlayer()
if ply:Team( n ) == true then
chat.AddText( Color(0,0,0), ply:Team( n ), ": ", Color(0,0,0), textbox:GetValue())
end
end
local sheet2 = vgui.Create( "DPanel", colsheet )
sheet2:Dock( FILL )
sheet2.Paint = function( s, w, h )
draw.RoundedBox( 0, 0, 0, w, h, Color( 59, 66, 54 ) )
end
colsheet:AddSheet( "Map", sheet2 )
timer.Simple(20, function()
self:SetVisible( false )
end)
Paint = function( self, w, h)
draw.RoundedBox(0,0,0,w,h,Color(76,88,68,255))
surface.DrawOutlinedRect( 2, 2, w-4, h-4)
end
end
}
vgui.Register( "menu_lobby", PANEL ) -- I registered? [/CODE]
Also, when I enter the game, the frame in cl_init.lua can be expandable. How do I fix this?
Resizing
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/DFrame/SetSizable]DFrame:SetSizable[/url]
also you need to create it as you would normally create other vgui elements and make it visible and popup. I'm pretty sure you're missing the 3rd argument in vgui.Register which is the base panel
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/vgui/Register]vgui.Register[/url]
[QUOTE=Knoxed;52077891]Resizing
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/DFrame/SetSizable]DFrame:SetSizable[/url]
also you need to create it as you would normally create other vgui elements and make it visible and popup. I'm pretty sure you're missing the 3rd argument in vgui.Register which is the base panel
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/vgui/Register]vgui.Register[/url][/QUOTE]
I did put vgui.Register. It's in the bottom of cl_lobby.lua. Thanks for trying to help me though! :)
[QUOTE=Knoxed;52077891]I'm pretty sure you're missing the 3rd argument in vgui.Register which is the base panel[/QUOTE]
You don't actually need it - it defaults to Panel if you don't add it there
[editline]9th April 2017[/editline]
If you don't want the DFrame created in cl_init to be expandable then remove the line where you made it expandable:
[CODE]
frame:SetSizable( true )
[/CODE]
[QUOTE=MPan1;52078482]You don't actually need it - it defaults to Panel if you don't add it there
[editline]9th April 2017[/editline]
If you don't want the DFrame created in cl_init to be expandable then remove the line where you made it expandable:
[CODE]
frame:SetSizable( true )
[/CODE][/QUOTE]
Can you help me with DButton opening the PANEL? Thanks for the advice btw!
The reason your panel doesn't show is because the base you registered it was Panel:
[CODE]
vgui.Register( "menu_lobby", PANEL ) -- No third argument makes it default to Panel base
[/CODE]
But I assume you want to register it as a DFrame:
[CODE]
vgui.Register( "menu_lobby", PANEL, "DFrame" )
[/CODE]
[QUOTE=MPan1;52079173]The reason your panel doesn't show is because the base you registered it was Panel:
[CODE]
vgui.Register( "menu_lobby", PANEL ) -- No third argument makes it default to Panel base
[/CODE]
But I assume you want to register it as a DFrame:
[CODE]
vgui.Register( "menu_lobby", PANEL, "DFrame" )
[/CODE][/QUOTE]
Omg thank you so much! You got what I asked for, but a slight problem. When you say put "DFrame" it puts a DFrame, but it doesn't show any of my PANEL. It just creates a whole new untouched DFrame.
[QUOTE=Chalksteam56;52080489]Omg thank you so much! You got what I asked for, but a slight problem. When you say put "DFrame" it puts a DFrame, but it doesn't show any of my PANEL. It just creates a whole new untouched DFrame.[/QUOTE]
Nevermind, I figured it out! Thanks for the help everybody!!
Sorry, you need to Log In to post a reply to this thread.