flickerstreak@25
|
1 --[[
|
flickerstreak@25
|
2 ReAction Configuration UI module
|
flickerstreak@25
|
3
|
flickerstreak@33
|
4 Hooks into Blizzard Interface Options AddOns panel
|
flickerstreak@25
|
5 --]]
|
flickerstreak@25
|
6
|
flickerstreak@25
|
7 -- local imports
|
flickerstreak@25
|
8 local ReAction = ReAction
|
flickerstreak@25
|
9 local L = ReAction.L
|
flickerstreak@51
|
10 local _G = _G
|
flickerstreak@47
|
11 local AceConfigReg = LibStub("AceConfigRegistry-3.0")
|
flickerstreak@47
|
12 local AceConfigDialog = LibStub("AceConfigDialog-3.0")
|
flickerstreak@25
|
13
|
flickerstreak@80
|
14 ReAction:UpdateRevision("$Revision$")
|
flickerstreak@77
|
15
|
flickerstreak@51
|
16 -- some constants
|
flickerstreak@60
|
17 local configName = "ReAction"
|
flickerstreak@51
|
18
|
flickerstreak@25
|
19 -- module declaration
|
flickerstreak@25
|
20 local moduleID = "ConfigUI"
|
flickerstreak@47
|
21 local module = ReAction:NewModule( moduleID,
|
flickerstreak@47
|
22 "AceEvent-3.0"
|
flickerstreak@47
|
23 )
|
flickerstreak@25
|
24
|
flickerstreak@25
|
25 -- module methods
|
flickerstreak@25
|
26 function module:OnInitialize()
|
flickerstreak@47
|
27 self.db = ReAction.db:RegisterNamespace( moduleID,
|
flickerstreak@47
|
28 {
|
flickerstreak@47
|
29 profile = {
|
flickerstreak@47
|
30 closeOnLaunch = true,
|
flickerstreak@47
|
31 editorCloseOnLaunch = true,
|
flickerstreak@47
|
32 }
|
flickerstreak@47
|
33 }
|
flickerstreak@47
|
34 )
|
flickerstreak@47
|
35
|
flickerstreak@60
|
36 self:RegisterEvent("PLAYER_REGEN_DISABLED")
|
flickerstreak@60
|
37 ReAction.RegisterCallback(self,"OnOptionsRegistered","OnOptionsRefreshed")
|
flickerstreak@33
|
38 ReAction.RegisterCallback(self,"OnOptionsRefreshed")
|
flickerstreak@46
|
39 self:InitializeOptions()
|
flickerstreak@25
|
40 end
|
flickerstreak@25
|
41
|
flickerstreak@33
|
42 function module:OnOptionsRefreshed(evt)
|
flickerstreak@60
|
43 AceConfigReg:NotifyChange(configName)
|
flickerstreak@60
|
44 if self.editor then self.editor:Refresh() end
|
flickerstreak@47
|
45 end
|
flickerstreak@47
|
46
|
flickerstreak@47
|
47 function module:PLAYER_REGEN_DISABLED()
|
flickerstreak@47
|
48 if self.editor then
|
flickerstreak@47
|
49 self.editor:Hide()
|
flickerstreak@47
|
50 end
|
flickerstreak@47
|
51 end
|
flickerstreak@47
|
52
|
flickerstreak@47
|
53 function module:OpenConfig()
|
flickerstreak@60
|
54 InterfaceOptionsFrame_OpenToFrame(configName)
|
flickerstreak@47
|
55 end
|
flickerstreak@47
|
56
|
flickerstreak@46
|
57 function module:InitializeOptions()
|
flickerstreak@60
|
58 ReAction:RegisterOptions(self, {
|
flickerstreak@58
|
59 _launchEditor = {
|
flickerstreak@47
|
60 type = "execute",
|
flickerstreak@47
|
61 handler = self,
|
flickerstreak@58
|
62 name = L["Edit Bars..."],
|
flickerstreak@58
|
63 desc = L["Show the ReAction Bar Editor dialogue"],
|
flickerstreak@47
|
64 func = function()
|
flickerstreak@58
|
65 self:LaunchBarEditor()
|
flickerstreak@47
|
66 -- you can't close a dialog in response to an options click, because the end of the
|
flickerstreak@47
|
67 -- handler for all the button events calls lib:Open()
|
flickerstreak@47
|
68 -- So, schedule a close on the next OnUpdate
|
flickerstreak@47
|
69 if self.db.profile.closeOnLaunch then
|
flickerstreak@47
|
70 self.editor.closePending = true
|
flickerstreak@47
|
71 end
|
flickerstreak@47
|
72 end,
|
flickerstreak@47
|
73 order = 2,
|
flickerstreak@47
|
74 },
|
flickerstreak@47
|
75 _closeThis = {
|
flickerstreak@47
|
76 type = "toggle",
|
flickerstreak@47
|
77 name = L["Close on Launch"],
|
flickerstreak@58
|
78 desc = L["Close the Interface Options window when launching the ReAction Bar Editor"],
|
flickerstreak@47
|
79 get = function() return self.db.profile.closeOnLaunch end,
|
flickerstreak@47
|
80 set = function(info, val) self.db.profile.closeOnLaunch = val end,
|
flickerstreak@47
|
81 order = 3,
|
flickerstreak@47
|
82 },
|
flickerstreak@88
|
83 _keybind = {
|
flickerstreak@88
|
84 type = "execute",
|
flickerstreak@88
|
85 handler = self,
|
flickerstreak@88
|
86 name = L["Key Bindings"],
|
flickerstreak@88
|
87 desc = L["Show the keybinding dialogue"],
|
flickerstreak@88
|
88 func = function()
|
flickerstreak@88
|
89 ReAction:SetKeybindMode(true)
|
flickerstreak@88
|
90 end,
|
flickerstreak@88
|
91 order = 4,
|
flickerstreak@88
|
92 },
|
flickerstreak@60
|
93 }, true) -- global
|
flickerstreak@60
|
94
|
flickerstreak@60
|
95 AceConfigReg:RegisterOptionsTable(configName,ReAction.options)
|
flickerstreak@60
|
96 self.frame = AceConfigDialog:AddToBlizOptions(configName, configName)
|
flickerstreak@47
|
97 self.frame.obj:SetCallback("default",
|
flickerstreak@47
|
98 function()
|
flickerstreak@47
|
99 ReAction.db:ResetProfile()
|
flickerstreak@63
|
100 ReAction:RefreshOptions()
|
flickerstreak@47
|
101 end )
|
flickerstreak@60
|
102 end
|
flickerstreak@46
|
103
|
flickerstreak@60
|
104
|
flickerstreak@60
|
105
|
flickerstreak@60
|
106
|
flickerstreak@60
|
107 -- Bar Editor --
|
flickerstreak@60
|
108 local function NewEditor()
|
flickerstreak@60
|
109 -- private variables
|
flickerstreak@60
|
110 local editorName = "ReAction-Editor"
|
flickerstreak@63
|
111 local barOptMap = setmetatable({},{__mode="v"})
|
flickerstreak@60
|
112 local tmp = { }
|
flickerstreak@60
|
113 local pointTable = {
|
flickerstreak@60
|
114 CENTER = L["Center"],
|
flickerstreak@60
|
115 LEFT = L["Left"],
|
flickerstreak@60
|
116 RIGHT = L["Right"],
|
flickerstreak@60
|
117 TOP = L["Top"],
|
flickerstreak@60
|
118 BOTTOM = L["Bottom"],
|
flickerstreak@60
|
119 TOPLEFT = L["Top Left"],
|
flickerstreak@60
|
120 TOPRIGHT = L["Top Right"],
|
flickerstreak@60
|
121 BOTTOMLEFT = L["Bottom Left"],
|
flickerstreak@60
|
122 BOTTOMRIGHT = L["Bottom Right"],
|
flickerstreak@60
|
123 }
|
flickerstreak@60
|
124
|
flickerstreak@60
|
125
|
flickerstreak@60
|
126 -- use a local GUI container to work around AceConfigDialog closing
|
flickerstreak@60
|
127 -- both the bar editor and the global options when interface options is closed
|
flickerstreak@60
|
128 local editor = LibStub("AceGUI-3.0"):Create("Frame")
|
flickerstreak@60
|
129 local frame = editor.frame
|
flickerstreak@60
|
130 frame:SetClampedToScreen(true)
|
flickerstreak@60
|
131 local old_OnUpdate = frame:GetScript("OnUpdate")
|
flickerstreak@60
|
132 frame:SetScript("OnUpdate", function(dt)
|
flickerstreak@60
|
133 if old_OnUpdate then
|
flickerstreak@60
|
134 old_OnUpdate(dt)
|
flickerstreak@46
|
135 end
|
flickerstreak@60
|
136 if editor.closePending then
|
flickerstreak@60
|
137 InterfaceOptionsFrame:Hide()
|
flickerstreak@60
|
138 editor.closePending = false
|
flickerstreak@60
|
139 end
|
flickerstreak@60
|
140 if editor.selfClosePending then
|
flickerstreak@63
|
141 editor:Hide()
|
flickerstreak@60
|
142 AceConfigReg:NotifyChange(configName)
|
flickerstreak@60
|
143 editor.selfClosePending = false
|
flickerstreak@60
|
144 end
|
flickerstreak@60
|
145 end )
|
flickerstreak@60
|
146 editor:SetCallback("OnClose",
|
flickerstreak@60
|
147 function()
|
flickerstreak@60
|
148 ReAction:SetConfigMode(false)
|
flickerstreak@60
|
149 end )
|
flickerstreak@61
|
150 AceConfigDialog:SetDefaultSize(editorName, 700, 540)
|
flickerstreak@60
|
151
|
flickerstreak@46
|
152
|
flickerstreak@76
|
153 local name = ("ReAction - %s"):format(L["Bar Editor"])
|
flickerstreak@76
|
154 editor:SetTitle(name)
|
flickerstreak@60
|
155 local options = {
|
flickerstreak@47
|
156 type = "group",
|
flickerstreak@76
|
157 name = name,
|
flickerstreak@60
|
158 handler = editor,
|
flickerstreak@47
|
159 childGroups = "tree",
|
flickerstreak@47
|
160 args = {
|
flickerstreak@47
|
161 desc = {
|
flickerstreak@47
|
162 type = "description",
|
flickerstreak@47
|
163 name = L["Use the mouse to arrange and resize the bars on screen. Tooltips on bars indicate additional functionality."],
|
flickerstreak@47
|
164 order = 1
|
flickerstreak@47
|
165 },
|
flickerstreak@47
|
166 launchConfig = {
|
flickerstreak@47
|
167 type = "execute",
|
flickerstreak@47
|
168 name = L["Global Config"],
|
flickerstreak@47
|
169 desc = L["Opens ReAction global configuration settings panel"],
|
flickerstreak@47
|
170 func = function()
|
flickerstreak@60
|
171 module:OpenConfig()
|
flickerstreak@47
|
172 -- you can't close a dialog in response to an options click, because the end of the
|
flickerstreak@47
|
173 -- handler for all the button events calls lib:Open()
|
flickerstreak@48
|
174 -- So, schedule a close on the next OnUpdate
|
flickerstreak@60
|
175 if module.db.profile.editorCloseOnLaunch then
|
flickerstreak@60
|
176 editor.selfClosePending = true
|
flickerstreak@47
|
177 end
|
flickerstreak@47
|
178 end,
|
flickerstreak@47
|
179 order = 2
|
flickerstreak@47
|
180 },
|
flickerstreak@48
|
181 closeThis = {
|
flickerstreak@47
|
182 type = "toggle",
|
flickerstreak@47
|
183 name = L["Close on Launch"],
|
flickerstreak@58
|
184 desc = L["Close the Bar Editor when opening the ReAction global Interface Options"],
|
flickerstreak@60
|
185 get = function() return module.db.profile.editorCloseOnLaunch end,
|
flickerstreak@60
|
186 set = function(info, val) module.db.profile.editorCloseOnLaunch = val end,
|
flickerstreak@47
|
187 order = 3,
|
flickerstreak@47
|
188 },
|
flickerstreak@47
|
189 new = {
|
flickerstreak@47
|
190 type = "group",
|
flickerstreak@47
|
191 name = L["New Bar..."],
|
flickerstreak@47
|
192 order = 4,
|
flickerstreak@47
|
193 args = {
|
flickerstreak@47
|
194 desc = {
|
flickerstreak@47
|
195 type = "description",
|
flickerstreak@47
|
196 name = L["Choose a name, type, and initial grid for your new action bar:"],
|
flickerstreak@47
|
197 order = 1,
|
flickerstreak@47
|
198 },
|
flickerstreak@47
|
199 name = {
|
flickerstreak@47
|
200 type = "input",
|
flickerstreak@47
|
201 name = L["Bar Name"],
|
flickerstreak@47
|
202 desc = L["Enter a name for your new action bar"],
|
flickerstreak@60
|
203 get = function() return tmp.barName or "" end,
|
flickerstreak@60
|
204 set = function(info, val) tmp.barName = val end,
|
flickerstreak@47
|
205 order = 2,
|
flickerstreak@47
|
206 },
|
flickerstreak@47
|
207 type = {
|
flickerstreak@47
|
208 type = "select",
|
flickerstreak@47
|
209 name = L["Button Type"],
|
flickerstreak@63
|
210 get = function() return tmp.barType or ReAction:GetDefaultBarType() or "" end,
|
flickerstreak@53
|
211 set = function(info, val)
|
flickerstreak@63
|
212 local c = ReAction:GetBarTypeConfig(val)
|
flickerstreak@60
|
213 tmp.barType = val
|
flickerstreak@60
|
214 tmp.barSize = c.defaultButtonSize or tmp.barSize
|
flickerstreak@60
|
215 tmp.barRows = c.defaultBarRows or tmp.barRows
|
flickerstreak@60
|
216 tmp.barCols = c.defaultBarCols or tmp.barCols
|
flickerstreak@60
|
217 tmp.barSpacing = c.defaultBarSpacing or tmp.barSpacing
|
flickerstreak@53
|
218 end,
|
flickerstreak@47
|
219 values = "GetBarTypes",
|
flickerstreak@47
|
220 order = 3,
|
flickerstreak@47
|
221 },
|
flickerstreak@47
|
222 grid = {
|
flickerstreak@47
|
223 type = "group",
|
flickerstreak@47
|
224 name = L["Button Grid"],
|
flickerstreak@47
|
225 inline = true,
|
flickerstreak@47
|
226 args = {
|
flickerstreak@47
|
227 hdr = {
|
flickerstreak@47
|
228 type = "header",
|
flickerstreak@47
|
229 name = L["Button Grid"],
|
flickerstreak@47
|
230 order = 1,
|
flickerstreak@47
|
231 },
|
flickerstreak@47
|
232 rows = {
|
flickerstreak@47
|
233 type = "range",
|
flickerstreak@47
|
234 name = L["Rows"],
|
flickerstreak@60
|
235 get = function() return tmp.barRows or 1 end,
|
flickerstreak@60
|
236 set = function(info, val) tmp.barRows = val end,
|
flickerstreak@47
|
237 width = "half",
|
flickerstreak@47
|
238 min = 1,
|
flickerstreak@47
|
239 max = 32,
|
flickerstreak@47
|
240 step = 1,
|
flickerstreak@47
|
241 order = 2,
|
flickerstreak@47
|
242 },
|
flickerstreak@47
|
243 cols = {
|
flickerstreak@47
|
244 type = "range",
|
flickerstreak@47
|
245 name = L["Columns"],
|
flickerstreak@60
|
246 get = function() return tmp.barCols or 12 end,
|
flickerstreak@60
|
247 set = function(info, val) tmp.barCols = val end,
|
flickerstreak@47
|
248 width = "half",
|
flickerstreak@47
|
249 min = 1,
|
flickerstreak@47
|
250 max = 32,
|
flickerstreak@47
|
251 step = 1,
|
flickerstreak@47
|
252 order = 3,
|
flickerstreak@47
|
253 },
|
flickerstreak@47
|
254 sz = {
|
flickerstreak@47
|
255 type = "range",
|
flickerstreak@47
|
256 name = L["Size"],
|
flickerstreak@60
|
257 get = function() return tmp.barSize or 36 end,
|
flickerstreak@60
|
258 set = function(info, val) tmp.barSize = val end,
|
flickerstreak@47
|
259 width = "half",
|
flickerstreak@47
|
260 min = 10,
|
flickerstreak@47
|
261 max = 72,
|
flickerstreak@47
|
262 step = 1,
|
flickerstreak@47
|
263 order = 4,
|
flickerstreak@47
|
264 },
|
flickerstreak@47
|
265 spacing = {
|
flickerstreak@47
|
266 type = "range",
|
flickerstreak@47
|
267 name = L["Spacing"],
|
flickerstreak@60
|
268 get = function() return tmp.barSpacing or 3 end,
|
flickerstreak@60
|
269 set = function(info, val) tmp.barSpacing = val end,
|
flickerstreak@47
|
270 width = "half",
|
flickerstreak@47
|
271 min = 0,
|
flickerstreak@47
|
272 max = 24,
|
flickerstreak@47
|
273 step = 1,
|
flickerstreak@47
|
274 order = 5,
|
flickerstreak@47
|
275 }
|
flickerstreak@47
|
276 },
|
flickerstreak@47
|
277 order = 4
|
flickerstreak@47
|
278 },
|
flickerstreak@47
|
279 spacer = {
|
flickerstreak@47
|
280 type = "header",
|
flickerstreak@47
|
281 name = "",
|
flickerstreak@47
|
282 width = "full",
|
flickerstreak@47
|
283 order = -2
|
flickerstreak@47
|
284 },
|
flickerstreak@47
|
285 go = {
|
flickerstreak@47
|
286 type = "execute",
|
flickerstreak@47
|
287 name = L["Create Bar"],
|
flickerstreak@47
|
288 func = "CreateBar",
|
flickerstreak@47
|
289 order = -1,
|
flickerstreak@47
|
290 }
|
flickerstreak@47
|
291 }
|
flickerstreak@47
|
292 }
|
flickerstreak@47
|
293 }
|
flickerstreak@47
|
294 }
|
flickerstreak@60
|
295 AceConfigReg:RegisterOptionsTable(editorName, options)
|
flickerstreak@60
|
296
|
flickerstreak@81
|
297 function editor:Open(bar, ...)
|
flickerstreak@76
|
298 if bar then
|
flickerstreak@81
|
299 AceConfigDialog:SelectGroup(editorName, barOptMap[bar:GetName()], ...)
|
flickerstreak@76
|
300 end
|
flickerstreak@60
|
301 AceConfigDialog:Open(editorName,self)
|
flickerstreak@60
|
302 end
|
flickerstreak@60
|
303
|
flickerstreak@60
|
304 function editor:Refresh()
|
flickerstreak@60
|
305 AceConfigReg:NotifyChange(editorName)
|
flickerstreak@60
|
306 end
|
flickerstreak@60
|
307
|
flickerstreak@60
|
308 function editor:CreateBarTree(bar)
|
flickerstreak@60
|
309 local name = bar:GetName()
|
flickerstreak@60
|
310 -- AceConfig doesn't allow spaces, etc, in arg key names, and they must be
|
flickerstreak@60
|
311 -- unique strings. So generate a unique key (it can be whatever) for the bar
|
flickerstreak@60
|
312 local args = options.args
|
flickerstreak@60
|
313 local key
|
flickerstreak@60
|
314 local i = 1
|
flickerstreak@60
|
315 repeat
|
flickerstreak@60
|
316 key = ("bar%s"):format(i)
|
flickerstreak@60
|
317 i = i+1
|
flickerstreak@60
|
318 until args[key] == nil
|
flickerstreak@60
|
319 barOptMap[name] = key
|
flickerstreak@60
|
320 args[key] = {
|
flickerstreak@60
|
321 type = "group",
|
flickerstreak@60
|
322 name = name,
|
flickerstreak@60
|
323 childGroups = "tab",
|
flickerstreak@60
|
324 args = {
|
flickerstreak@60
|
325 general = {
|
flickerstreak@60
|
326 type = "group",
|
flickerstreak@60
|
327 name = L["General"],
|
flickerstreak@60
|
328 order = 1,
|
flickerstreak@60
|
329 args = {
|
flickerstreak@60
|
330 name = {
|
flickerstreak@60
|
331 type = "input",
|
flickerstreak@60
|
332 name = L["Rename Bar"],
|
flickerstreak@60
|
333 get = function() return bar:GetName() end,
|
flickerstreak@60
|
334 set = function(info, value) return ReAction:RenameBar(bar, value) end,
|
flickerstreak@60
|
335 order = 1,
|
flickerstreak@60
|
336 },
|
flickerstreak@60
|
337 delete = {
|
flickerstreak@60
|
338 type = "execute",
|
flickerstreak@60
|
339 name = L["Delete Bar"],
|
flickerstreak@60
|
340 desc = function() return bar:GetName() end,
|
flickerstreak@60
|
341 confirm = true,
|
flickerstreak@60
|
342 func = function() ReAction:EraseBar(bar) end,
|
flickerstreak@60
|
343 order = 2
|
flickerstreak@60
|
344 },
|
flickerstreak@60
|
345 anchor = {
|
flickerstreak@60
|
346 type = "group",
|
flickerstreak@60
|
347 name = L["Anchor"],
|
flickerstreak@60
|
348 inline = true,
|
flickerstreak@60
|
349 args = {
|
flickerstreak@60
|
350 frame = {
|
flickerstreak@60
|
351 type = "input",
|
flickerstreak@60
|
352 name = L["Frame"],
|
flickerstreak@60
|
353 desc = L["The frame that the bar is anchored to"],
|
flickerstreak@60
|
354 get = function() local _, f = bar:GetAnchor(); return f end,
|
flickerstreak@60
|
355 set = function(info, val) bar:SetAnchor(nil,val) end,
|
flickerstreak@60
|
356 validate = function(info, name)
|
flickerstreak@60
|
357 if name then
|
flickerstreak@60
|
358 local f = ReAction:GetBar(name)
|
flickerstreak@60
|
359 if f then
|
flickerstreak@60
|
360 return true
|
flickerstreak@60
|
361 else
|
flickerstreak@60
|
362 f = _G[name]
|
flickerstreak@60
|
363 if f and type(f) == "table" and f.IsObjectType and f:IsObjectType("Frame") then
|
flickerstreak@60
|
364 return true
|
flickerstreak@60
|
365 end
|
flickerstreak@60
|
366 end
|
flickerstreak@60
|
367 end
|
flickerstreak@60
|
368 return false
|
flickerstreak@60
|
369 end,
|
flickerstreak@60
|
370 width = "double",
|
flickerstreak@60
|
371 order = 1
|
flickerstreak@60
|
372 },
|
flickerstreak@60
|
373 point = {
|
flickerstreak@60
|
374 type = "select",
|
flickerstreak@60
|
375 name = L["Point"],
|
flickerstreak@60
|
376 desc = L["Anchor point on the bar frame"],
|
flickerstreak@60
|
377 style = "dropdown",
|
flickerstreak@60
|
378 get = function() return bar:GetAnchor() end,
|
flickerstreak@60
|
379 set = function(info, val) bar:SetAnchor(val) end,
|
flickerstreak@60
|
380 values = pointTable,
|
flickerstreak@60
|
381 order = 2,
|
flickerstreak@60
|
382 },
|
flickerstreak@60
|
383 relativePoint = {
|
flickerstreak@60
|
384 type = "select",
|
flickerstreak@60
|
385 name = L["Relative Point"],
|
flickerstreak@60
|
386 desc = L["Anchor point on the target frame"],
|
flickerstreak@60
|
387 style = "dropdown",
|
flickerstreak@60
|
388 get = function() local p,f,r = bar:GetAnchor(); return r end,
|
flickerstreak@60
|
389 set = function(info, val) bar:SetAnchor(nil,nil,val) end,
|
flickerstreak@60
|
390 values = pointTable,
|
flickerstreak@60
|
391 order = 3,
|
flickerstreak@60
|
392 },
|
flickerstreak@60
|
393 x = {
|
flickerstreak@60
|
394 type = "input",
|
flickerstreak@60
|
395 pattern = "\-?%d+",
|
flickerstreak@60
|
396 name = L["X offset"],
|
flickerstreak@60
|
397 get = function() local p,f,r,x = bar:GetAnchor(); return ("%d"):format(x) end,
|
flickerstreak@60
|
398 set = function(info,val) bar:SetAnchor(nil,nil,nil,val) end,
|
flickerstreak@60
|
399 order = 4
|
flickerstreak@60
|
400 },
|
flickerstreak@60
|
401 y = {
|
flickerstreak@60
|
402 type = "input",
|
flickerstreak@60
|
403 pattern = "\-?%d+",
|
flickerstreak@60
|
404 name = L["Y offset"],
|
flickerstreak@60
|
405 get = function() local p,f,r,x,y = bar:GetAnchor(); return ("%d"):format(y) end,
|
flickerstreak@60
|
406 set = function(info,val) bar:SetAnchor(nil,nil,nil,nil,val) end,
|
flickerstreak@60
|
407 order = 5
|
flickerstreak@60
|
408 },
|
flickerstreak@60
|
409 },
|
flickerstreak@60
|
410 order = 3
|
flickerstreak@60
|
411 },
|
flickerstreak@60
|
412 },
|
flickerstreak@60
|
413 },
|
flickerstreak@60
|
414 }
|
flickerstreak@60
|
415 }
|
flickerstreak@60
|
416 self:RefreshBarTree(bar)
|
flickerstreak@60
|
417 end
|
flickerstreak@60
|
418
|
flickerstreak@60
|
419 function editor:RefreshBarTree(bar)
|
flickerstreak@63
|
420 local key = barOptMap[bar:GetName()]
|
flickerstreak@63
|
421 if key and options.args[key] then
|
flickerstreak@63
|
422 options.args[key].plugins = ReAction:GenerateBarOptionsTable(bar)
|
flickerstreak@63
|
423 AceConfigReg:NotifyChange(editorName)
|
flickerstreak@60
|
424 end
|
flickerstreak@60
|
425 end
|
flickerstreak@60
|
426
|
flickerstreak@60
|
427 function editor:OnCreateBar(evt, bar)
|
flickerstreak@60
|
428 self:CreateBarTree(bar)
|
flickerstreak@60
|
429 end
|
flickerstreak@60
|
430
|
flickerstreak@63
|
431 function editor:OnDestroyBar(evt, bar, name)
|
flickerstreak@63
|
432 local key = barOptMap[name]
|
flickerstreak@63
|
433 if key then
|
flickerstreak@63
|
434 options.args[key] = nil
|
flickerstreak@63
|
435 end
|
flickerstreak@63
|
436 self:Refresh()
|
flickerstreak@63
|
437 end
|
flickerstreak@63
|
438
|
flickerstreak@60
|
439 function editor:OnEraseBar(evt, name)
|
flickerstreak@60
|
440 local key = barOptMap[name]
|
flickerstreak@60
|
441 barOptMap[name] = nil
|
flickerstreak@60
|
442 if key then
|
flickerstreak@60
|
443 options.args[key] = nil
|
flickerstreak@60
|
444 self:Refresh()
|
flickerstreak@60
|
445 end
|
flickerstreak@60
|
446 end
|
flickerstreak@60
|
447
|
flickerstreak@83
|
448 function editor:OnRenameBar(evt, bar, oldname, newname)
|
flickerstreak@60
|
449 local key = barOptMap[oldname]
|
flickerstreak@60
|
450 barOptMap[oldname], barOptMap[newname] = nil, key
|
flickerstreak@60
|
451 if key then
|
flickerstreak@60
|
452 options.args[key].name = newname
|
flickerstreak@60
|
453 self:Refresh()
|
flickerstreak@60
|
454 end
|
flickerstreak@60
|
455 end
|
flickerstreak@60
|
456
|
flickerstreak@63
|
457 function editor:OnBarOptionGeneratorRegistered(evt)
|
flickerstreak@63
|
458 for name in pairs(barOptMap) do
|
flickerstreak@63
|
459 local bar = ReAction:GetBar(name)
|
flickerstreak@63
|
460 if bar then
|
flickerstreak@63
|
461 self:RefreshBarTree(bar)
|
flickerstreak@63
|
462 end
|
flickerstreak@63
|
463 end
|
flickerstreak@63
|
464 end
|
flickerstreak@63
|
465
|
flickerstreak@60
|
466 local _scratch = { }
|
flickerstreak@60
|
467 function editor:GetBarTypes()
|
flickerstreak@60
|
468 for k,v in pairs(_scratch) do
|
flickerstreak@60
|
469 _scratch[k] = nil
|
flickerstreak@60
|
470 end
|
flickerstreak@63
|
471 return ReAction:GetBarTypeOptions(_scratch)
|
flickerstreak@60
|
472 end
|
flickerstreak@60
|
473
|
flickerstreak@60
|
474 function editor:CreateBar()
|
flickerstreak@60
|
475 if tmp.barName and tmp.barName ~= "" then
|
flickerstreak@63
|
476 ReAction:CreateBar(tmp.barName, tmp.barType or ReAction:GetDefaultBarType(), tmp.barRows, tmp.barCols, tmp.barSize, tmp.barSpacing)
|
flickerstreak@81
|
477 AceConfigDialog:SelectGroup(editorName, barOptMap[tmp.barName])
|
flickerstreak@60
|
478 tmp.barName = nil
|
flickerstreak@60
|
479 end
|
flickerstreak@60
|
480 end
|
flickerstreak@60
|
481
|
flickerstreak@60
|
482 ReAction.RegisterCallback(editor,"OnCreateBar")
|
flickerstreak@63
|
483 ReAction.RegisterCallback(editor,"OnDestroyBar")
|
flickerstreak@60
|
484 ReAction.RegisterCallback(editor,"OnEraseBar")
|
flickerstreak@60
|
485 ReAction.RegisterCallback(editor,"OnRenameBar")
|
flickerstreak@63
|
486 ReAction.RegisterCallback(editor,"OnBarOptionGeneratorRegistered")
|
flickerstreak@60
|
487
|
flickerstreak@63
|
488 for name, bar in ReAction:IterateBars() do
|
flickerstreak@60
|
489 editor:CreateBarTree(bar)
|
flickerstreak@60
|
490 end
|
flickerstreak@60
|
491
|
flickerstreak@60
|
492 return editor
|
flickerstreak@44
|
493 end
|
flickerstreak@44
|
494
|
flickerstreak@60
|
495
|
flickerstreak@81
|
496 function module:LaunchBarEditor(bar, ...)
|
flickerstreak@60
|
497 if InCombatLockdown() then
|
flickerstreak@61
|
498 ReAction:UserError(L["ReAction config mode disabled during combat."])
|
flickerstreak@60
|
499 else
|
flickerstreak@60
|
500 if not self.editor then
|
flickerstreak@60
|
501 self.editor = NewEditor()
|
flickerstreak@60
|
502 end
|
flickerstreak@81
|
503 self.editor:Open(bar, ...)
|
flickerstreak@60
|
504 ReAction:SetConfigMode(true)
|
flickerstreak@60
|
505 end
|
flickerstreak@60
|
506 end
|
flickerstreak@60
|
507
|