comparison modules/ReAction_ConfigUI/ReAction_ConfigUI.lua @ 58:20003239af0b

changed "layout editor" to "bar editor"
author Flick <flickerstreak@gmail.com>
date Mon, 28 Apr 2008 21:08:35 +0000
parents 7e09c02ae620
children 7430a8dd4e90
comparison
equal deleted inserted replaced
57:b85118b61564 58:20003239af0b
61 end 61 end
62 end 62 end
63 63
64 function module:OnOptionsRefreshed(evt) 64 function module:OnOptionsRefreshed(evt)
65 AceConfigReg:NotifyChange("ReAction") 65 AceConfigReg:NotifyChange("ReAction")
66 AceConfigReg:NotifyChange("ReAction-Layout") 66 AceConfigReg:NotifyChange("ReAction-Editor")
67 end 67 end
68 68
69 function module:OnCreateBar(evt, bar) 69 function module:OnCreateBar(evt, bar)
70 local name = bar:GetName() 70 local name = bar:GetName()
71 -- AceConfig doesn't allow spaces, etc, in arg key names, and they must be 71 -- AceConfig doesn't allow spaces, etc, in arg key names, and they must be
73 local key 73 local key
74 local i = 1 74 local i = 1
75 repeat 75 repeat
76 key = ("bar%s"):format(i) 76 key = ("bar%s"):format(i)
77 i = i+1 77 i = i+1
78 until self.layoutOpts.args[key] == nil 78 until self.editorOpts.args[key] == nil
79 self.barOptMap[name] = key 79 self.barOptMap[name] = key
80 self.layoutOpts.args[key] = { 80 self.editorOpts.args[key] = {
81 type = "group", 81 type = "group",
82 name = name, 82 name = name,
83 childGroups = "tab", 83 childGroups = "tab",
84 args = { 84 args = {
85 general = { 85 general = {
177 177
178 function module:OnEraseBar(evt, name) 178 function module:OnEraseBar(evt, name)
179 local key = self.barOptMap[name] 179 local key = self.barOptMap[name]
180 self.barOptMap[name] = nil 180 self.barOptMap[name] = nil
181 if key then 181 if key then
182 self.layoutOpts.args[key] = nil 182 self.editorOpts.args[key] = nil
183 self:RefreshLayoutEditor() 183 self:RefreshBarEditor()
184 end 184 end
185 end 185 end
186 186
187 function module:OnRenameBar(evt, oldname, newname) 187 function module:OnRenameBar(evt, oldname, newname)
188 local key = self.barOptMap[oldname] 188 local key = self.barOptMap[oldname]
189 self.barOptMap[oldname], self.barOptMap[newname] = nil, key 189 self.barOptMap[oldname], self.barOptMap[newname] = nil, key
190 if key then 190 if key then
191 self.layoutOpts.args[key].name = newname 191 self.editorOpts.args[key].name = newname
192 self:RefreshLayoutEditor() 192 self:RefreshBarEditor()
193 end 193 end
194 end 194 end
195 195
196 function module:PLAYER_REGEN_DISABLED() 196 function module:PLAYER_REGEN_DISABLED()
197 if self.editor then 197 if self.editor then
206 206
207 function module:OpenConfig() 207 function module:OpenConfig()
208 InterfaceOptionsFrame_OpenToFrame("ReAction") 208 InterfaceOptionsFrame_OpenToFrame("ReAction")
209 end 209 end
210 210
211 function module:LaunchLayoutEditor(bar) 211 function module:LaunchBarEditor(bar)
212 if InCombatLockdown() then 212 if InCombatLockdown() then
213 self:UserError(L["ReAction config mode disabled during combat."]) 213 self:UserError(L["ReAction config mode disabled during combat."])
214 else 214 else
215 if not self.editor then 215 if not self.editor then
216 -- use a local container to work around AceConfigDialog closing 216 -- use a local container to work around AceConfigDialog closing
217 -- both the layout editor and the global options when interface options is closed 217 -- both the bar editor and the global options when interface options is closed
218 local ed = LibStub("AceGUI-3.0"):Create("Frame") 218 local ed = LibStub("AceGUI-3.0"):Create("Frame")
219 ed.frame:SetClampedToScreen(true) 219 ed.frame:SetClampedToScreen(true)
220 local old_OnUpdate = ed.frame:GetScript("OnUpdate") 220 local old_OnUpdate = ed.frame:GetScript("OnUpdate")
221 ed.frame:SetScript("OnUpdate", function(dt) 221 ed.frame:SetScript("OnUpdate", function(dt)
222 if old_OnUpdate then 222 if old_OnUpdate then
235 ed:SetCallback("OnClose", 235 ed:SetCallback("OnClose",
236 function() 236 function()
237 ReAction:SetConfigMode(false) 237 ReAction:SetConfigMode(false)
238 end ) 238 end )
239 self.editor = ed 239 self.editor = ed
240 AceConfigDialog:SetDefaultSize("ReAction-Layout", 640, 420) 240 AceConfigDialog:SetDefaultSize("ReAction-Editor", 640, 420)
241 end 241 end
242 242
243 AceConfigDialog:Open("ReAction-Layout", self.editor) 243 AceConfigDialog:Open("ReAction-Editor", self.editor)
244 ReAction:SetConfigMode(true) 244 ReAction:SetConfigMode(true)
245 end 245 end
246 end 246 end
247 247
248 function module:RefreshLayoutEditor() 248 function module:RefreshBarEditor()
249 AceConfigReg:NotifyChange("ReAction-Layout") 249 AceConfigReg:NotifyChange("ReAction-Editor")
250 if self.editor and self.editor.frame:IsShown() then 250 if self.editor and self.editor.frame:IsShown() then
251 AceConfigDialog:Open("ReAction-Layout", self.editor) 251 AceConfigDialog:Open("ReAction-Editor", self.editor)
252 end 252 end
253 end 253 end
254 254
255 function module:GetBarTypes() 255 function module:GetBarTypes()
256 local opts = self.optBarTypes or { } 256 local opts = self.optBarTypes or { }
281 _desc = { 281 _desc = {
282 type = "description", 282 type = "description",
283 name = L["Customizable replacement for Blizzard's Action Bars"], 283 name = L["Customizable replacement for Blizzard's Action Bars"],
284 order = 1, 284 order = 1,
285 }, 285 },
286 _launchLayout = { 286 _launchEditor = {
287 type = "execute", 287 type = "execute",
288 handler = self, 288 handler = self,
289 name = L["Layout Editor..."], 289 name = L["Edit Bars..."],
290 desc = L["Show the ReAction Layout Editor to edit your bars"], 290 desc = L["Show the ReAction Bar Editor dialogue"],
291 func = function() 291 func = function()
292 self:LaunchLayoutEditor() 292 self:LaunchBarEditor()
293 -- you can't close a dialog in response to an options click, because the end of the 293 -- you can't close a dialog in response to an options click, because the end of the
294 -- handler for all the button events calls lib:Open() 294 -- handler for all the button events calls lib:Open()
295 -- So, schedule a close on the next OnUpdate 295 -- So, schedule a close on the next OnUpdate
296 if self.db.profile.closeOnLaunch then 296 if self.db.profile.closeOnLaunch then
297 self.editor.closePending = true 297 self.editor.closePending = true
300 order = 2, 300 order = 2,
301 }, 301 },
302 _closeThis = { 302 _closeThis = {
303 type = "toggle", 303 type = "toggle",
304 name = L["Close on Launch"], 304 name = L["Close on Launch"],
305 desc = L["Close the Interface Options window when launching the ReAction Layout Editor"], 305 desc = L["Close the Interface Options window when launching the ReAction Bar Editor"],
306 get = function() return self.db.profile.closeOnLaunch end, 306 get = function() return self.db.profile.closeOnLaunch end,
307 set = function(info, val) self.db.profile.closeOnLaunch = val end, 307 set = function(info, val) self.db.profile.closeOnLaunch = val end,
308 order = 3, 308 order = 3,
309 }, 309 },
310 global = { 310 global = {
361 } 361 }
362 } 362 }
363 }, 363 },
364 }) 364 })
365 365
366 -- layout editor options 366 -- bar editor options
367 local layoutOpts = { 367 local editorOpts = {
368 type = "group", 368 type = "group",
369 name = ("ReAction - %s"):format(L["Layout"]), 369 name = ("ReAction - %s"):format(L["Bar Editor"]),
370 handler = self, 370 handler = self,
371 childGroups = "tree", 371 childGroups = "tree",
372 args = { 372 args = {
373 desc = { 373 desc = {
374 type = "description", 374 type = "description",
391 order = 2 391 order = 2
392 }, 392 },
393 closeThis = { 393 closeThis = {
394 type = "toggle", 394 type = "toggle",
395 name = L["Close on Launch"], 395 name = L["Close on Launch"],
396 desc = L["Close the Layout Editor when opening the ReAction global Interface Options"], 396 desc = L["Close the Bar Editor when opening the ReAction global Interface Options"],
397 get = function() return self.db.profile.editorCloseOnLaunch end, 397 get = function() return self.db.profile.editorCloseOnLaunch end,
398 set = function(info, val) self.db.profile.editorCloseOnLaunch = val end, 398 set = function(info, val) self.db.profile.editorCloseOnLaunch = val end,
399 order = 3, 399 order = 3,
400 }, 400 },
401 new = { 401 new = {
502 } 502 }
503 } 503 }
504 } 504 }
505 } 505 }
506 } 506 }
507 self.layoutOpts = layoutOpts 507 self.editorOpts = editorOpts
508 self.barOptMap = { } 508 self.barOptMap = { }
509 AceConfigReg:RegisterOptionsTable("ReAction-Layout",layoutOpts) 509 AceConfigReg:RegisterOptionsTable("ReAction-Editor",editorOpts)
510 end 510 end
511 511