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@90
|
54 InterfaceOptionsFrame_OpenToCategory(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@92
|
131 frame:Hide()
|
flickerstreak@60
|
132 local old_OnUpdate = frame:GetScript("OnUpdate")
|
flickerstreak@60
|
133 frame:SetScript("OnUpdate", function(dt)
|
flickerstreak@60
|
134 if old_OnUpdate then
|
flickerstreak@60
|
135 old_OnUpdate(dt)
|
flickerstreak@46
|
136 end
|
flickerstreak@60
|
137 if editor.closePending then
|
flickerstreak@60
|
138 InterfaceOptionsFrame:Hide()
|
flickerstreak@60
|
139 editor.closePending = false
|
flickerstreak@60
|
140 end
|
flickerstreak@60
|
141 if editor.selfClosePending then
|
flickerstreak@63
|
142 editor:Hide()
|
flickerstreak@60
|
143 AceConfigReg:NotifyChange(configName)
|
flickerstreak@60
|
144 editor.selfClosePending = false
|
flickerstreak@60
|
145 end
|
flickerstreak@60
|
146 end )
|
flickerstreak@60
|
147 editor:SetCallback("OnClose",
|
flickerstreak@60
|
148 function()
|
flickerstreak@60
|
149 ReAction:SetConfigMode(false)
|
flickerstreak@60
|
150 end )
|
flickerstreak@61
|
151 AceConfigDialog:SetDefaultSize(editorName, 700, 540)
|
flickerstreak@60
|
152
|
flickerstreak@46
|
153
|
flickerstreak@76
|
154 local name = ("ReAction - %s"):format(L["Bar Editor"])
|
flickerstreak@76
|
155 editor:SetTitle(name)
|
flickerstreak@60
|
156 local options = {
|
flickerstreak@47
|
157 type = "group",
|
flickerstreak@76
|
158 name = name,
|
flickerstreak@60
|
159 handler = editor,
|
flickerstreak@47
|
160 childGroups = "tree",
|
flickerstreak@47
|
161 args = {
|
flickerstreak@47
|
162 desc = {
|
flickerstreak@47
|
163 type = "description",
|
flickerstreak@47
|
164 name = L["Use the mouse to arrange and resize the bars on screen. Tooltips on bars indicate additional functionality."],
|
flickerstreak@47
|
165 order = 1
|
flickerstreak@47
|
166 },
|
flickerstreak@47
|
167 launchConfig = {
|
flickerstreak@47
|
168 type = "execute",
|
flickerstreak@47
|
169 name = L["Global Config"],
|
flickerstreak@47
|
170 desc = L["Opens ReAction global configuration settings panel"],
|
flickerstreak@47
|
171 func = function()
|
flickerstreak@60
|
172 module:OpenConfig()
|
flickerstreak@47
|
173 -- you can't close a dialog in response to an options click, because the end of the
|
flickerstreak@47
|
174 -- handler for all the button events calls lib:Open()
|
flickerstreak@48
|
175 -- So, schedule a close on the next OnUpdate
|
flickerstreak@60
|
176 if module.db.profile.editorCloseOnLaunch then
|
flickerstreak@60
|
177 editor.selfClosePending = true
|
flickerstreak@47
|
178 end
|
flickerstreak@47
|
179 end,
|
flickerstreak@47
|
180 order = 2
|
flickerstreak@47
|
181 },
|
flickerstreak@48
|
182 closeThis = {
|
flickerstreak@47
|
183 type = "toggle",
|
flickerstreak@47
|
184 name = L["Close on Launch"],
|
flickerstreak@58
|
185 desc = L["Close the Bar Editor when opening the ReAction global Interface Options"],
|
flickerstreak@60
|
186 get = function() return module.db.profile.editorCloseOnLaunch end,
|
flickerstreak@60
|
187 set = function(info, val) module.db.profile.editorCloseOnLaunch = val end,
|
flickerstreak@47
|
188 order = 3,
|
flickerstreak@47
|
189 },
|
flickerstreak@47
|
190 new = {
|
flickerstreak@47
|
191 type = "group",
|
flickerstreak@47
|
192 name = L["New Bar..."],
|
flickerstreak@47
|
193 order = 4,
|
flickerstreak@47
|
194 args = {
|
flickerstreak@47
|
195 desc = {
|
flickerstreak@47
|
196 type = "description",
|
flickerstreak@47
|
197 name = L["Choose a name, type, and initial grid for your new action bar:"],
|
flickerstreak@47
|
198 order = 1,
|
flickerstreak@47
|
199 },
|
flickerstreak@47
|
200 name = {
|
flickerstreak@47
|
201 type = "input",
|
flickerstreak@47
|
202 name = L["Bar Name"],
|
flickerstreak@47
|
203 desc = L["Enter a name for your new action bar"],
|
flickerstreak@60
|
204 get = function() return tmp.barName or "" end,
|
flickerstreak@60
|
205 set = function(info, val) tmp.barName = val end,
|
flickerstreak@47
|
206 order = 2,
|
flickerstreak@47
|
207 },
|
flickerstreak@47
|
208 type = {
|
flickerstreak@47
|
209 type = "select",
|
flickerstreak@47
|
210 name = L["Button Type"],
|
flickerstreak@63
|
211 get = function() return tmp.barType or ReAction:GetDefaultBarType() or "" end,
|
flickerstreak@53
|
212 set = function(info, val)
|
flickerstreak@63
|
213 local c = ReAction:GetBarTypeConfig(val)
|
flickerstreak@60
|
214 tmp.barType = val
|
flickerstreak@60
|
215 tmp.barSize = c.defaultButtonSize or tmp.barSize
|
flickerstreak@60
|
216 tmp.barRows = c.defaultBarRows or tmp.barRows
|
flickerstreak@60
|
217 tmp.barCols = c.defaultBarCols or tmp.barCols
|
flickerstreak@60
|
218 tmp.barSpacing = c.defaultBarSpacing or tmp.barSpacing
|
flickerstreak@53
|
219 end,
|
flickerstreak@47
|
220 values = "GetBarTypes",
|
flickerstreak@47
|
221 order = 3,
|
flickerstreak@47
|
222 },
|
flickerstreak@47
|
223 grid = {
|
flickerstreak@47
|
224 type = "group",
|
flickerstreak@47
|
225 name = L["Button Grid"],
|
flickerstreak@47
|
226 inline = true,
|
flickerstreak@47
|
227 args = {
|
flickerstreak@47
|
228 hdr = {
|
flickerstreak@47
|
229 type = "header",
|
flickerstreak@47
|
230 name = L["Button Grid"],
|
flickerstreak@47
|
231 order = 1,
|
flickerstreak@47
|
232 },
|
flickerstreak@47
|
233 rows = {
|
flickerstreak@47
|
234 type = "range",
|
flickerstreak@47
|
235 name = L["Rows"],
|
flickerstreak@60
|
236 get = function() return tmp.barRows or 1 end,
|
flickerstreak@60
|
237 set = function(info, val) tmp.barRows = val end,
|
flickerstreak@47
|
238 width = "half",
|
flickerstreak@47
|
239 min = 1,
|
flickerstreak@47
|
240 max = 32,
|
flickerstreak@47
|
241 step = 1,
|
flickerstreak@47
|
242 order = 2,
|
flickerstreak@47
|
243 },
|
flickerstreak@47
|
244 cols = {
|
flickerstreak@47
|
245 type = "range",
|
flickerstreak@47
|
246 name = L["Columns"],
|
flickerstreak@60
|
247 get = function() return tmp.barCols or 12 end,
|
flickerstreak@60
|
248 set = function(info, val) tmp.barCols = val end,
|
flickerstreak@47
|
249 width = "half",
|
flickerstreak@47
|
250 min = 1,
|
flickerstreak@47
|
251 max = 32,
|
flickerstreak@47
|
252 step = 1,
|
flickerstreak@47
|
253 order = 3,
|
flickerstreak@47
|
254 },
|
flickerstreak@47
|
255 sz = {
|
flickerstreak@47
|
256 type = "range",
|
flickerstreak@47
|
257 name = L["Size"],
|
flickerstreak@60
|
258 get = function() return tmp.barSize or 36 end,
|
flickerstreak@60
|
259 set = function(info, val) tmp.barSize = val end,
|
flickerstreak@47
|
260 width = "half",
|
flickerstreak@47
|
261 min = 10,
|
flickerstreak@47
|
262 max = 72,
|
flickerstreak@47
|
263 step = 1,
|
flickerstreak@47
|
264 order = 4,
|
flickerstreak@47
|
265 },
|
flickerstreak@47
|
266 spacing = {
|
flickerstreak@47
|
267 type = "range",
|
flickerstreak@47
|
268 name = L["Spacing"],
|
flickerstreak@60
|
269 get = function() return tmp.barSpacing or 3 end,
|
flickerstreak@60
|
270 set = function(info, val) tmp.barSpacing = val end,
|
flickerstreak@47
|
271 width = "half",
|
flickerstreak@47
|
272 min = 0,
|
flickerstreak@47
|
273 max = 24,
|
flickerstreak@47
|
274 step = 1,
|
flickerstreak@47
|
275 order = 5,
|
flickerstreak@47
|
276 }
|
flickerstreak@47
|
277 },
|
flickerstreak@47
|
278 order = 4
|
flickerstreak@47
|
279 },
|
flickerstreak@47
|
280 spacer = {
|
flickerstreak@47
|
281 type = "header",
|
flickerstreak@47
|
282 name = "",
|
flickerstreak@47
|
283 width = "full",
|
flickerstreak@47
|
284 order = -2
|
flickerstreak@47
|
285 },
|
flickerstreak@47
|
286 go = {
|
flickerstreak@47
|
287 type = "execute",
|
flickerstreak@47
|
288 name = L["Create Bar"],
|
flickerstreak@47
|
289 func = "CreateBar",
|
flickerstreak@47
|
290 order = -1,
|
flickerstreak@47
|
291 }
|
flickerstreak@47
|
292 }
|
flickerstreak@47
|
293 }
|
flickerstreak@47
|
294 }
|
flickerstreak@47
|
295 }
|
flickerstreak@60
|
296 AceConfigReg:RegisterOptionsTable(editorName, options)
|
flickerstreak@60
|
297
|
flickerstreak@81
|
298 function editor:Open(bar, ...)
|
flickerstreak@92
|
299 if not frame:IsVisible() then
|
flickerstreak@92
|
300 AceConfigDialog:Open(editorName,self)
|
flickerstreak@92
|
301 end
|
flickerstreak@76
|
302 if bar then
|
flickerstreak@81
|
303 AceConfigDialog:SelectGroup(editorName, barOptMap[bar:GetName()], ...)
|
flickerstreak@76
|
304 end
|
flickerstreak@60
|
305 end
|
flickerstreak@60
|
306
|
flickerstreak@60
|
307 function editor:Refresh()
|
flickerstreak@60
|
308 AceConfigReg:NotifyChange(editorName)
|
flickerstreak@60
|
309 end
|
flickerstreak@60
|
310
|
flickerstreak@60
|
311 function editor:CreateBarTree(bar)
|
flickerstreak@60
|
312 local name = bar:GetName()
|
flickerstreak@60
|
313 -- AceConfig doesn't allow spaces, etc, in arg key names, and they must be
|
flickerstreak@60
|
314 -- unique strings. So generate a unique key (it can be whatever) for the bar
|
flickerstreak@60
|
315 local args = options.args
|
flickerstreak@60
|
316 local key
|
flickerstreak@60
|
317 local i = 1
|
flickerstreak@60
|
318 repeat
|
flickerstreak@60
|
319 key = ("bar%s"):format(i)
|
flickerstreak@60
|
320 i = i+1
|
flickerstreak@60
|
321 until args[key] == nil
|
flickerstreak@60
|
322 barOptMap[name] = key
|
flickerstreak@60
|
323 args[key] = {
|
flickerstreak@60
|
324 type = "group",
|
flickerstreak@60
|
325 name = name,
|
flickerstreak@60
|
326 childGroups = "tab",
|
flickerstreak@60
|
327 args = {
|
flickerstreak@60
|
328 general = {
|
flickerstreak@60
|
329 type = "group",
|
flickerstreak@60
|
330 name = L["General"],
|
flickerstreak@60
|
331 order = 1,
|
flickerstreak@60
|
332 args = {
|
flickerstreak@60
|
333 name = {
|
flickerstreak@60
|
334 type = "input",
|
flickerstreak@60
|
335 name = L["Rename Bar"],
|
flickerstreak@60
|
336 get = function() return bar:GetName() end,
|
flickerstreak@60
|
337 set = function(info, value) return ReAction:RenameBar(bar, value) end,
|
flickerstreak@60
|
338 order = 1,
|
flickerstreak@60
|
339 },
|
flickerstreak@60
|
340 delete = {
|
flickerstreak@60
|
341 type = "execute",
|
flickerstreak@60
|
342 name = L["Delete Bar"],
|
flickerstreak@60
|
343 desc = function() return bar:GetName() end,
|
flickerstreak@60
|
344 confirm = true,
|
flickerstreak@60
|
345 func = function() ReAction:EraseBar(bar) end,
|
flickerstreak@60
|
346 order = 2
|
flickerstreak@60
|
347 },
|
flickerstreak@60
|
348 anchor = {
|
flickerstreak@60
|
349 type = "group",
|
flickerstreak@60
|
350 name = L["Anchor"],
|
flickerstreak@60
|
351 inline = true,
|
flickerstreak@60
|
352 args = {
|
flickerstreak@60
|
353 frame = {
|
flickerstreak@60
|
354 type = "input",
|
flickerstreak@60
|
355 name = L["Frame"],
|
flickerstreak@60
|
356 desc = L["The frame that the bar is anchored to"],
|
flickerstreak@60
|
357 get = function() local _, f = bar:GetAnchor(); return f end,
|
flickerstreak@60
|
358 set = function(info, val) bar:SetAnchor(nil,val) end,
|
flickerstreak@60
|
359 validate = function(info, name)
|
flickerstreak@60
|
360 if name then
|
flickerstreak@60
|
361 local f = ReAction:GetBar(name)
|
flickerstreak@60
|
362 if f then
|
flickerstreak@60
|
363 return true
|
flickerstreak@60
|
364 else
|
flickerstreak@60
|
365 f = _G[name]
|
flickerstreak@60
|
366 if f and type(f) == "table" and f.IsObjectType and f:IsObjectType("Frame") then
|
flickerstreak@60
|
367 return true
|
flickerstreak@60
|
368 end
|
flickerstreak@60
|
369 end
|
flickerstreak@60
|
370 end
|
flickerstreak@60
|
371 return false
|
flickerstreak@60
|
372 end,
|
flickerstreak@60
|
373 width = "double",
|
flickerstreak@60
|
374 order = 1
|
flickerstreak@60
|
375 },
|
flickerstreak@60
|
376 point = {
|
flickerstreak@60
|
377 type = "select",
|
flickerstreak@60
|
378 name = L["Point"],
|
flickerstreak@60
|
379 desc = L["Anchor point on the bar frame"],
|
flickerstreak@60
|
380 style = "dropdown",
|
flickerstreak@60
|
381 get = function() return bar:GetAnchor() end,
|
flickerstreak@60
|
382 set = function(info, val) bar:SetAnchor(val) end,
|
flickerstreak@60
|
383 values = pointTable,
|
flickerstreak@60
|
384 order = 2,
|
flickerstreak@60
|
385 },
|
flickerstreak@60
|
386 relativePoint = {
|
flickerstreak@60
|
387 type = "select",
|
flickerstreak@60
|
388 name = L["Relative Point"],
|
flickerstreak@60
|
389 desc = L["Anchor point on the target frame"],
|
flickerstreak@60
|
390 style = "dropdown",
|
flickerstreak@60
|
391 get = function() local p,f,r = bar:GetAnchor(); return r end,
|
flickerstreak@60
|
392 set = function(info, val) bar:SetAnchor(nil,nil,val) end,
|
flickerstreak@60
|
393 values = pointTable,
|
flickerstreak@60
|
394 order = 3,
|
flickerstreak@60
|
395 },
|
flickerstreak@60
|
396 x = {
|
flickerstreak@60
|
397 type = "input",
|
flickerstreak@60
|
398 pattern = "\-?%d+",
|
flickerstreak@60
|
399 name = L["X offset"],
|
flickerstreak@60
|
400 get = function() local p,f,r,x = bar:GetAnchor(); return ("%d"):format(x) end,
|
flickerstreak@60
|
401 set = function(info,val) bar:SetAnchor(nil,nil,nil,val) end,
|
flickerstreak@60
|
402 order = 4
|
flickerstreak@60
|
403 },
|
flickerstreak@60
|
404 y = {
|
flickerstreak@60
|
405 type = "input",
|
flickerstreak@60
|
406 pattern = "\-?%d+",
|
flickerstreak@60
|
407 name = L["Y offset"],
|
flickerstreak@60
|
408 get = function() local p,f,r,x,y = bar:GetAnchor(); return ("%d"):format(y) end,
|
flickerstreak@60
|
409 set = function(info,val) bar:SetAnchor(nil,nil,nil,nil,val) end,
|
flickerstreak@60
|
410 order = 5
|
flickerstreak@60
|
411 },
|
flickerstreak@60
|
412 },
|
flickerstreak@60
|
413 order = 3
|
flickerstreak@60
|
414 },
|
flickerstreak@60
|
415 },
|
flickerstreak@60
|
416 },
|
flickerstreak@60
|
417 }
|
flickerstreak@60
|
418 }
|
flickerstreak@60
|
419 self:RefreshBarTree(bar)
|
flickerstreak@60
|
420 end
|
flickerstreak@60
|
421
|
flickerstreak@60
|
422 function editor:RefreshBarTree(bar)
|
flickerstreak@63
|
423 local key = barOptMap[bar:GetName()]
|
flickerstreak@63
|
424 if key and options.args[key] then
|
flickerstreak@63
|
425 options.args[key].plugins = ReAction:GenerateBarOptionsTable(bar)
|
flickerstreak@63
|
426 AceConfigReg:NotifyChange(editorName)
|
flickerstreak@60
|
427 end
|
flickerstreak@60
|
428 end
|
flickerstreak@60
|
429
|
flickerstreak@60
|
430 function editor:OnCreateBar(evt, bar)
|
flickerstreak@91
|
431 if not tmp.creating then
|
flickerstreak@91
|
432 -- a bit of hack to work around OnCreateBar event handler ordering
|
flickerstreak@91
|
433 self:CreateBarTree(bar)
|
flickerstreak@91
|
434 end
|
flickerstreak@60
|
435 end
|
flickerstreak@60
|
436
|
flickerstreak@63
|
437 function editor:OnDestroyBar(evt, bar, name)
|
flickerstreak@63
|
438 local key = barOptMap[name]
|
flickerstreak@63
|
439 if key then
|
flickerstreak@63
|
440 options.args[key] = nil
|
flickerstreak@63
|
441 end
|
flickerstreak@63
|
442 self:Refresh()
|
flickerstreak@63
|
443 end
|
flickerstreak@63
|
444
|
flickerstreak@60
|
445 function editor:OnEraseBar(evt, name)
|
flickerstreak@60
|
446 local key = barOptMap[name]
|
flickerstreak@60
|
447 barOptMap[name] = nil
|
flickerstreak@60
|
448 if key then
|
flickerstreak@60
|
449 options.args[key] = nil
|
flickerstreak@60
|
450 self:Refresh()
|
flickerstreak@60
|
451 end
|
flickerstreak@60
|
452 end
|
flickerstreak@60
|
453
|
flickerstreak@83
|
454 function editor:OnRenameBar(evt, bar, oldname, newname)
|
flickerstreak@60
|
455 local key = barOptMap[oldname]
|
flickerstreak@60
|
456 barOptMap[oldname], barOptMap[newname] = nil, key
|
flickerstreak@60
|
457 if key then
|
flickerstreak@60
|
458 options.args[key].name = newname
|
flickerstreak@60
|
459 self:Refresh()
|
flickerstreak@60
|
460 end
|
flickerstreak@60
|
461 end
|
flickerstreak@60
|
462
|
flickerstreak@63
|
463 function editor:OnBarOptionGeneratorRegistered(evt)
|
flickerstreak@63
|
464 for name in pairs(barOptMap) do
|
flickerstreak@63
|
465 local bar = ReAction:GetBar(name)
|
flickerstreak@63
|
466 if bar then
|
flickerstreak@63
|
467 self:RefreshBarTree(bar)
|
flickerstreak@63
|
468 end
|
flickerstreak@63
|
469 end
|
flickerstreak@63
|
470 end
|
flickerstreak@63
|
471
|
flickerstreak@60
|
472 local _scratch = { }
|
flickerstreak@60
|
473 function editor:GetBarTypes()
|
flickerstreak@60
|
474 for k,v in pairs(_scratch) do
|
flickerstreak@60
|
475 _scratch[k] = nil
|
flickerstreak@60
|
476 end
|
flickerstreak@63
|
477 return ReAction:GetBarTypeOptions(_scratch)
|
flickerstreak@60
|
478 end
|
flickerstreak@60
|
479
|
flickerstreak@60
|
480 function editor:CreateBar()
|
flickerstreak@60
|
481 if tmp.barName and tmp.barName ~= "" then
|
flickerstreak@91
|
482 tmp.creating = true
|
flickerstreak@91
|
483 local bar = ReAction:CreateBar(tmp.barName, tmp.barType or ReAction:GetDefaultBarType(), tmp.barRows, tmp.barCols, tmp.barSize, tmp.barSpacing)
|
flickerstreak@91
|
484 self:CreateBarTree(bar)
|
flickerstreak@81
|
485 AceConfigDialog:SelectGroup(editorName, barOptMap[tmp.barName])
|
flickerstreak@60
|
486 tmp.barName = nil
|
flickerstreak@91
|
487 tmp.creating = false
|
flickerstreak@60
|
488 end
|
flickerstreak@60
|
489 end
|
flickerstreak@60
|
490
|
flickerstreak@60
|
491 ReAction.RegisterCallback(editor,"OnCreateBar")
|
flickerstreak@63
|
492 ReAction.RegisterCallback(editor,"OnDestroyBar")
|
flickerstreak@60
|
493 ReAction.RegisterCallback(editor,"OnEraseBar")
|
flickerstreak@60
|
494 ReAction.RegisterCallback(editor,"OnRenameBar")
|
flickerstreak@63
|
495 ReAction.RegisterCallback(editor,"OnBarOptionGeneratorRegistered")
|
flickerstreak@60
|
496
|
flickerstreak@63
|
497 for name, bar in ReAction:IterateBars() do
|
flickerstreak@60
|
498 editor:CreateBarTree(bar)
|
flickerstreak@60
|
499 end
|
flickerstreak@60
|
500
|
flickerstreak@60
|
501 return editor
|
flickerstreak@44
|
502 end
|
flickerstreak@44
|
503
|
flickerstreak@60
|
504
|
flickerstreak@81
|
505 function module:LaunchBarEditor(bar, ...)
|
flickerstreak@60
|
506 if InCombatLockdown() then
|
flickerstreak@61
|
507 ReAction:UserError(L["ReAction config mode disabled during combat."])
|
flickerstreak@60
|
508 else
|
flickerstreak@60
|
509 if not self.editor then
|
flickerstreak@60
|
510 self.editor = NewEditor()
|
flickerstreak@60
|
511 end
|
flickerstreak@81
|
512 self.editor:Open(bar, ...)
|
flickerstreak@60
|
513 ReAction:SetConfigMode(true)
|
flickerstreak@60
|
514 end
|
flickerstreak@60
|
515 end
|
flickerstreak@60
|
516
|