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