dobrograd-13-06-2022/garrysmod/addons/feature-wire/lua/wire/client/wiremenus.lua
Jonny_Bro (Nikita) e4d5311906 first commit
2023-11-16 15:01:19 +05:00

50 lines
1.3 KiB
Lua

local Categories = {
"Favourites",
"Chips, Gates",
"Visuals",
"Detection",
"Input, Output",
"Vehicle Control",
"Physics",
"Other",
"Memory",
"Advanced",
"Tools",
"Options",
}
hook.Add( "AddToolMenuCategories", "WireCategories", function()
for i=1,#Categories do
local Category = Categories[i]
spawnmenu.AddToolCategory("Wire", Category, Category)
end
end)
local function WireTab()
spawnmenu.AddToolTab( "Wire", "Wire" )
--start: UGLY HACK, BAD BAD BAD D:
local oldspawnmenuAddToolMenuOption = spawnmenu.AddToolMenuOption
function spawnmenu.AddToolMenuOption(tab, category, ...)
if tab == "Main" and string.lower(string.Left(category, 4)) == "wire" then tab = "Wire" end
oldspawnmenuAddToolMenuOption(tab, category, ...)
end
--end: UGLY HACK, BAD BAD BAD D:
end
hook.Add( "AddToolMenuTabs", "WireTab", WireTab)
local devs = {}
function AddWireAdminMaxDevice(pluralname, dev)
devs[pluralname] = dev
end
local function BuildAdminControlPanel(Panel)
for name,dev in pairs(devs) do
local slider = Panel:NumSlider(name, "sbox_max"..dev, 0, 999, 0)
end
end
local function AddWireAdminControlPanelMenu()
spawnmenu.AddToolMenuOption("Utilities", "Admin", "WireAdminControlPanel", "Max Wire Devices", "", "", BuildAdminControlPanel, {})
end
hook.Add("PopulateToolMenu", "AddAddWireAdminControlPanelMenu", AddWireAdminControlPanelMenu)