b8c7045 - Rename
[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             indicatorFont = {
12                 type = "select",
13                 dialogControl = "LSM30_Font",
14                 name = "Indicator font",
15                 values = AceGUIWidgetLSMlists.font,
16             },
17         }
18     };
19
20     for _, pos in ipairs(self.positions) do
21         options.args[pos] = {
22             type = "group",
23             get = function(item)
24                 return self.db.profile[pos][item[#item]];
25             end,
26             set = function(item, value)
27                 self.db.profile[pos][item[#item]] = value;
28                 self:RefreshConfig();
29             end,
30             args = {
31                 auras = {
32                     type = "input",
33                     name = "Auras",
34                     multiline = true,
35                     width = "full",
36                     get = function(item)
37                         return table.concat(self.db.profile[pos]["auras"], "\n");
38                     end,
39                     set = function(item, value)
40                         local t = {};
41                         for aura in string.gmatch(value, "[^\n]+") do
42                             aura = string.gsub(aura, "^%s*(.-)%s$", "%1");
43                             if tonumber(aura) then
44                                 table.insert(t, tonumber(aura));
45                             else
46                                 table.insert(t, aura);
47                             end
48                         end
49                         self.db.profile[pos]["auras"] = t;
50                         self:RefreshConfig();
51                     end,
52                 },
53                 mine = {
54                     type = "toggle",
55                     name = "Only cast by me",
56                 },
57                 showText = {
58                     type = "toggle",
59                     name = "Show remaining time",
60                 },
61                 textSize = {
62                     type = "range",
63                     name = "Text size",
64                     min = 1,
65                     max = 30,
66                     step = 1,
67                     width = "full",
68                 },
69                 textColor = {
70                     type = "color",
71                     name = "Text color",
72                     get = function(item)
73                         return unpack(self.db.profile[pos]["textColor"]);
74                     end,
75                     set = function(item, r, g, b, a)
76                         self.db.profile[pos]["textColor"] = {r, g, b, a};
77                         self:RefreshConfig();
78                     end,
79                 },
80                 stack = {
81                     type = "toggle",
82                     name = "Show stacks",
83                 },
84                 showIcon = {
85                     type = "toggle",
86                     name = "Show icon",
87                 },
88                 useDefaultIcon = {
89                     type = "toggle",
90                     name = "Use default icon",
91                     disabled = function() return not self.db.profile[pos]["showIcon"] end,
92                 },
93                 iconSize = {
94                     type = "range",
95                     name = "Icon size",
96                     min = 1,
97                     max = 30,
98                     step = 1,
99                     width = "full",
100                 },
101                 iconColor = {
102                     type = "color",
103                     name = "Icon tint",
104                     get = function(item)
105                         return unpack(self.db.profile[pos]["iconColor"]);
106                     end,
107                     set = function(item, r, g, b, a)
108                         self.db.profile[pos]["iconColor"] = {r, g, b, a};
109                         self:RefreshConfig();
110                     end,
111                 },
112             }
113         };
114     end
115     return options;
116 end
117
118 local profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(OmaRF.db);
119 local options = createOptionsTable(OmaRF);
120 local config = LibStub("AceConfig-3.0");
121 config:RegisterOptionsTable("Indicators", options);
122 config:RegisterOptionsTable("Indicators Profiles", profiles);
123
124 local dialog = LibStub("AceConfigDialog-3.0");
125 OmaRF.optionsFrames = {};
126 OmaRF.optionsFrames.Indicators = dialog:AddToBlizOptions("Indicators", "Indicators");
127 OmaRF.optionsFrames.Profile = dialog:AddToBlizOptions("Indicators Profiles", "Profiles", "Indicators");