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