Files
wnsrc/lua/derma/derma_example.lua
lifestorm 9c918c46e5 Upload
2024-08-04 23:12:27 +03:00

69 lines
1.5 KiB
Lua

--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PANEL = {}
function PANEL:Init()
self:SetTitle( "Derma Initiative Control Test" )
self.ContentPanel = vgui.Create( "DPropertySheet", self )
self.ContentPanel:Dock( FILL )
self:InvalidateLayout( true )
local w, h = self:GetSize()
local Controls = table.Copy( derma.GetControlList() )
for key, ctrl in SortedPairs( Controls ) do
local Ctrls = _G[ key ]
if ( Ctrls && Ctrls.GenerateExample ) then
Ctrls:GenerateExample( key, self.ContentPanel, w, h )
end
end
self:SetSize( 600, 450 )
end
function PANEL:SwitchTo( name )
self.ContentPanel:SwitchToName( name )
end
local vguiExampleWindow = vgui.RegisterTable( PANEL, "DFrame" )
--
-- This is all to open the actual window via concommand
--
local DermaExample = nil
local DermaControlsSuffix = ""
if ( MENU_DLL ) then -- Not all controls are available in menu state
DermaControlsSuffix = "_menu"
end
concommand.Add( "derma_controls" .. DermaControlsSuffix, function( player, command, arguments, args )
if ( IsValid( DermaExample ) ) then
DermaExample:Remove()
return end
DermaExample = vgui.CreateFromTable( vguiExampleWindow )
DermaExample:SwitchTo( args )
DermaExample:MakePopup()
DermaExample:Center()
end, nil, "", { FCVAR_DONTRECORD } )