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