comparison main.lua @ 17:639282f3a0e0

More cleanup of main.lua, ReBound-1.0.lua
author Flick <flickerstreak@gmail.com>
date Fri, 23 Mar 2007 19:28:30 +0000
parents 2735edcf9ab7
children 2f3e45fcb9e2
comparison
equal deleted inserted replaced
16:832aab6fed49 17:639282f3a0e0
7 7
8 -- Ace Library local object initialization 8 -- Ace Library local object initialization
9 local L = AceLibrary("AceLocale-2.2"):new("ReAction") 9 local L = AceLibrary("AceLocale-2.2"):new("ReAction")
10 local dewdrop = AceLibrary("Dewdrop-2.0") 10 local dewdrop = AceLibrary("Dewdrop-2.0")
11 local tablet = AceLibrary("Tablet-2.0") 11 local tablet = AceLibrary("Tablet-2.0")
12 local ReBound = AceLibrary("ReBound-1.0"):new("REACTION") 12 local ReBound = AceLibrary("ReBound-1.0"):new("ReAction")
13 13
14 -- private functions 14 -- private functions
15 local function tcopy(t) 15 local function tcopy(t)
16 local r = { } 16 local r = { }
17 for k, v in pairs(t) do 17 for k, v in pairs(t) do
22 22
23 -- private constants 23 -- private constants
24 local EMPTY_BAR_SLOT = -1 24 local EMPTY_BAR_SLOT = -1
25 25
26 -- key binding label constants 26 -- key binding label constants
27 BINDING_HEADER_REACTION = L["ReAction"] 27 BINDING_HEADER_REACTION = L["ReAction"]
28 BINDING_NAME_REACTION_TOGGLELOCK = L["Toggle ReAction Bar Lock"] 28 BINDING_NAME_REACTION_TOGGLELOCK = L["Toggle ReAction Bar Lock"]
29 BINDING_NAME_REACTION_TOGGLEKEYBIND = L["ReAction Keybinding Mode"] 29 BINDING_NAME_REACTION_TOGGLEKEYBIND = L["ReAction Keybinding Mode"]
30 30
31 -- UI panel strings 31 -- UI panel strings
32 REACTION_KEYBIND_TITLE = L["ReAction Keybinding"] 32 REACTION_KEYBIND_TITLE = L["ReAction Keybinding"]
33 REACTION_KEYBIND_SUBTITLE = L["Click Buttons to Set Keybindings"] 33 REACTION_KEYBIND_SUBTITLE = L["Click Buttons to Set Keybindings"]
34 REACTION_KEYBIND_DONE = L["Save"] 34 REACTION_KEYBIND_DONE = L["Save"]
35 REACTION_KEYBIND_REVERT = L["Revert"] 35 REACTION_KEYBIND_REVERT = L["Revert"]
36 36
37 37
38 38
39 ------------------------------ 39 ------------------------------
40 -- AceAddon setup 40 -- AceAddon setup
49 function main:OnInitialize() 49 function main:OnInitialize()
50 self:RegisterChatCommand( {L["/reaction"], L["/rxn"]}, ReActionConsoleOptions, "REACTION" ) 50 self:RegisterChatCommand( {L["/reaction"], L["/rxn"]}, ReActionConsoleOptions, "REACTION" )
51 self:RegisterDB("ReActionDB","ReActionDBPC") 51 self:RegisterDB("ReActionDB","ReActionDBPC")
52 self:RegisterDefaults("profile", ReAction_DefaultProfile) 52 self:RegisterDefaults("profile", ReAction_DefaultProfile)
53 self:RegisterEvent("PLAYER_REGEN_DISABLED","CombatLockdown") 53 self:RegisterEvent("PLAYER_REGEN_DISABLED","CombatLockdown")
54 self:RegisterEvent("PLAYER_ENTERING_WORLD","HideDefaultBars")
55 self:DisableDefaultKeybindings() 54 self:DisableDefaultKeybindings()
56 55
57 -- create update function for keybinding frame 56 -- create update function for keybinding frame
58 ReActionKeybindDialog:SetScript("OnHide", function(frame) 57 ReActionKeybindDialog:SetScript("OnHide", function(frame) main:HideKeybindDialog(frame) end)
59 main:SetKeybindMode(false)
60 if frame.save then
61 ReBound:SaveBindings()
62 else
63 ReBound:RevertBindings()
64 end
65 frame.save = false
66 end )
67 58
68 -- initial non-persistent state 59 -- initial non-persistent state
69 self.locked = true 60 self.locked = true
61 self.keybindMode = false
70 self.bars = { } 62 self.bars = { }
71 end 63 end
72 64
73 -- OnEnable is called at startup and when the profile is changed (via OnProfileEnable) 65 -- OnEnable is called at PLAYER_LOGIN or when the addon is enabled.
74 function main:OnEnable( ) 66 function main:OnEnable( )
75 if self.db.profile.firstRunDone ~= true then 67 self:HideDefaultBars()
76 self.db.profile.bars = tcopy(ReAction_DefaultBlizzardBars) 68 self:SetupProfile( )
77 end
78 self:DestroyAllBars()
79 self:SetupBars()
80 self:UpgradeProfile()
81 self:SetupKeybindings()
82 if self.db.profile.firstRunDone ~= true then
83 self:Unlock()
84 end
85 self.db.profile.firstRunDone = true
86 end 69 end
87 70
88 function main:OnDisable() 71 function main:OnDisable()
89 self:Lock() 72 self:Lock()
90 end 73 end
92 -- OnProfileEnable() is only called when switching profiles, NOT for the initial profile at load time. 75 -- OnProfileEnable() is only called when switching profiles, NOT for the initial profile at load time.
93 function main:OnProfileEnable( oldName, oldData ) 76 function main:OnProfileEnable( oldName, oldData )
94 self:UnregisterEvent("REBOUND_BIND") 77 self:UnregisterEvent("REBOUND_BIND")
95 self:UnregisterEvent("REBOUND_UNBIND") 78 self:UnregisterEvent("REBOUND_UNBIND")
96 ReBound:ClearRegisteredBindings() 79 ReBound:ClearRegisteredBindings()
97 self:OnEnable() 80 self:SetupProfile()
98 end 81 end
99 82
100 function main:UpgradeProfile() 83 function main:SetupProfile( )
101 if self.db.profile.firstRunDone ~= true and #self.db.profile.bindings == 0 then 84 local profile = self.db.profile
85 if profile.firstRunDone ~= true then
86 profile.bars = tcopy(ReAction_DefaultBlizzardBars)
87 end
88 self:DestroyAllBars()
89 self:UpgradeProfile()
90 self:HideArt()
91 self:SetupBars()
92 self:SetupKeybindings()
93 if profile.firstRunDone ~= true then
94 self:Unlock()
95 profile.firstRunDone = true
96 end
97 end
98
99 -- Set a global variable for Bindings.xml (I use 'setglobal' for clarity, it's not strictly necessary)
100 setglobal("ReActionAddOn", main)
101
102
103
104
105 ------------------------------------------------------------
106 -- Profile conversion functions (from old profiles)
107 --
108 -- NOTE: these will be REMOVED when alpha testing is over.
109 ------------------------------------------------------------
110 function main:UpgradeBindingConfig()
111 if #self.db.profile.bindings == 0 then
102 for _, bar in pairs(self.bars) do 112 for _, bar in pairs(self.bars) do
103 for _, button in pairs(bar.buttons) do 113 for _, button in pairs(bar.buttons) do
104 local key = ReBound:GetBinding(button:GetActionFrame(),"LeftButton") 114 local key = ReBound:GetBinding(button:GetActionFrame(),"LeftButton")
105 if key and #key > 0 and not self.db.profile.bindings[key] then 115 if key and #key > 0 and not self.db.profile.bindings[key] then
106 self:REBOUND_BIND(key,button:GetActionFrame():GetName(),"LeftButton") 116 self:REBOUND_BIND(key,button:GetActionFrame():GetName(),"LeftButton")
108 end 118 end
109 end 119 end
110 end 120 end
111 end 121 end
112 122
123 function main:UpgradeProfile()
124 end
113 125
114 126
115 127
116 -------------------------------------------- 128 --------------------------------------------
117 -- FuBar plugin setup 129 -- FuBar plugin setup
153 165
154 ------------------------------ 166 ------------------------------
155 -- Key binding functions 167 -- Key binding functions
156 ------------------------------ 168 ------------------------------
157 function main:DisableDefaultKeybindings() 169 function main:DisableDefaultKeybindings()
158 -- change the labels on all actionbar keybindings in the default 170 -- change the labels on all actionbar keybindings in the default interface.
159 -- interface.
160 local label = "|cff999999("..L["Use ReAction"]..")|r" 171 local label = "|cff999999("..L["Use ReAction"]..")|r"
161 for i = 1, 12 do 172 for i = 1, 12 do
162 setglobal("BINDING_NAME_ACTIONBUTTON"..i,label) 173 setglobal("BINDING_NAME_ACTIONBUTTON"..i,label)
163 for j = 1, 4 do 174 for j = 1, 4 do
164 setglobal("BINDING_NAME_MULTIACTIONBAR"..j.."BUTTON"..i,label) 175 setglobal("BINDING_NAME_MULTIACTIONBAR"..j.."BUTTON"..i,label)
167 for i = 1, 6 do 178 for i = 1, 6 do
168 setglobal("BINDING_NAME_ACTIONPAGE"..i,label) 179 setglobal("BINDING_NAME_ACTIONPAGE"..i,label)
169 end 180 end
170 for i = 1, 10 do 181 for i = 1, 10 do
171 setglobal("BINDING_NAME_BONUSACTIONBUTTON"..i,label) 182 setglobal("BINDING_NAME_BONUSACTIONBUTTON"..i,label)
172 setglobal("BINDING_NAME_SHAPESHIFTBUTTON"..i,label) 183 -- setglobal("BINDING_NAME_SHAPESHIFTBUTTON"..i,label)
173 end 184 end
174 BINDING_HEADER_ACTIONBAR = "|cff999999"..L["Action Bar Functions Disabled"].."|r" 185 BINDING_HEADER_ACTIONBAR = "|cff999999"..L["Action Bar Functions Disabled"].."|r"
175 BINDING_HEADER_MULTIACTIONBAR = "|cff999999"..L["Multi-Action Bar Functions Disabled"].."|r" 186 BINDING_HEADER_MULTIACTIONBAR = "|cff999999"..L["Multi-Action Bar Functions Disabled"].."|r"
176 BINDING_NAME_NEXTACTIONPAGE = label 187 BINDING_NAME_NEXTACTIONPAGE = label
177 BINDING_NAME_PREVIOUSACTIONPAGE = label 188 BINDING_NAME_PREVIOUSACTIONPAGE = label
179 190
180 function main:SetupKeybindings() 191 function main:SetupKeybindings()
181 if self.db.profile.firstRunDone ~= true then 192 if self.db.profile.firstRunDone ~= true then
182 self:StealKeyBindings() 193 self:StealKeyBindings()
183 else 194 else
195 self:UpgradeBindingConfig()
196 local needsSave = false
184 for key, binding in pairs(self.db.profile.bindings) do 197 for key, binding in pairs(self.db.profile.bindings) do
185 local target = getglobal(binding.target) 198 local target = getglobal(binding.target)
186 if target then 199 if target then
187 ReBound:SetBinding(key, target, binding.button) 200 if ReBound:GetBinding(target,binding.button) ~= key then
188 end 201 ReBound:SetBinding(key,target,binding.button,true)
189 end 202 needsSave = true
190 end 203 end
191 ReBound:SaveBindings() 204 end
205 end
206 if needsSave then
207 ReBound:SaveBindings()
208 end
209 end
192 self:RegisterEvent("REBOUND_BIND") 210 self:RegisterEvent("REBOUND_BIND")
193 self:RegisterEvent("REBOUND_UNBIND") 211 self:RegisterEvent("REBOUND_UNBIND")
194 end 212 end
195 213
196 function main:StealKeyBindings() 214 function main:StealKeyBindings()
197 -- steal the keybindings of the main action bar and assign them to rebar 1, buttons 1-12 215 -- steal the keybindings of the main action bar and assign them to rebar 1, buttons 1-12
198 for i = 1, 12 do 216 local bar = self.bars[1]
199 local key = GetBindingKey("ACTIONBUTTON"..i) 217 if bar and bar ~= EMPTY_BAR_SLOT then
218 for i = 1, 12 do
219 local key = GetBindingKey("ACTIONBUTTON"..i)
220 if key and #key > 0 then
221 local button = bar.buttons[i]
222 if button then
223 ReBound:SetBinding(key, button:GetActionFrame(),nil,true)
224 end
225 end
226 end
227 local key = GetBindingKey("NEXTACTIONPAGE")
200 if key and #key > 0 then 228 if key and #key > 0 then
201 ReBound:ClearBinding(key,nil,nil,true) -- suppress notification printouts 229 ReBound:SetBinding(key, bar.upArrow,nil,true)
202 ReBound:SetBinding(key, self.bars[1].buttons[i]:GetActionFrame(), "LeftButton") 230 end
203 end 231 key = GetBindingKey("PREVIOUSACTIONPAGE")
204 end 232 if key and #key > 0 then
205 ReBound:SaveBindings() 233 ReBound:SetBinding(key, bar.downArrow,nil,true)
234 end
235 ReBound:SaveBindings()
236 end
206 end 237 end
207 238
208 function main:REBOUND_BIND(id, key, target, button) 239 function main:REBOUND_BIND(id, key, target, button)
209 if id == "REACTION" and key and target then 240 if id == "ReAction" and key and target then
210 self.db.profile.bindings[key] = { target = target, button = button } 241 self.db.profile.bindings[key] = { target = target, button = button }
211 end 242 end
212 end 243 end
213 244
214 function main:REBOUND_UNBIND(id, key) 245 function main:REBOUND_UNBIND(id, key)
215 if id == "REACTION" and key then 246 if id == "ReAction" and key then
216 self.db.profile.bindings[key] = nil 247 self.db.profile.bindings[key] = nil
217 end 248 end
218 end 249 end
219 250
220 function main:ToggleKeybindMode() 251 function main:ToggleKeybindMode()
224 function main:GetKeybindMode() 255 function main:GetKeybindMode()
225 return self.keybindMode 256 return self.keybindMode
226 end 257 end
227 258
228 function main:SetKeybindMode(enabled) 259 function main:SetKeybindMode(enabled)
229 if not InCombatLockdown() then 260 if InCombatLockdown() then
261 UIErrorsFrame:AddMessage(ERROR_NOT_IN_COMBAT)
262 else
230 self.keybindMode = enabled 263 self.keybindMode = enabled
231 for _, bar in pairs(self.bars) do 264 for _, bar in pairs(self.bars) do
232 for __, button in pairs(bar.buttons) do 265 if bar and bar ~= EMPTY_BAR_SLOT then
233 if button and button ~= EMPTY_BAR_SLOT then 266 for __, button in pairs(bar.buttons) do
234 button:TempShow(enabled) 267 if button then
268 button:TempShow(enabled)
269 end
235 end 270 end
236 end 271 end
237 end 272 end
238 if enabled then 273 if enabled then
239 ReBound:ShowFrames() 274 ReBound:ShowRegisteredFrames()
240 ReActionKeybindDialog:Show() 275 ReActionKeybindDialog:Show()
241 else 276 else
242 ReBound:HideFrames() 277 ReBound:HideRegisteredFrames()
243 if ReActionKeybindDialog:IsShown() then 278 if ReActionKeybindDialog:IsShown() then
244 ReActionKeybindDialog:Hide() 279 ReActionKeybindDialog:Hide()
245 end 280 end
246 end 281 end
247 else 282 end
248 UIErrorsFrame:AddMessage(ERROR_NOT_IN_COMBAT) 283 end
249 end 284
250 end 285 function main:HideKeybindDialog( frame )
251 286 self:SetKeybindMode(false)
252 287 if frame.save then
288 ReBound:SaveBindings()
289 else
290 ReBound:RevertBindings()
291 end
292 frame.save = false
293 end
253 294
254 295
255 ---------------------------- 296 ----------------------------
256 -- Bar lock/unlock functions 297 -- Bar lock/unlock functions
257 ---------------------------- 298 ----------------------------
297 function main:Unlock() 338 function main:Unlock()
298 self:SetLocked(false) 339 self:SetLocked(false)
299 end 340 end
300 341
301 function main:ToggleLocked() 342 function main:ToggleLocked()
302 main:SetLocked( not(self.locked) ) 343 self:SetLocked( not(self.locked) )
303 end 344 end
304 345
305 346
306 347
307 -------------------------------------------------------- 348 --------------------------------------------------------
308 -- Functions to hide the default Blizzard main bar parts 349 -- Functions to hide the default Blizzard main bar parts
309 -------------------------------------------------------- 350 --------------------------------------------------------
310 function main:HideArt() 351 function main:HideArt()
311 if self.db.profile.hideArt then 352 if self.db.profile.hideArt then
312 -- the pet bar is a child of MainMenuBar, and can't be hidden. Need to reparent it 353 -- the pet bar is a child of MainMenuBar, but can't be hidden because it will
354 -- break automatic pet bar show/hide. Need to reparent it.
313 PetActionBarFrame:SetParent(UIParent) 355 PetActionBarFrame:SetParent(UIParent)
314 MainMenuBar:Hide() -- this also hides the bags, xp bar, lag meter, and micro menu buttons. 356
315 -- these two are the pet bar background 357 -- these two are the pet bar background
316 -- unfortunately UIParent_ManageFramePositions() shows and hides these too 358 -- unfortunately UIParent_ManageFramePositions() shows and hides these too
317 -- so they get reparented to MainMenuBar 359 -- so they get reparented to MainMenuBar
318 SlidingActionBarTexture0:SetParent(MainMenuBar) 360 SlidingActionBarTexture0:SetParent(MainMenuBar)
319 SlidingActionBarTexture1:SetParent(MainMenuBar) 361 SlidingActionBarTexture1:SetParent(MainMenuBar)
362
363 MainMenuBar:Hide() -- this also hides the bags, xp bar, lag meter, and micro menu buttons.
320 else 364 else
321 SlidingActionBarTexture0:SetParent(PetActionBarFrame) 365 SlidingActionBarTexture0:SetParent(PetActionBarFrame)
322 SlidingActionBarTexture1:SetParent(PetActionBarFrame) 366 SlidingActionBarTexture1:SetParent(PetActionBarFrame)
367 PetActionBarFrame:SetParent(MainMenuBar)
323 MainMenuBar:Show() 368 MainMenuBar:Show()
324 end 369 end
325 end 370 end
326 371
327 function main:IsArtHidden() 372 function main:IsArtHidden()
410 -- Reset bars to blizzard defaults 455 -- Reset bars to blizzard defaults
411 function main:ResetBars() 456 function main:ResetBars()
412 if InCombatLockdown() then 457 if InCombatLockdown() then
413 UIErrorsFrame:AddMessage(SPELL_FAILED_AFFECTING_COMBAT) 458 UIErrorsFrame:AddMessage(SPELL_FAILED_AFFECTING_COMBAT)
414 else 459 else
415 self:DestroyAllBars()
416 self.db.profile.bars = tcopy(ReAction_DefaultBlizzardBars) 460 self.db.profile.bars = tcopy(ReAction_DefaultBlizzardBars)
417 self:SetupBars() 461 self:OnProfileEnable() -- treat it like a profile switch
418 end 462 end
419 end 463 end
420 464
421 function main:DestroyAllBars() 465 function main:DestroyAllBars()
422 -- destroy any existing bars 466 -- destroy any existing bars
424 self:DestroyBar(id) 468 self:DestroyBar(id)
425 end 469 end
426 end 470 end
427 471
428 function main:SetupBars() 472 function main:SetupBars()
429 -- hide the default Blizzard art, if configued
430 self:HideArt()
431
432 -- set up the bars from the profile 473 -- set up the bars from the profile
433 -- note the use of table.maxn rather than # or ipairs: 474 -- note the use of table.maxn rather than # or ipairs:
434 -- our array of bars can in fact contain holes 475 -- our array of bars can in fact contain holes
435 for id = 1, table.maxn(self.db.profile.bars) do 476 for id = 1, table.maxn(self.db.profile.bars) do
436 local config = self.db.profile.bars[id] 477 local config = self.db.profile.bars[id]
437 if config then 478 if config then
438 self:CreateBar(config, id) 479 self.bars[id] = self:CreateBar(config, id)
439 end 480 end
440 end 481 end
441 482
442 -- anchor the bars, have to do this in a second pass because 483 -- anchor the bars, have to do this in a second pass because
443 -- they might be anchored to each other in a non-ordered way 484 -- they might be anchored to each other in a non-ordered way
447 end 488 end
448 end 489 end
449 end 490 end
450 491
451 function main:CreateBar( config, id ) 492 function main:CreateBar( config, id )
493 local buttonType = config.btnConfig and config.btnConfig.type and getglobal(config.btnConfig.type)
494 local subtype = buttonType and buttonType:GetButtonType(config.btnConfig.subtype)
495
496 if not subtype then
497 self:Print(L["Tried to create a button of unknown type"])
498 return
499 end
500
452 local bar = ReBar:new(config, id) 501 local bar = ReBar:new(config, id)
453 local buttonType = ReAction:GetButtonType(config.btnConfig.subtype) 502
454 503 -- initialize dewdrop menu
455 if buttonType then 504 dewdrop:Register(bar:GetControlFrame(),
456 self.bars[id] = bar 505 'children',
457 self.db.profile.bars[id] = config 506 function()
458 507 dewdrop:FeedAceOptionsTable(ReActionGlobalMenuOptions)
459 -- initialize dewdrop menu 508 dewdrop:FeedAceOptionsTable(GenerateReActionBarOptions(bar,self))
460 local cf = bar:GetControlFrame() 509 dewdrop:FeedAceOptionsTable(subtype:GenerateOptionsTable(config.btnConfig, function() return bar:GetButtonList() end))
461 dewdrop:Register(cf, 510 end,
462 'children', 511 'cursorX', true,
463 function() 512 'cursorY', true
464 dewdrop:FeedAceOptionsTable(ReActionGlobalMenuOptions) 513 )
465 dewdrop:FeedAceOptionsTable(GenerateReActionBarOptions(bar,self)) 514
466 dewdrop:FeedAceOptionsTable(buttonType:GenerateOptionsTable(config.btnConfig, function() return bar:GetButtonList() end)) 515 -- register page up/down buttons with ReBound for keybinding
467 end, 516 ReBound:Register(bar.upArrow)
468 'cursorX', true, 517 ReBound:Register(bar.downArrow)
469 'cursorY', true 518
470 ) 519 if not self.locked then
471 520 bar:ShowControls()
472 bar:GetControlFrame():SetScript("OnClick", 521 end
473 function(btn) 522
474 if btn == "RightButton" then 523 return bar
475 dewdrop:Open(cf)
476 end
477 end
478 )
479
480 -- register page up/down buttons with ReBound for keybinding
481 ReBound:Register(bar.upArrow)
482 ReBound:Register(bar.downArrow)
483
484 if not self.locked then
485 bar:ShowControls()
486 end
487 return bar
488 else
489 if bar then
490 bar:Destroy()
491 end
492 error(L["Tried to create a button of unknown type"])
493 end
494 end 524 end
495 525
496 function main:DestroyBar( id ) 526 function main:DestroyBar( id )
497 local bar = self.bars[id] 527 local bar = self.bars[id]
498 if bar and bar ~= EMPTY_BAR_SLOT then 528 if bar and bar ~= EMPTY_BAR_SLOT then
514 -- this function is a wrapper for CreateBar() which looks up the bar type 544 -- this function is a wrapper for CreateBar() which looks up the bar type
515 -- and constructs a new configuration object of the right type. 545 -- and constructs a new configuration object of the right type.
516 function main:NewBar( type ) 546 function main:NewBar( type )
517 if InCombatLockdown() then 547 if InCombatLockdown() then
518 UIErrorsFrame:AddMessage(SPELL_FAILED_AFFECTING_COMBAT) 548 UIErrorsFrame:AddMessage(SPELL_FAILED_AFFECTING_COMBAT)
519 else 549 return
520 local t = ReAction:GetButtonType(type) 550 end
521 if t then 551
522 local c = tcopy(ReAction_DefaultBarConfig["ReAction"][type]) 552 local t = ReAction:GetButtonType(type)
523 local id = nil 553 if t then
524 for i = 1, table.maxn(self.bars) + 1 do -- there may be holes, so #self.bars won't work 554 local c = tcopy(ReAction_DefaultBarConfig["ReAction"][type])
525 if self.bars[i] == nil or self.bars[i] == EMPTY_BAR_SLOT then 555 local id = nil
526 id = i 556 for i = 1, table.maxn(self.bars) + 1 do -- there may be holes, so #self.bars won't work
527 break 557 if self.bars[i] == nil or self.bars[i] == EMPTY_BAR_SLOT then
528 end 558 id = i
529 end 559 break
530 local bar = self:CreateBar(c, id) 560 end
531 bar:ApplyAnchor() 561 end
532 self:Unlock() 562 self.bars[id] = self:CreateBar(c, id)
533 end 563 self.db.profile.bars[id] = c
564 self.bars[id]:ApplyAnchor()
565 self:Unlock()
534 end 566 end
535 end 567 end
536 568
537 -- 569 --
538 -- This function is a wrapper for DestroyBar() which does in-combat 570 -- This function is a wrapper for DestroyBar() which does in-combat
548 end 580 end
549 end 581 end
550 582
551 583
552 584
553
554 -----------------
555 -- General utility
556 -----------------
557 function main:ToggleIds()
558 if self.showIds then
559 ReAction:HideAllIds()
560 else
561 ReAction:ShowAllIds()
562 end
563 self.showIds = not self.showIds
564 end
565
566 function main:AreIdsVisible()
567 return self.showIds
568 end
569
570 -- set a global variable for Bindings.xml
571 ReActionAddOn = main
572
573