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