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