annotate modules/ReAction_ConfigUI/ReAction_ConfigUI.lua @ 107:110ec60c7a66

Removed README.html
author Flick <flickerstreak@gmail.com>
date Tue, 06 Jan 2009 21:10:03 +0000
parents 890e4c4ab143
children
rev   line source
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@103 367 local _, explicit = f:IsProtected()
flickerstreak@103 368 return explicit
flickerstreak@60 369 end
flickerstreak@60 370 end
flickerstreak@60 371 end
flickerstreak@60 372 return false
flickerstreak@60 373 end,
flickerstreak@60 374 width = "double",
flickerstreak@60 375 order = 1
flickerstreak@60 376 },
flickerstreak@60 377 point = {
flickerstreak@60 378 type = "select",
flickerstreak@60 379 name = L["Point"],
flickerstreak@60 380 desc = L["Anchor point on the bar frame"],
flickerstreak@60 381 style = "dropdown",
flickerstreak@60 382 get = function() return bar:GetAnchor() end,
flickerstreak@60 383 set = function(info, val) bar:SetAnchor(val) end,
flickerstreak@60 384 values = pointTable,
flickerstreak@60 385 order = 2,
flickerstreak@60 386 },
flickerstreak@60 387 relativePoint = {
flickerstreak@60 388 type = "select",
flickerstreak@60 389 name = L["Relative Point"],
flickerstreak@60 390 desc = L["Anchor point on the target frame"],
flickerstreak@60 391 style = "dropdown",
flickerstreak@60 392 get = function() local p,f,r = bar:GetAnchor(); return r end,
flickerstreak@60 393 set = function(info, val) bar:SetAnchor(nil,nil,val) end,
flickerstreak@60 394 values = pointTable,
flickerstreak@60 395 order = 3,
flickerstreak@60 396 },
flickerstreak@60 397 x = {
flickerstreak@60 398 type = "input",
flickerstreak@60 399 pattern = "\-?%d+",
flickerstreak@60 400 name = L["X offset"],
flickerstreak@60 401 get = function() local p,f,r,x = bar:GetAnchor(); return ("%d"):format(x) end,
flickerstreak@60 402 set = function(info,val) bar:SetAnchor(nil,nil,nil,val) end,
flickerstreak@60 403 order = 4
flickerstreak@60 404 },
flickerstreak@60 405 y = {
flickerstreak@60 406 type = "input",
flickerstreak@60 407 pattern = "\-?%d+",
flickerstreak@60 408 name = L["Y offset"],
flickerstreak@60 409 get = function() local p,f,r,x,y = bar:GetAnchor(); return ("%d"):format(y) end,
flickerstreak@60 410 set = function(info,val) bar:SetAnchor(nil,nil,nil,nil,val) end,
flickerstreak@60 411 order = 5
flickerstreak@60 412 },
flickerstreak@60 413 },
flickerstreak@60 414 order = 3
flickerstreak@60 415 },
flickerstreak@103 416 alpha = {
flickerstreak@103 417 type = "range",
flickerstreak@103 418 name = L["Transparency"],
flickerstreak@103 419 get = function() return bar:GetAlpha() end,
flickerstreak@103 420 set = function(info, val) bar:SetAlpha(val) end,
flickerstreak@103 421 min = 0,
flickerstreak@103 422 max = 1,
flickerstreak@103 423 isPercent = true,
flickerstreak@103 424 step = 0.01,
flickerstreak@103 425 bigStep = 0.05,
flickerstreak@103 426 order = 4,
flickerstreak@103 427 },
flickerstreak@60 428 },
flickerstreak@60 429 },
flickerstreak@60 430 }
flickerstreak@60 431 }
flickerstreak@60 432 self:RefreshBarTree(bar)
flickerstreak@60 433 end
flickerstreak@60 434
flickerstreak@60 435 function editor:RefreshBarTree(bar)
flickerstreak@63 436 local key = barOptMap[bar:GetName()]
flickerstreak@63 437 if key and options.args[key] then
flickerstreak@63 438 options.args[key].plugins = ReAction:GenerateBarOptionsTable(bar)
flickerstreak@63 439 AceConfigReg:NotifyChange(editorName)
flickerstreak@60 440 end
flickerstreak@60 441 end
flickerstreak@60 442
flickerstreak@60 443 function editor:OnCreateBar(evt, bar)
flickerstreak@91 444 if not tmp.creating then
flickerstreak@91 445 -- a bit of hack to work around OnCreateBar event handler ordering
flickerstreak@91 446 self:CreateBarTree(bar)
flickerstreak@91 447 end
flickerstreak@60 448 end
flickerstreak@60 449
flickerstreak@63 450 function editor:OnDestroyBar(evt, bar, name)
flickerstreak@63 451 local key = barOptMap[name]
flickerstreak@63 452 if key then
flickerstreak@63 453 options.args[key] = nil
flickerstreak@63 454 end
flickerstreak@63 455 self:Refresh()
flickerstreak@63 456 end
flickerstreak@63 457
flickerstreak@60 458 function editor:OnEraseBar(evt, name)
flickerstreak@60 459 local key = barOptMap[name]
flickerstreak@60 460 barOptMap[name] = nil
flickerstreak@60 461 if key then
flickerstreak@60 462 options.args[key] = nil
flickerstreak@60 463 self:Refresh()
flickerstreak@60 464 end
flickerstreak@60 465 end
flickerstreak@60 466
flickerstreak@83 467 function editor:OnRenameBar(evt, bar, oldname, newname)
flickerstreak@60 468 local key = barOptMap[oldname]
flickerstreak@60 469 barOptMap[oldname], barOptMap[newname] = nil, key
flickerstreak@60 470 if key then
flickerstreak@60 471 options.args[key].name = newname
flickerstreak@60 472 self:Refresh()
flickerstreak@60 473 end
flickerstreak@60 474 end
flickerstreak@60 475
flickerstreak@63 476 function editor:OnBarOptionGeneratorRegistered(evt)
flickerstreak@63 477 for name in pairs(barOptMap) do
flickerstreak@63 478 local bar = ReAction:GetBar(name)
flickerstreak@63 479 if bar then
flickerstreak@63 480 self:RefreshBarTree(bar)
flickerstreak@63 481 end
flickerstreak@63 482 end
flickerstreak@63 483 end
flickerstreak@63 484
flickerstreak@60 485 local _scratch = { }
flickerstreak@60 486 function editor:GetBarTypes()
flickerstreak@60 487 for k,v in pairs(_scratch) do
flickerstreak@60 488 _scratch[k] = nil
flickerstreak@60 489 end
flickerstreak@63 490 return ReAction:GetBarTypeOptions(_scratch)
flickerstreak@60 491 end
flickerstreak@60 492
flickerstreak@60 493 function editor:CreateBar()
flickerstreak@60 494 if tmp.barName and tmp.barName ~= "" then
flickerstreak@91 495 tmp.creating = true
flickerstreak@91 496 local bar = ReAction:CreateBar(tmp.barName, tmp.barType or ReAction:GetDefaultBarType(), tmp.barRows, tmp.barCols, tmp.barSize, tmp.barSpacing)
flickerstreak@91 497 self:CreateBarTree(bar)
flickerstreak@81 498 AceConfigDialog:SelectGroup(editorName, barOptMap[tmp.barName])
flickerstreak@60 499 tmp.barName = nil
flickerstreak@91 500 tmp.creating = false
flickerstreak@60 501 end
flickerstreak@60 502 end
flickerstreak@60 503
flickerstreak@60 504 ReAction.RegisterCallback(editor,"OnCreateBar")
flickerstreak@63 505 ReAction.RegisterCallback(editor,"OnDestroyBar")
flickerstreak@60 506 ReAction.RegisterCallback(editor,"OnEraseBar")
flickerstreak@60 507 ReAction.RegisterCallback(editor,"OnRenameBar")
flickerstreak@63 508 ReAction.RegisterCallback(editor,"OnBarOptionGeneratorRegistered")
flickerstreak@60 509
flickerstreak@63 510 for name, bar in ReAction:IterateBars() do
flickerstreak@60 511 editor:CreateBarTree(bar)
flickerstreak@60 512 end
flickerstreak@60 513
flickerstreak@60 514 return editor
flickerstreak@44 515 end
flickerstreak@44 516
flickerstreak@60 517
flickerstreak@81 518 function module:LaunchBarEditor(bar, ...)
flickerstreak@60 519 if InCombatLockdown() then
flickerstreak@61 520 ReAction:UserError(L["ReAction config mode disabled during combat."])
flickerstreak@60 521 else
flickerstreak@60 522 if not self.editor then
flickerstreak@60 523 self.editor = NewEditor()
flickerstreak@60 524 end
flickerstreak@81 525 self.editor:Open(bar, ...)
flickerstreak@60 526 ReAction:SetConfigMode(true)
flickerstreak@60 527 end
flickerstreak@60 528 end
flickerstreak@60 529