annotate modules/ConfigUI.lua @ 174:09f7af2f53f8

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