comparison Buttons.lua @ 7:f920db5fc6b1

version 0.3
author Flick <flickerstreak@gmail.com>
date Tue, 20 Mar 2007 21:25:29 +0000
parents
children c05fd3e18b4f
comparison
equal deleted inserted replaced
6:2da5089ab7ff 7:f920db5fc6b1
1 -- Buttons.lua
2 --
3 -- Defines button types for use with the ReAction AddOn
4 --
5
6 local AceOO = AceLibrary("AceOO-2.0")
7
8 local Action = AceOO.Class(
9 ReAction,
10 ReAction.ActionType,
11 ReAction.ActionDisplay,
12 ReAction.DefaultColorScheme
13 )
14
15 local PetAction = AceOO.Class(
16 ReAction,
17 ReAction.PetActionType,
18 ReAction.PetActionDisplay,
19 ReAction.DefaultColorScheme
20 )
21
22
23 ReAction:AddButtonType( "Action", Action, 120 )
24 ReAction:AddButtonType( "Pet Action", PetAction, 10 )
25
26
27
28 -----------------------
29 -- static class members
30 -----------------------
31 Action.defaultProfile = {
32 type = "ReAction",
33 subtype = "Action",
34 ids = { },
35 selfcast = nil,
36 keyBindLoc = "TOPRIGHT",
37 stackCountLoc = "BOTTOMRIGHT",
38 showKeyBind = true,
39 showStackCount = true,
40 showMacroText = true,
41 showGrid = false,
42 showBorder = true,
43 keyBindColorCode = false,
44 }
45
46 PetAction.defaultProfile = {
47 type = "ReAction",
48 subtype = "Pet Action",
49 ids = { },
50 keyBindLoc = "TOPRIGHT",
51 showKeyBind = false,
52 showGrid = false,
53 showBorder = true,
54 keyBindColorCode = false,
55 }
56
57
58
59 -----------------------
60 -- static class methods
61 -----------------------
62 function Action:GetDefaultProfile()
63 return self.defaultProfile
64 end
65
66 function PetAction:GetDefaultProfile()
67 return self.defaultProfile
68 end
69
70
71
72 local labelPlacementOptions = {
73 "TOP",
74 "BOTTOM",
75 "LEFT",
76 "RIGHT",
77 "TOPLEFT",
78 "TOPRIGHT",
79 "BOTTOMLEFT",
80 "BOTTOMRIGHT"
81 }
82
83
84 function Action:GenerateOptionsTable( config, buttonListFunc )
85
86 local function refresh()
87 for _, b in pairs(buttonListFunc()) do
88 b:UpdateAction()
89 b:UpdateTooltip()
90 b:UpdateDisplay()
91 end
92 end
93
94 return {
95 type = "group",
96 args = {
97 selfcast = {
98 type = "text",
99 name = "Self Cast",
100 desc = "Choose a modifier key to hold down or an alternate button to click to self-cast spells. "..
101 "'default' uses the settings in the Interface Options Advanced panel (use this to achieve 'smart self cast'). "..
102 "'right-click' self-casting is not supported for multi-page bars.",
103 get = function() return config.selfcast or "default" end,
104 set = function(opt)
105 if opt == "default" then opt = nil end
106 config.selfcast = opt
107 for _, b in pairs(buttonListFunc()) do
108 b:UpdateSelfcast()
109 end
110 end,
111 validate = { "default", "none", "alt", "ctrl", "shift", "right-click" },
112 },
113
114 keyloc = {
115 type = "text",
116 name = "Hotkey Location",
117 desc = "Sets hotkey location",
118 get = function() return config.keyBindLoc end,
119 set = function(loc) config.keyBindLoc = loc ; refresh() end,
120 validate = labelPlacementOptions,
121 },
122
123 stackloc = {
124 type = "text",
125 name = "Stack Count Location",
126 desc = "Sets stack count location",
127 get = function() return config.stackCountLoc end,
128 set = function(loc) config.stackCountLoc = loc ; refresh() end,
129 validate = labelPlacementOptions,
130 },
131
132 showkeybind = {
133 type = "toggle",
134 name = "Show Hotkey",
135 desc = "Toggle show/hide hot key labels",
136 get = function() return config.showKeyBind end,
137 set = function() config.showKeyBind = not config.showKeyBind ; refresh() end,
138 },
139
140 showstackcount = {
141 type = "toggle",
142 name = "Show Stack Count",
143 desc = "Toggle show/hide stack count labels",
144 get = function() return config.showStackCount end,
145 set = function() config.showStackCount = not config.showStackCount ; refresh() end,
146 },
147
148 showmacrotext = {
149 type = "toggle",
150 name = "Show Macro Names",
151 desc = "Toggle show/hide macro name labels",
152 get = function() return config.showMacroText end,
153 set = function() config.showMacroText = not config.showMacroText ; refresh() end,
154 },
155
156 showgrid = {
157 type = "toggle",
158 name = "Always Show Buttons",
159 desc = "Show button placeholders when no action is assigned or on the cursor. Note that buttons are always shown when bars are unlocked.",
160 get = function() return config.showGrid end,
161 set = function() config.showGrid = not config.showGrid ; refresh() end,
162 },
163
164 colorhotkeys = {
165 type = "toggle",
166 name = "Colorize Hotkeys",
167 desc = "Toggles coloring hotkeys based on the modifier key. Out-of-range coloring is always enabled.",
168 get = function() return config.keyBindColorCode end,
169 set = function() config.keyBindColorCode = not config.keyBindColorCode ; refresh() end,
170 },
171
172 --[[
173 hideborder = {
174 type = "toggle",
175 name = "Hide Border",
176 desc = "Toggles hiding of the button border frame.",
177 get = function() return not config.showBorder end,
178 set = function() config.showBorder = not config.showBorder ; refresh() end,
179 },]]
180 }
181 }
182 end
183
184
185 function PetAction:GenerateOptionsTable( config, buttonListFunc )
186
187 local function refresh()
188 for _, b in pairs(buttonListFunc()) do
189 b:UpdateAction()
190 b:UpdateTooltip()
191 b:UpdateDisplay()
192 end
193 end
194
195 return {
196 type = "group",
197 args = {
198 keyloc = {
199 type = "text",
200 name = "Hotkey Location",
201 desc = "Sets hotkey location",
202 get = function() return config.keyBindLoc end,
203 set = function(loc) config.keyBindLoc = loc ; refresh() end,
204 validate = { "TOP", "BOTTOM", "LEFT", "RIGHT", "TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT" },
205 },
206
207 showkeybind = {
208 type = "toggle",
209 name = "Show Hotkey",
210 desc = "Toggle show/hide hot key labels",
211 get = function() return config.showKeyBind end,
212 set = function() config.showKeyBind = not config.showGrid ; refresh() end,
213 },
214
215 showgrid = {
216 type = "toggle",
217 name = "Always Show Buttons",
218 desc = "Show button placeholders when no action is assigned or on the cursor. Note that buttons are always shown when bars are unlocked.",
219 get = function() return config.showGrid end,
220 set = function() config.showGrid = not config.showGrid ; refresh() end,
221 },
222
223 colorhotkeys = {
224 type = "toggle",
225 name = "Colorize Hotkeys",
226 desc = "Toggles coloring hotkeys based on the modifier key. Out-of-range coloring is always enabled.",
227 get = function() return config.keyBindColorCode end,
228 set = function() config.keyBindColorCode = not config.keyBindColorCode ; refresh() end,
229 },
230
231 --[[
232 hideborder = {
233 type = "toggle",
234 name = "Hide Border",
235 desc = "Toggles hiding of the button border frame.",
236 get = function() return not config.showBorder end,
237 set = function() config.showBorder = not config.showBorder ; refresh() end,
238 },]]
239 }
240 }
241 end
242
243
244
245 ----------------------
246 -- Instance methods
247 ----------------------
248 function Action.prototype:init( id )
249 Action.super.prototype.init(self)
250
251 self:SetupDisplay("ReActionButton"..id)
252 self:SetupAction()
253
254 -- register button with ReBound for keybinding
255 if ReBound then
256 ReBound:AddKeybindTarget(self:GetActionFrame())
257 end
258 end
259
260 function PetAction.prototype:init( id )
261 Action.super.prototype.init(self)
262
263 self:SetupDisplay("ReActionPetButton"..id)
264 self:SetupAction()
265
266 -- register button with ReBound for keybinding
267 if ReBound then
268 ReBound:AddKeybindTarget(self:GetActionFrame())
269 end
270 end
271