978ee00 - Different health text and more text space in config
[wowui.git] / OmaRFConfig / IndicatorsConfig.lua
1 local function createOptionsTable(self)
2     local options = {
3         type = "group",
4         get = function(item) return self.db.profile[item[#item]] end,
5         set = function(item, value) self.db.profile[item[#item]] = value; self:RefreshConfig() end,
6         args = {
7             enabled = {
8                 type = "toggle",
9                 name = "Enable",
10             },
11             majorAuras = {
12                 type = "group",
13                 name = "Major Auras",
14                 get = function(item) return self.db.profile.majorAuras[item[#item]] end,
15                 set = function(item, value)
16                     self.db.profile.majorAuras[item[#item]] = value;
17                     self:RefreshConfig()
18                 end,
19                 args = {
20                     auras = {
21                         type = "input",
22                         name = "Auras",
23                         multiline = 10,
24                         width = "full",
25                         get = function(item)
26                             return table.concat(self.db.profile.majorAuras["auras"], "\n");
27                         end,
28                         set = function(item, value)
29                             local t = {};
30                             for aura in string.gmatch(value, "[^\n]+") do
31                                 aura = string.gsub(aura, "^%s*(.-)%s$", "%1");
32                                 if tonumber(aura) then
33                                     table.insert(t, tonumber(aura));
34                                 else
35                                     table.insert(t, aura);
36                                 end
37                             end
38                             self.db.profile.majorAuras["auras"] = t;
39                             self:RefreshConfig();
40                         end,
41                     },
42                     max = {
43                         type = "range",
44                         name = "Number shown",
45                         min = 1,
46                         max = 10,
47                         step = 1,
48                         width = "full",
49                     },
50                     iconSize = {
51                         type = "range",
52                         name = "Icon size",
53                         min = 1,
54                         max = 30,
55                         step = 1,
56                         width = "full",
57                     },
58                     textSize = {
59                         type = "range",
60                         name = "Text size",
61                         min = 1,
62                         max = 30,
63                         step = 1,
64                         width = "full",
65                     },
66                 }
67             },
68         }
69     };
70
71     for _, pos in ipairs(self.positions) do
72         options.args[pos] = {
73             type = "group",
74             name = pos,
75             get = function(item)
76                 return self.db.profile.indicators[pos][item[#item]];
77             end,
78             set = function(item, value)
79                 self.db.profile.indicators[pos][item[#item]] = value;
80                 self:RefreshConfig();
81             end,
82             args = {
83                 auras = {
84                     type = "input",
85                     name = "Auras",
86                     multiline = true,
87                     width = "full",
88                     get = function(item)
89                         return table.concat(self.db.profile.indicators[pos]["auras"], "\n");
90                     end,
91                     set = function(item, value)
92                         local t = {};
93                         for aura in string.gmatch(value, "[^\n]+") do
94                             aura = string.gsub(aura, "^%s*(.-)%s$", "%1");
95                             if tonumber(aura) then
96                                 table.insert(t, tonumber(aura));
97                             else
98                                 table.insert(t, aura);
99                             end
100                         end
101                         self.db.profile.indicators[pos]["auras"] = t;
102                         self:RefreshConfig();
103                     end,
104                 },
105                 mine = {
106                     type = "toggle",
107                     name = "Only cast by me",
108                 },
109                 showText = {
110                     type = "toggle",
111                     name = "Show remaining time",
112                 },
113                 textSize = {
114                     type = "range",
115                     name = "Text size",
116                     min = 1,
117                     max = 30,
118                     step = 1,
119                     width = "full",
120                 },
121                 textColor = {
122                     type = "color",
123                     name = "Text color",
124                     get = function(item)
125                         return unpack(self.db.profile.indicators[pos]["textColor"]);
126                     end,
127                     set = function(item, r, g, b, a)
128                         self.db.profile.indicators[pos]["textColor"] = {r, g, b, a};
129                         self:RefreshConfig();
130                     end,
131                 },
132                 stack = {
133                     type = "toggle",
134                     name = "Show stacks",
135                 },
136                 showIcon = {
137                     type = "toggle",
138                     name = "Show icon",
139                 },
140                 useDefaultIcon = {
141                     type = "toggle",
142                     name = "Use default icon",
143                     disabled = function() return not self.db.profile.indicators[pos]["showIcon"] end,
144                 },
145                 iconSize = {
146                     type = "range",
147                     name = "Icon size",
148                     min = 1,
149                     max = 30,
150                     step = 1,
151                     width = "full",
152                 },
153                 iconColor = {
154                     type = "color",
155                     name = "Icon tint",
156                     get = function(item)
157                         return unpack(self.db.profile.indicators[pos]["iconColor"]);
158                     end,
159                     set = function(item, r, g, b, a)
160                         self.db.profile.indicators[pos]["iconColor"] = {r, g, b, a};
161                         self:RefreshConfig();
162                     end,
163                 },
164             }
165         };
166     end
167     return options;
168 end
169
170 local profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(OmaRF.db);
171 local options = createOptionsTable(OmaRF);
172 local config = LibStub("AceConfig-3.0");
173 config:RegisterOptionsTable("Indicators", options);
174 config:RegisterOptionsTable("Indicators Profiles", profiles);
175
176 local dialog = LibStub("AceConfigDialog-3.0");
177 OmaRF.optionsFrames = {};
178 OmaRF.optionsFrames.Indicators = dialog:AddToBlizOptions("Indicators", "Indicators");
179 OmaRF.optionsFrames.Profile = dialog:AddToBlizOptions("Indicators Profiles", "Profiles", "Indicators");