comparison KBF.lua @ 66:6f1457157688

do less in on update, strata-based workaround for the SAH bug with failing to hide aura buttons
author Chris Mellon <arkanes@gmail.com>
date Tue, 28 Feb 2012 13:44:48 -0600
parents e19d0380b9f3
children 673fd9893f1e
comparison
equal deleted inserted replaced
65:e19d0380b9f3 66:6f1457157688
4 4
5 local kbf = LibStub("AceAddon-3.0"):NewAddon(kbf, "KBF", "AceEvent-3.0", "AceConsole-3.0") 5 local kbf = LibStub("AceAddon-3.0"):NewAddon(kbf, "KBF", "AceEvent-3.0", "AceConsole-3.0")
6 6
7 7
8 function kbf:OnInitialize() 8 function kbf:OnInitialize()
9 self.oocQueue = {}
9 -- config settings - account wide shared profile by default 10 -- config settings - account wide shared profile by default
10 self.db = LibStub("AceDB-3.0"):New("KBFSavedVars", self.defaultConfig, true) 11 self.db = LibStub("AceDB-3.0"):New("KBFSavedVars", self.defaultConfig, true)
11 -- create frames here so that they will be correctly stored in location cache by 12 -- create frames here so that they will be correctly stored in location cache by
12 -- the UI. 13 -- the UI.
13 self.anchor, self.secureHeader, self.consolidateHeader, self.consolidateProxy = self:CreateCoreFrames() 14 self.anchor, self.secureHeader, self.consolidateHeader, self.consolidateProxy = self:CreateCoreFrames()
17 self:RegisterEvent("UNIT_EXITING_VEHICLE", "PollForVehicleChange") 18 self:RegisterEvent("UNIT_EXITING_VEHICLE", "PollForVehicleChange")
18 LibStub("AceConfig-3.0"):RegisterOptionsTable("KBF", self.options); 19 LibStub("AceConfig-3.0"):RegisterOptionsTable("KBF", self.options);
19 self.profilesFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("KBF", "KBF"); 20 self.profilesFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("KBF", "KBF");
20 self:RegisterChatCommand("kbf", "ToggleAnchor") 21 self:RegisterChatCommand("kbf", "ToggleAnchor")
21 22
22 self.oocQueue = {} 23
23 end 24 end
24 25
25 function kbf:OnEnable() 26 function kbf:OnEnable()
26 -- set up the countdown timer 27 -- set up the countdown timer
27 -- TODO: Fancy enable/disable based on whether you have any timed buffs. 28 -- TODO: Fancy enable/disable based on whether you have any timed buffs.
100 if not (frame and frame:IsShown()) then break end 101 if not (frame and frame:IsShown()) then break end
101 local boundIndex = frame:GetAttribute("index") 102 local boundIndex = frame:GetAttribute("index")
102 if not boundIndex then 103 if not boundIndex then
103 break 104 break
104 end 105 end
105 local hasbuff = UnitAura(unit, boundIndex) 106 if self.dirty then
106 --self:Print(hasbuff, idx, boundIndex) 107 local hasbuff = UnitAura(unit, boundIndex)
107 if not hasbuff then 108 --self:Print(hasbuff, idx, boundIndex)
108 if frame.icon then frame.icon:Hide() end 109 if not hasbuff then
109 if frame.statusbar then frame.statusbar:Hide() end 110 if frame.icon then frame.icon:Hide() end
110 if frame.statusbarbg then frame.statusbarbg:Hide() end 111 if frame.statusbar then frame.statusbar:Hide() end
111 if frame.text then frame.text:Hide() end 112 if frame.statusbarbg then frame.statusbarbg:Hide() end
112 if frame.timertext then frame.timertext:Hide() end 113 if frame.text then frame.text:Hide() end
113 break 114 if frame.timertext then frame.timertext:Hide() end
114 end 115 break
115 buffCount = buffCount + 1 116 end
116 117 buffCount = buffCount + 1
117 if self.dirty then 118
118 if self:BindBarToBuff(frame, unit) then break end 119 if self.dirty then
119 end 120 if self:BindBarToBuff(frame, unit) then break end
120 frame.icon:Show() 121 end
121 frame.statusbar:Show() 122 frame.icon:Show()
122 frame.statusbarbg:Show() 123 frame.statusbar:Show()
123 frame.text:Show() 124 frame.statusbarbg:Show()
124 frame.timertext:Show() 125 frame.text:Show()
126 frame.timertext:Show()
127 end
125 self:UpdateBarExpirationTime(frame) 128 self:UpdateBarExpirationTime(frame)
126 -- Don't forget to refresh shown tooltips 129 -- Don't forget to refresh shown tooltips
127 if (GameTooltip:IsOwned(frame)) then 130 if (GameTooltip:IsOwned(frame)) then
128 self:OnEnter(frame) 131 self:OnEnter(frame)
129 end 132 end
247 ["Earthliving"] = {51730, 30*60}, 250 ["Earthliving"] = {51730, 30*60},
248 ["Windfury"] = {8232, 30*60}, 251 ["Windfury"] = {8232, 30*60},
249 ["Instant Poison"] = {8680, 60*60}, 252 ["Instant Poison"] = {8680, 60*60},
250 ["Wound Poison"] = {13218, 60*60}, 253 ["Wound Poison"] = {13218, 60*60},
251 ["Deadly Poison"] = {2823, 60*60}, 254 ["Deadly Poison"] = {2823, 60*60},
255 ["Crippling Poison"] = {3408, 60*60}
252 256
253 } 257 }
254 local spellId = nil 258 local spellId = nil
255 if gratt then 259 if gratt then
256 gratt:SetInventoryItem("player", slot) 260 gratt:SetInventoryItem("player", slot)
373 local fontsize = 11 377 local fontsize = 11
374 local timertextwidth = fontsize * 3.6 378 local timertextwidth = fontsize * 3.6
375 local textcolor = {1, 1, 1, 1} 379 local textcolor = {1, 1, 1, 1}
376 local timertextcolor = {1, 1, 1, 1} 380 local timertextcolor = {1, 1, 1, 1}
377 if not frame then 381 if not frame then
378 frame = CreateFrame("Button", nil, UIParent) -- the "top level" frame that represents the bar as a whole 382 frame = CreateFrame("Button", "ABC", UIParent) -- the "top level" frame that represents the bar as a whole
379 frame:SetHeight(height) 383 frame:SetHeight(height)
380 frame:SetWidth(width + height) 384 frame:SetWidth(width + height)
381 end 385 end
382 local bar = frame 386 local bar = frame
383 bar.icon = CreateFrame("Button", nil, bar) -- the icon 387 bar.icon = CreateFrame("Button", "ABC-Icon", bar) -- the icon
384 bar.statusbarbg = CreateFrame("StatusBar", nil, bar) -- the bars background 388 bar.statusbarbg = CreateFrame("StatusBar", "ABC-BG", bar) -- the bars background
385 bar.statusbar = CreateFrame("StatusBar", nil, bar) -- and the bars foreground 389 bar.statusbar = CreateFrame("StatusBar", "ABC-status", bar) -- and the bars foreground
386 bar.text = bar.statusbar:CreateFontString(nil, "OVERLAY") -- the label text 390 bar.text = bar.statusbar:CreateFontString(nil, "OVERLAY") -- the label text
387 bar.timertext = bar.statusbar:CreateFontString(nil, "OVERLAY") -- and the timer text 391 bar.timertext = bar.statusbar:CreateFontString(nil, "OVERLAY") -- and the timer text
392
388 393
389 -- the icon 394 -- the icon
390 bar.icon:ClearAllPoints() 395 bar.icon:ClearAllPoints()
391 bar.icon:SetPoint("LEFT", bar, "LEFT", 0, 0) 396 bar.icon:SetPoint("LEFT", bar, "LEFT", 0, 0)
392 -- icons are square 397 -- icons are square
407 sb:SetMinMaxValues(0,1) 412 sb:SetMinMaxValues(0,1)
408 sb:SetValue(1) 413 sb:SetValue(1)
409 end 414 end
410 setupStatusBar(bar.statusbarbg, bgcolor) 415 setupStatusBar(bar.statusbarbg, bgcolor)
411 setupStatusBar(bar.statusbar, color) 416 setupStatusBar(bar.statusbar, color)
412 bar.statusbarbg:SetFrameLevel(bar.statusbarbg:GetFrameLevel()-1) -- make sure the bg frame stays in the back 417 bar.statusbarbg:SetFrameLevel(bar.statusbar:GetFrameLevel()-1) -- make sure the bg frame stays in the back
413 -- timer text 418 -- timer text
414 bar.timertext:SetFontObject(GameFontHighlight) 419 bar.timertext:SetFontObject(GameFontHighlight)
415 bar.timertext:SetFont(GameFontHighlight:GetFont()) 420 bar.timertext:SetFont(GameFontHighlight:GetFont())
416 bar.timertext:SetHeight(height) 421 bar.timertext:SetHeight(height)
417 bar.timertext:SetWidth(timertextwidth) 422 bar.timertext:SetWidth(timertextwidth)
470 end 475 end
471 secureHeader:SetPoint("TOP", anchor, "TOP", 0, 0) 476 secureHeader:SetPoint("TOP", anchor, "TOP", 0, 0)
472 477
473 -- this is the "button" in the aura flow that represents the consolidated buffs. 478 -- this is the "button" in the aura flow that represents the consolidated buffs.
474 -- pre-creating it here in order to perform customization 479 -- pre-creating it here in order to perform customization
475 local consolidateProxy = CreateFrame("BUTTON", nil, UIParent, "SecureHandlerClickTemplate") 480 local consolidateProxy = CreateFrame("BUTTON", "KBFConsolidateProxy", UIParent, "SecureHandlerClickTemplate")
481 consolidateProxy:SetFrameStrata("HIGH")
476 consolidateProxy:SetNormalTexture("Interface\\TargetingFrame\\UI-StatusBar") 482 consolidateProxy:SetNormalTexture("Interface\\TargetingFrame\\UI-StatusBar")
477 consolidateProxy:SetWidth(200 +16) 483 consolidateProxy:SetWidth(200 +16)
478 consolidateProxy:SetHeight(16) 484 consolidateProxy:SetHeight(16)
479 secureHeader:SetAttribute("consolidateProxy", consolidateProxy) 485 secureHeader:SetAttribute("consolidateProxy", consolidateProxy)
480 --secureHeader:SetFrameRef("proxy", consolidateProxy) 486 --secureHeader:SetFrameRef("proxy", consolidateProxy)
519 frame:SetAttribute("sortOrder", "-") 525 frame:SetAttribute("sortOrder", "-")
520 frame:SetAttribute("weaponTemplate", "KBFSecureWeaponEnchantTemplate") 526 frame:SetAttribute("weaponTemplate", "KBFSecureWeaponEnchantTemplate")
521 -- TODO: 4.3 SAH has a bug that messes up buff binding when a consolidate proxy 527 -- TODO: 4.3 SAH has a bug that messes up buff binding when a consolidate proxy
522 -- and/or weapon enchants are present, don't use them. Set up a standalone enchant window to be managed 528 -- and/or weapon enchants are present, don't use them. Set up a standalone enchant window to be managed
523 -- independently 529 -- independently
524 frame:SetAttribute("includeWeapons", nil) 530 frame:SetAttribute("includeWeapons", 100)
525 frame:Show() -- has to be shown, otherwise the child frames don't show 531 frame:Show() -- has to be shown, otherwise the child frames don't show
526 return frame 532 return frame
527 end 533 end
528 534
529 function kbf:ShowAnchor() 535 function kbf:ShowAnchor()