2024-03-08 20:10:47 -05:00
|
|
|
|
|
|
|
---------------------
|
|
|
|
-- Your Name is Benny
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
|
|
|
|
if SERVER then
|
|
|
|
util.AddNetworkString( "Benny_DebugMenuSpawn" )
|
|
|
|
net.Receive( "Benny_DebugMenuSpawn", function( len, ply )
|
|
|
|
if !ply:IsAdmin() then return end
|
|
|
|
local ent = ents.Create( "b-item_" .. net.ReadString() )
|
|
|
|
ent:SetPos( ply:GetEyeTrace().HitPos )
|
|
|
|
ent:Spawn()
|
|
|
|
end)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local function dospawn( self )
|
|
|
|
net.Start( "Benny_DebugMenuSpawn" )
|
|
|
|
net.WriteString( self.iName )
|
|
|
|
net.SendToServer()
|
2024-04-06 09:30:09 -04:00
|
|
|
DebugMenu:Remove()
|
|
|
|
return
|
2024-03-08 20:10:47 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
local function OpenDebugMenu()
|
|
|
|
if IsValid(DebugMenu) then DebugMenu:Remove() end
|
|
|
|
DebugMenu = vgui.Create("DFrame")
|
2024-08-30 18:30:03 -04:00
|
|
|
DebugMenu:SetSize( 200, 500 )
|
2024-03-08 20:10:47 -05:00
|
|
|
DebugMenu:Center()
|
|
|
|
DebugMenu:MakePopup()
|
2024-03-25 00:48:36 -04:00
|
|
|
DebugMenu:SetKeyboardInputEnabled( false )
|
2024-03-08 20:10:47 -05:00
|
|
|
|
2024-04-06 09:30:09 -04:00
|
|
|
local opt = DebugMenu:Add("DScrollPanel")
|
|
|
|
opt:Dock( FILL )
|
2024-03-08 20:10:47 -05:00
|
|
|
|
2024-08-30 18:30:03 -04:00
|
|
|
local categories = {}
|
|
|
|
|
2024-03-08 20:10:47 -05:00
|
|
|
for iname, idata in SortedPairs( ITEMS ) do
|
2024-08-30 18:30:03 -04:00
|
|
|
if !categories[idata.Category] then
|
|
|
|
local cate = opt:Add("DCollapsibleCategory")
|
|
|
|
cate:Dock(TOP)
|
|
|
|
cate:SetLabel(idata.Category)
|
|
|
|
local plist = vgui.Create("DPanelList")
|
|
|
|
cate:SetContents(plist)
|
|
|
|
categories[idata.Category] = plist
|
|
|
|
end
|
|
|
|
local plist = categories[idata.Category]
|
|
|
|
local button = plist:Add("DButton")
|
2024-03-08 20:10:47 -05:00
|
|
|
button:Dock( TOP )
|
2024-08-30 18:30:03 -04:00
|
|
|
button:DockMargin( 0, 0, 0, 0 )
|
2024-03-08 20:10:47 -05:00
|
|
|
button:SetText( l8( idata.PrintName ) )
|
|
|
|
button.iName = iname
|
|
|
|
button.iData = idata
|
|
|
|
button.DoClick = dospawn
|
|
|
|
end
|
2024-03-25 00:48:36 -04:00
|
|
|
|
|
|
|
local button = DebugMenu:Add("DButton")
|
|
|
|
button:Dock( BOTTOM )
|
|
|
|
button:DockMargin( 4, 4, 4, 4 )
|
|
|
|
button:SetText( "CLOSE" )
|
|
|
|
button:SetTall( 36 )
|
|
|
|
button.DoClick = function( self )
|
|
|
|
DebugMenu:Remove()
|
|
|
|
end
|
2024-03-08 20:10:47 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
hook.Add("PlayerButtonDown", "PlayerButtonDown_DebugMenu", function( ply, button )
|
|
|
|
if button == KEY_F1 then
|
|
|
|
OpenDebugMenu()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
hook.Add("PlayerButtonUp", "PlayerButtonUp_DebugMenu", function( ply, button )
|
|
|
|
if button == KEY_F1 then
|
|
|
|
--if IsValid(DebugMenu) then DebugMenu:Remove() end
|
|
|
|
end
|
|
|
|
end)
|