flickerstreak@7
|
1 -- Buttons.lua
|
flickerstreak@7
|
2 --
|
flickerstreak@7
|
3 -- Defines button types for use with the ReAction AddOn
|
flickerstreak@7
|
4 --
|
flickerstreak@7
|
5
|
flickerstreak@7
|
6 local AceOO = AceLibrary("AceOO-2.0")
|
flickerstreak@7
|
7
|
flickerstreak@7
|
8 local Action = AceOO.Class(
|
flickerstreak@7
|
9 ReAction,
|
flickerstreak@7
|
10 ReAction.ActionType,
|
flickerstreak@7
|
11 ReAction.ActionDisplay,
|
flickerstreak@7
|
12 ReAction.DefaultColorScheme
|
flickerstreak@7
|
13 )
|
flickerstreak@7
|
14
|
flickerstreak@7
|
15 local PetAction = AceOO.Class(
|
flickerstreak@7
|
16 ReAction,
|
flickerstreak@7
|
17 ReAction.PetActionType,
|
flickerstreak@7
|
18 ReAction.PetActionDisplay,
|
flickerstreak@7
|
19 ReAction.DefaultColorScheme
|
flickerstreak@7
|
20 )
|
flickerstreak@7
|
21
|
flickerstreak@7
|
22
|
flickerstreak@7
|
23 ReAction:AddButtonType( "Action", Action, 120 )
|
flickerstreak@7
|
24 ReAction:AddButtonType( "Pet Action", PetAction, 10 )
|
flickerstreak@7
|
25
|
flickerstreak@7
|
26
|
flickerstreak@7
|
27
|
flickerstreak@7
|
28 -----------------------
|
flickerstreak@7
|
29 -- static class members
|
flickerstreak@7
|
30 -----------------------
|
flickerstreak@7
|
31 Action.defaultProfile = {
|
flickerstreak@7
|
32 type = "ReAction",
|
flickerstreak@7
|
33 subtype = "Action",
|
flickerstreak@7
|
34 ids = { },
|
flickerstreak@7
|
35 selfcast = nil,
|
flickerstreak@7
|
36 keyBindLoc = "TOPRIGHT",
|
flickerstreak@7
|
37 stackCountLoc = "BOTTOMRIGHT",
|
flickerstreak@7
|
38 showKeyBind = true,
|
flickerstreak@7
|
39 showStackCount = true,
|
flickerstreak@7
|
40 showMacroText = true,
|
flickerstreak@7
|
41 showBorder = true,
|
flickerstreak@7
|
42 keyBindColorCode = false,
|
flickerstreak@8
|
43 hideCooldown = false,
|
flickerstreak@8
|
44 hideGlobalCooldown = false,
|
flickerstreak@7
|
45 }
|
flickerstreak@7
|
46
|
flickerstreak@7
|
47 PetAction.defaultProfile = {
|
flickerstreak@7
|
48 type = "ReAction",
|
flickerstreak@7
|
49 subtype = "Pet Action",
|
flickerstreak@7
|
50 ids = { },
|
flickerstreak@7
|
51 keyBindLoc = "TOPRIGHT",
|
flickerstreak@7
|
52 showKeyBind = false,
|
flickerstreak@7
|
53 showGrid = false,
|
flickerstreak@7
|
54 showBorder = true,
|
flickerstreak@7
|
55 keyBindColorCode = false,
|
flickerstreak@7
|
56 }
|
flickerstreak@7
|
57
|
flickerstreak@7
|
58
|
flickerstreak@7
|
59
|
flickerstreak@7
|
60 -----------------------
|
flickerstreak@7
|
61 -- static class methods
|
flickerstreak@7
|
62 -----------------------
|
flickerstreak@7
|
63 function Action:GetDefaultProfile()
|
flickerstreak@7
|
64 return self.defaultProfile
|
flickerstreak@7
|
65 end
|
flickerstreak@7
|
66
|
flickerstreak@7
|
67 function PetAction:GetDefaultProfile()
|
flickerstreak@7
|
68 return self.defaultProfile
|
flickerstreak@7
|
69 end
|
flickerstreak@7
|
70
|
flickerstreak@7
|
71
|
flickerstreak@7
|
72
|
flickerstreak@7
|
73 local labelPlacementOptions = {
|
flickerstreak@7
|
74 "TOP",
|
flickerstreak@7
|
75 "BOTTOM",
|
flickerstreak@7
|
76 "LEFT",
|
flickerstreak@7
|
77 "RIGHT",
|
flickerstreak@7
|
78 "TOPLEFT",
|
flickerstreak@7
|
79 "TOPRIGHT",
|
flickerstreak@7
|
80 "BOTTOMLEFT",
|
flickerstreak@7
|
81 "BOTTOMRIGHT"
|
flickerstreak@7
|
82 }
|
flickerstreak@7
|
83
|
flickerstreak@7
|
84
|
flickerstreak@7
|
85 function Action:GenerateOptionsTable( config, buttonListFunc )
|
flickerstreak@7
|
86
|
flickerstreak@7
|
87 local function refresh()
|
flickerstreak@7
|
88 for _, b in pairs(buttonListFunc()) do
|
flickerstreak@7
|
89 b:UpdateAction()
|
flickerstreak@7
|
90 b:UpdateTooltip()
|
flickerstreak@7
|
91 b:UpdateDisplay()
|
flickerstreak@7
|
92 end
|
flickerstreak@7
|
93 end
|
flickerstreak@7
|
94
|
flickerstreak@8
|
95 local function setOpacity(field, value)
|
flickerstreak@8
|
96 if not config.opacity then
|
flickerstreak@8
|
97 config.opacity = { }
|
flickerstreak@8
|
98 end
|
flickerstreak@8
|
99 config.opacity[field] = (value and value / 100)
|
flickerstreak@8
|
100 refresh()
|
flickerstreak@8
|
101 end
|
flickerstreak@8
|
102
|
flickerstreak@8
|
103 local function getOpacity(field, default)
|
flickerstreak@8
|
104 local o = config.opacity and config.opacity[field] or (default and default/100) or 1
|
flickerstreak@8
|
105 return o * 100
|
flickerstreak@8
|
106 end
|
flickerstreak@8
|
107
|
flickerstreak@7
|
108 return {
|
flickerstreak@7
|
109 type = "group",
|
flickerstreak@7
|
110 args = {
|
flickerstreak@7
|
111 selfcast = {
|
flickerstreak@7
|
112 type = "text",
|
flickerstreak@7
|
113 name = "Self Cast",
|
flickerstreak@7
|
114 desc = "Choose a modifier key to hold down or an alternate button to click to self-cast spells. "..
|
flickerstreak@7
|
115 "'default' uses the settings in the Interface Options Advanced panel (use this to achieve 'smart self cast'). "..
|
flickerstreak@7
|
116 "'right-click' self-casting is not supported for multi-page bars.",
|
flickerstreak@7
|
117 get = function() return config.selfcast or "default" end,
|
flickerstreak@7
|
118 set = function(opt)
|
flickerstreak@7
|
119 if opt == "default" then opt = nil end
|
flickerstreak@7
|
120 config.selfcast = opt
|
flickerstreak@7
|
121 for _, b in pairs(buttonListFunc()) do
|
flickerstreak@7
|
122 b:UpdateSelfcast()
|
flickerstreak@7
|
123 end
|
flickerstreak@7
|
124 end,
|
flickerstreak@7
|
125 validate = { "default", "none", "alt", "ctrl", "shift", "right-click" },
|
flickerstreak@7
|
126 },
|
flickerstreak@7
|
127
|
flickerstreak@8
|
128 opacity = {
|
flickerstreak@8
|
129 type = "group",
|
flickerstreak@8
|
130 name = "Opacity",
|
flickerstreak@8
|
131 desc = "Set options for variable button opacity",
|
flickerstreak@8
|
132 args = {
|
flickerstreak@8
|
133 usable = {
|
flickerstreak@8
|
134 type = "range",
|
flickerstreak@8
|
135 name = "Usable",
|
flickerstreak@8
|
136 desc = "Button opacity when the action is currently usable",
|
flickerstreak@8
|
137 min = 0,
|
flickerstreak@8
|
138 max = 100,
|
flickerstreak@8
|
139 step = 1,
|
flickerstreak@8
|
140 get = function() return getOpacity("usable") end,
|
flickerstreak@8
|
141 set = function(x) setOpacity("usable", x) end,
|
flickerstreak@8
|
142 order = 1,
|
flickerstreak@8
|
143 },
|
flickerstreak@8
|
144
|
flickerstreak@8
|
145 notUsable = {
|
flickerstreak@8
|
146 type = "range",
|
flickerstreak@8
|
147 name = "Not Usable",
|
flickerstreak@8
|
148 desc = "Button opacity when the action is currently not usable",
|
flickerstreak@8
|
149 min = 0,
|
flickerstreak@8
|
150 max = 100,
|
flickerstreak@8
|
151 step = 1,
|
flickerstreak@8
|
152 get = function() return getOpacity("notUsable") end,
|
flickerstreak@8
|
153 set = function(x) setOpacity("notUsable",x) end,
|
flickerstreak@8
|
154 order = 2,
|
flickerstreak@8
|
155 },
|
flickerstreak@8
|
156
|
flickerstreak@8
|
157 oom = {
|
flickerstreak@8
|
158 type = "range",
|
flickerstreak@8
|
159 name = "Out of Power",
|
flickerstreak@8
|
160 desc = "Button opacity when the action is not usable due to not enough mana/energy/rage. "..
|
flickerstreak@8
|
161 "By default this uses the generic 'not-usable' setting.",
|
flickerstreak@8
|
162 min = 0,
|
flickerstreak@8
|
163 max = 100,
|
flickerstreak@8
|
164 step = 1,
|
flickerstreak@8
|
165 get = function() return getOpacity("oom",getOpacity("notUsable")) end,
|
flickerstreak@8
|
166 set = function(x) setOpacity("oom", x ~= getOpacity("notUsable") and x) end,
|
flickerstreak@8
|
167 order = 3,
|
flickerstreak@8
|
168 },
|
flickerstreak@8
|
169
|
flickerstreak@8
|
170 oorange = {
|
flickerstreak@8
|
171 type = "range",
|
flickerstreak@8
|
172 name = "Out of Range",
|
flickerstreak@8
|
173 desc = "Button opacity when the action is not usable due to the target not being in range. "..
|
flickerstreak@8
|
174 "By default this uses the generic 'not-usable' setting.",
|
flickerstreak@8
|
175 min = 0,
|
flickerstreak@8
|
176 max = 100,
|
flickerstreak@8
|
177 step = 1,
|
flickerstreak@8
|
178 get = function() return getOpacity("ooRange",getOpacity("notUsable")) end,
|
flickerstreak@8
|
179 set = function(x) setOpacity("ooRange", x ~= getOpacity("notUsable") and x) end,
|
flickerstreak@8
|
180 order = 4,
|
flickerstreak@8
|
181 },
|
flickerstreak@8
|
182
|
flickerstreak@8
|
183 empty = {
|
flickerstreak@8
|
184 type = "range",
|
flickerstreak@8
|
185 name = "Empty Slot",
|
flickerstreak@8
|
186 desc = "Button opacity when the button's action slot is empty. By default this is 0 (fully transparent), "..
|
flickerstreak@8
|
187 "but note that they still block mouse clicks. Empty slots are automatically made opaque (per the "..
|
flickerstreak@8
|
188 "'usable' opacity setting) when moving actions around.",
|
flickerstreak@8
|
189 min = 0,
|
flickerstreak@8
|
190 max = 100,
|
flickerstreak@8
|
191 step = 1,
|
flickerstreak@8
|
192 get = function() return getOpacity("empty",0) end,
|
flickerstreak@8
|
193 set = function(x) setOpacity("empty",x) end,
|
flickerstreak@8
|
194 order = 5,
|
flickerstreak@8
|
195 },
|
flickerstreak@8
|
196
|
flickerstreak@8
|
197 hideEmpty = {
|
flickerstreak@8
|
198 type = "toggle",
|
flickerstreak@8
|
199 name = "Hide Empty Slots",
|
flickerstreak@8
|
200 desc = "Hides empty action slots rather than changing their opacity. This has the advantage that empty slots "..
|
flickerstreak@8
|
201 "don't block mouse clicks. WARNING: this makes it impossible to re-arrange actions with drag-and-drop "..
|
flickerstreak@8
|
202 "while in combat.",
|
flickerstreak@8
|
203 get = function() return config.hideEmptySlots end,
|
flickerstreak@8
|
204 set = function() config.hideEmptySlots = not config.hideEmptySlots ; refresh() end,
|
flickerstreak@8
|
205 order = 6,
|
flickerstreak@8
|
206 },
|
flickerstreak@8
|
207
|
flickerstreak@8
|
208 },
|
flickerstreak@8
|
209 },
|
flickerstreak@8
|
210
|
flickerstreak@7
|
211 keyloc = {
|
flickerstreak@7
|
212 type = "text",
|
flickerstreak@7
|
213 name = "Hotkey Location",
|
flickerstreak@7
|
214 desc = "Sets hotkey location",
|
flickerstreak@7
|
215 get = function() return config.keyBindLoc end,
|
flickerstreak@7
|
216 set = function(loc) config.keyBindLoc = loc ; refresh() end,
|
flickerstreak@7
|
217 validate = labelPlacementOptions,
|
flickerstreak@7
|
218 },
|
flickerstreak@7
|
219
|
flickerstreak@7
|
220 stackloc = {
|
flickerstreak@7
|
221 type = "text",
|
flickerstreak@7
|
222 name = "Stack Count Location",
|
flickerstreak@7
|
223 desc = "Sets stack count location",
|
flickerstreak@7
|
224 get = function() return config.stackCountLoc end,
|
flickerstreak@7
|
225 set = function(loc) config.stackCountLoc = loc ; refresh() end,
|
flickerstreak@7
|
226 validate = labelPlacementOptions,
|
flickerstreak@7
|
227 },
|
flickerstreak@7
|
228
|
flickerstreak@7
|
229 showkeybind = {
|
flickerstreak@7
|
230 type = "toggle",
|
flickerstreak@7
|
231 name = "Show Hotkey",
|
flickerstreak@7
|
232 desc = "Toggle show/hide hot key labels",
|
flickerstreak@7
|
233 get = function() return config.showKeyBind end,
|
flickerstreak@7
|
234 set = function() config.showKeyBind = not config.showKeyBind ; refresh() end,
|
flickerstreak@7
|
235 },
|
flickerstreak@7
|
236
|
flickerstreak@7
|
237 showstackcount = {
|
flickerstreak@7
|
238 type = "toggle",
|
flickerstreak@7
|
239 name = "Show Stack Count",
|
flickerstreak@7
|
240 desc = "Toggle show/hide stack count labels",
|
flickerstreak@7
|
241 get = function() return config.showStackCount end,
|
flickerstreak@7
|
242 set = function() config.showStackCount = not config.showStackCount ; refresh() end,
|
flickerstreak@7
|
243 },
|
flickerstreak@7
|
244
|
flickerstreak@7
|
245 showmacrotext = {
|
flickerstreak@7
|
246 type = "toggle",
|
flickerstreak@7
|
247 name = "Show Macro Names",
|
flickerstreak@7
|
248 desc = "Toggle show/hide macro name labels",
|
flickerstreak@7
|
249 get = function() return config.showMacroText end,
|
flickerstreak@7
|
250 set = function() config.showMacroText = not config.showMacroText ; refresh() end,
|
flickerstreak@7
|
251 },
|
flickerstreak@7
|
252
|
flickerstreak@8
|
253 hidecooldown = {
|
flickerstreak@7
|
254 type = "toggle",
|
flickerstreak@8
|
255 name = "Hide Cooldowns",
|
flickerstreak@8
|
256 desc = "Hides all cooldown displays on buttons. Toggling this on does not hide currently running cooldowns.",
|
flickerstreak@8
|
257 get = function() return config.hideCooldown end,
|
flickerstreak@8
|
258 set = function() config.hideCooldown = not config.hideCooldown ; refresh() end,
|
flickerstreak@8
|
259 },
|
flickerstreak@8
|
260
|
flickerstreak@8
|
261 hideglobalcooldown = {
|
flickerstreak@8
|
262 type = "toggle",
|
flickerstreak@8
|
263 name = "Hide Global Cooldown",
|
flickerstreak@8
|
264 desc = "Disables the global cooldown from being displayed on buttons.",
|
flickerstreak@8
|
265 get = function() return config.hideGlobalCooldown end,
|
flickerstreak@8
|
266 set = function() config.hideGlobalCooldown = not config.hideGlobalCooldown ; refresh() end,
|
flickerstreak@7
|
267 },
|
flickerstreak@7
|
268
|
flickerstreak@7
|
269 colorhotkeys = {
|
flickerstreak@7
|
270 type = "toggle",
|
flickerstreak@7
|
271 name = "Colorize Hotkeys",
|
flickerstreak@7
|
272 desc = "Toggles coloring hotkeys based on the modifier key. Out-of-range coloring is always enabled.",
|
flickerstreak@7
|
273 get = function() return config.keyBindColorCode end,
|
flickerstreak@7
|
274 set = function() config.keyBindColorCode = not config.keyBindColorCode ; refresh() end,
|
flickerstreak@7
|
275 },
|
flickerstreak@7
|
276
|
flickerstreak@7
|
277 --[[
|
flickerstreak@7
|
278 hideborder = {
|
flickerstreak@7
|
279 type = "toggle",
|
flickerstreak@7
|
280 name = "Hide Border",
|
flickerstreak@7
|
281 desc = "Toggles hiding of the button border frame.",
|
flickerstreak@7
|
282 get = function() return not config.showBorder end,
|
flickerstreak@7
|
283 set = function() config.showBorder = not config.showBorder ; refresh() end,
|
flickerstreak@7
|
284 },]]
|
flickerstreak@7
|
285 }
|
flickerstreak@7
|
286 }
|
flickerstreak@7
|
287 end
|
flickerstreak@7
|
288
|
flickerstreak@7
|
289
|
flickerstreak@7
|
290 function PetAction:GenerateOptionsTable( config, buttonListFunc )
|
flickerstreak@7
|
291
|
flickerstreak@7
|
292 local function refresh()
|
flickerstreak@7
|
293 for _, b in pairs(buttonListFunc()) do
|
flickerstreak@7
|
294 b:UpdateAction()
|
flickerstreak@7
|
295 b:UpdateTooltip()
|
flickerstreak@7
|
296 b:UpdateDisplay()
|
flickerstreak@7
|
297 end
|
flickerstreak@7
|
298 end
|
flickerstreak@7
|
299
|
flickerstreak@7
|
300 return {
|
flickerstreak@7
|
301 type = "group",
|
flickerstreak@7
|
302 args = {
|
flickerstreak@7
|
303 keyloc = {
|
flickerstreak@7
|
304 type = "text",
|
flickerstreak@7
|
305 name = "Hotkey Location",
|
flickerstreak@7
|
306 desc = "Sets hotkey location",
|
flickerstreak@7
|
307 get = function() return config.keyBindLoc end,
|
flickerstreak@7
|
308 set = function(loc) config.keyBindLoc = loc ; refresh() end,
|
flickerstreak@7
|
309 validate = { "TOP", "BOTTOM", "LEFT", "RIGHT", "TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT" },
|
flickerstreak@7
|
310 },
|
flickerstreak@7
|
311
|
flickerstreak@7
|
312 showkeybind = {
|
flickerstreak@7
|
313 type = "toggle",
|
flickerstreak@7
|
314 name = "Show Hotkey",
|
flickerstreak@7
|
315 desc = "Toggle show/hide hot key labels",
|
flickerstreak@7
|
316 get = function() return config.showKeyBind end,
|
flickerstreak@7
|
317 set = function() config.showKeyBind = not config.showGrid ; refresh() end,
|
flickerstreak@7
|
318 },
|
flickerstreak@7
|
319
|
flickerstreak@7
|
320 showgrid = {
|
flickerstreak@7
|
321 type = "toggle",
|
flickerstreak@7
|
322 name = "Always Show Buttons",
|
flickerstreak@7
|
323 desc = "Show button placeholders when no action is assigned or on the cursor. Note that buttons are always shown when bars are unlocked.",
|
flickerstreak@7
|
324 get = function() return config.showGrid end,
|
flickerstreak@7
|
325 set = function() config.showGrid = not config.showGrid ; refresh() end,
|
flickerstreak@7
|
326 },
|
flickerstreak@7
|
327
|
flickerstreak@7
|
328 colorhotkeys = {
|
flickerstreak@7
|
329 type = "toggle",
|
flickerstreak@7
|
330 name = "Colorize Hotkeys",
|
flickerstreak@7
|
331 desc = "Toggles coloring hotkeys based on the modifier key. Out-of-range coloring is always enabled.",
|
flickerstreak@7
|
332 get = function() return config.keyBindColorCode end,
|
flickerstreak@7
|
333 set = function() config.keyBindColorCode = not config.keyBindColorCode ; refresh() end,
|
flickerstreak@7
|
334 },
|
flickerstreak@7
|
335
|
flickerstreak@7
|
336 --[[
|
flickerstreak@7
|
337 hideborder = {
|
flickerstreak@7
|
338 type = "toggle",
|
flickerstreak@7
|
339 name = "Hide Border",
|
flickerstreak@7
|
340 desc = "Toggles hiding of the button border frame.",
|
flickerstreak@7
|
341 get = function() return not config.showBorder end,
|
flickerstreak@7
|
342 set = function() config.showBorder = not config.showBorder ; refresh() end,
|
flickerstreak@7
|
343 },]]
|
flickerstreak@7
|
344 }
|
flickerstreak@7
|
345 }
|
flickerstreak@7
|
346 end
|
flickerstreak@7
|
347
|
flickerstreak@7
|
348
|
flickerstreak@7
|
349
|
flickerstreak@7
|
350 ----------------------
|
flickerstreak@7
|
351 -- Instance methods
|
flickerstreak@7
|
352 ----------------------
|
flickerstreak@7
|
353 function Action.prototype:init( id )
|
flickerstreak@7
|
354 Action.super.prototype.init(self)
|
flickerstreak@7
|
355
|
flickerstreak@7
|
356 self:SetupDisplay("ReActionButton"..id)
|
flickerstreak@7
|
357 self:SetupAction()
|
flickerstreak@7
|
358
|
flickerstreak@7
|
359 -- register button with ReBound for keybinding
|
flickerstreak@7
|
360 if ReBound then
|
flickerstreak@7
|
361 ReBound:AddKeybindTarget(self:GetActionFrame())
|
flickerstreak@7
|
362 end
|
flickerstreak@7
|
363 end
|
flickerstreak@7
|
364
|
flickerstreak@7
|
365 function PetAction.prototype:init( id )
|
flickerstreak@7
|
366 Action.super.prototype.init(self)
|
flickerstreak@7
|
367
|
flickerstreak@7
|
368 self:SetupDisplay("ReActionPetButton"..id)
|
flickerstreak@7
|
369 self:SetupAction()
|
flickerstreak@7
|
370
|
flickerstreak@7
|
371 -- register button with ReBound for keybinding
|
flickerstreak@7
|
372 if ReBound then
|
flickerstreak@7
|
373 ReBound:AddKeybindTarget(self:GetActionFrame())
|
flickerstreak@7
|
374 end
|
flickerstreak@7
|
375 end
|
flickerstreak@7
|
376
|