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