wiremod-svn-archive/wire/lua/autorun/client/cl_modelplug.lua

54 lines
1.3 KiB
Lua
Raw Normal View History

2007-02-04 07:18:10 +00:00
ModelPlugInfo = {}
2007-02-05 10:52:02 +00:00
function ModelPlug_AddToCPanel(panel, category, toolname, label, type, textbox_label)
2007-02-04 07:18:10 +00:00
if (not ModelPlugInfo[category]) then
local catinfo = {}
local packs = file.Find("WireModelPacks/*.txt")
for _,filename in pairs(packs) do
local packtbl = util.KeyValuesToTable(file.Read("WireModelPacks/" .. filename) or {})
for name,entry in pairs(packtbl) do
local categorytable = string.Explode(",", entry.categories or "none") or { "none" }
2007-02-05 10:52:02 +00:00
2007-02-04 07:18:10 +00:00
for _,cat in pairs(categorytable) do
if (cat == category) then
catinfo[name] = entry.model or ""
default = default or entry.model
break
end
end
end
end
ModelPlugInfo[category] = catinfo
end
2007-02-05 10:52:02 +00:00
if (table.Count(ModelPlugInfo[category]) > 1) then
2007-02-04 07:59:33 +00:00
local type = type or "ComboBox"
local Models = {
Label = label or "Model:",
MenuButton = "0",
2007-02-04 07:18:10 +00:00
2007-02-04 07:59:33 +00:00
Options = {}
}
2007-02-04 07:18:10 +00:00
2007-02-04 07:59:33 +00:00
for name,model in pairs(ModelPlugInfo[category]) do
Models.Options[name] = { [toolname .. "_model"] = model }
end
2007-02-04 07:18:10 +00:00
2007-02-04 07:59:33 +00:00
panel:AddControl(type, Models)
2007-02-04 07:18:10 +00:00
end
if (textbox_label) then
panel:AddControl("TextBox", {
Label = textbox_label,
Command = toolname .. "_model",
MaxLength = "200"
})
end
end