Skip to content

Instantly share code, notes, and snippets.

@EntranceJew
Created August 4, 2023 08:29
Show Gist options
  • Save EntranceJew/1d7e9050cd18155aa5bfa5d7285c719b to your computer and use it in GitHub Desktop.
Save EntranceJew/1d7e9050cd18155aa5bfa5d7285c719b to your computer and use it in GitHub Desktop.

Revisions

  1. EntranceJew created this gist Aug 4, 2023.
    38 changes: 38 additions & 0 deletions ShowToolMenu.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    include("sandbox/gamemode/spawnmenu/controlpanel.lua")

    local function ShowToolMenu( name )
    local frame = vgui.Create( "DFrame" )
    frame:SetTitle( name )
    frame:SetSize( ScrW() * 0.75, ScrH() * 0.75 )
    frame:Center()
    frame:SetDraggable( true )
    frame:ShowCloseButton( true )
    frame:SetSizable( true )
    frame:MakePopup()

    local dsp = vgui.Create("DScrollPanel", frame)
    dsp:Dock( FILL )

    local controlPanel = vgui.Create( "ControlPanel", dsp )
    controlPanel:SetExpanded( true )
    controlPanel:Dock( FILL )
    controlPanel.Header:SetSize( 0, 0 )

    frame.btnClose:MoveToFront()
    frame.btnMaxim:MoveToFront()
    frame.btnMinim:MoveToFront()


    local atmo = spawnmenu.AddToolMenuOption
    local dex = {}
    spawnmenu.AddToolMenuOption = function(tab, category, class, name, cmd, config, cpanel, tbl)
    dex[ tab .. "/" .. category .. "/" .. class ] = cpanel
    end
    hook.Run( "PopulateToolMenu" )
    spawnmenu.AddToolMenuOption = atmo
    local target = dex[ name ]
    target( controlPanel )
    end


    ShowToolMenu( "Utilities/User/SandboxClientSettings" )