annotate modules/ConfigUI.lua @ 175:df68b5a40490

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