-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.lua
120 lines (113 loc) · 2.59 KB
/
options.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
local addon,ns=...;
local L,C=ns.L,ns.LC.color;
local order,orderSub = 10,1;
ns.options = {
type = "group",
name = L[addon],
childGroups = "tree",
args = {
-- general = { type = "group", name = "Options", args = {} }
--[[
credits_separator = {
type = "group",
name = " ",
order = 100000,
disabled = true,
args = {},
},
--]]
}
};
ns.options_subpanels = {
};
ns.options_subpanels_count = 0;
local function separators(tbl,mod)
for k,v in pairs(tbl.args)do
if k:match("^separator%d+$") then
v.type = "description";
v.name = " ";
v.fontSize = v.size or "small";
v.size = nil;
elseif v.args then
separators(v,mod.."/"..k); -- recursive
end
end
end
function ns.addModuleOptions(modName,modData)
local tbl = ns.options;
if modData.options_subpanel ~= false then
if not ns.options_subpanels[modName] then
ns.options_subpanels[modName] = {
type = "group", order = orderSub,
name = modData.label,
childGroups = "tab",
args = {}
};
end
tbl = ns.options_subpanels[modName];
ns.options_subpanels_count = ns.options_subpanels_count+1;
orderSub = orderSub + 1;
else
if modData.options_prependingSeparator then
ns.options.args[modName.."_separator"] = {
type = "group",
name = " ",
order = order,
disabled = true,
args = {},
}
order=order+1;
end
if not ns.options.args[modName] then
ns.options.args[modName] = {
type = "group",
name = modData.label,
order = order,
args = {},
};
end
tbl = ns.options.args[modName];
if not modData.options_NoHeader then
tbl.args.title = {
order=1,
type="description",
name=C("dkyellow",modData.label),
fontSize = "large"
};
end
end
if modData.desc then
tbl.args.description ={
type = "description", order = 2,
name = modData.desc,
fontSize = "small"
}
end
local c = 10;
if modData.options then
if modData.options_childGroups then
tbl.childGroups = modData.options_childGroups;
end
for k,v in pairs(modData.options)do
if v.order then
v.order = v.order+c;
else
v.order = c;
c=c+1;
end
tbl.args[k] = v;
end
separators(tbl,modName);
end
order=order+1;
end
function ns.RegisterOptionPanel()
LibStub("AceConfig-3.0"):RegisterOptionsTable(L[addon], ns.options);
LibStub("AceConfigDialog-3.0"):AddToBlizOptions(L[addon]);
if ns.options_subpanels_count>0 then
for modName,modOptions in ns.pairsByKeys(ns.options_subpanels)do
LibStub("AceConfig-3.0"):RegisterOptionsTable(modName, modOptions);
LibStub("AceConfigDialog-3.0"):AddToBlizOptions(modName,modOptions.name,L[addon]);
end
end
end