rework config system to use a API for setting up the table now, and no merging
This commit is contained in:
+44
@@ -164,3 +164,47 @@ end
|
||||
function Bartender4:RegisterModuleOptions(key, table)
|
||||
self.options.plugins[key] = { [key] = table }
|
||||
end
|
||||
|
||||
local optionParent = {}
|
||||
function optionParent:NewCategory(category, data)
|
||||
self.table[category] = data
|
||||
end
|
||||
|
||||
function optionParent:AddElement(category, element, data, ...)
|
||||
local lvl = self.table[category]
|
||||
for i = 1, select('#', ...) do
|
||||
local key = select(i, ...)
|
||||
if not (lvl.args[key] and lvl.args[key].args) then
|
||||
error(("Sub-Level Key %s does not exist in options group or is no sub-group."):format(key), 2)
|
||||
end
|
||||
lvl = lvl.args[key]
|
||||
end
|
||||
|
||||
lvl.args[element] = data
|
||||
end
|
||||
|
||||
function optionParent:AddElementGroup(category, group_desc, data, ...)
|
||||
local lvl = self.table[category]
|
||||
for i = 1, select('#', ...) do
|
||||
local key = select(i, ...)
|
||||
if not (lvl.args[key] and lvl.args[key].args) then
|
||||
error(("Sub-Level Key %s does not exist in options group or is no sub-group."):format(key), 2)
|
||||
end
|
||||
lvl = lvl.args[key]
|
||||
end
|
||||
|
||||
if not lvl.plugins then
|
||||
lvl.plugins = {}
|
||||
end
|
||||
lvl.plugins[group_desc] = data
|
||||
end
|
||||
|
||||
function Bartender4:NewOptionObject(otbl)
|
||||
if not otbl then otbl = {} end
|
||||
local tbl = { table = otbl }
|
||||
for k, v in pairs(optionParent) do
|
||||
tbl[k] = v
|
||||
end
|
||||
|
||||
return tbl
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user