Mercurial > wow > kbf
comparison KBF.lua @ 67:673fd9893f1e
set consolidation so that infinite (duration = 0) buffs will be consoliated
| author | Chris Mellon <arkanes@gmail.com> |
|---|---|
| date | Sat, 30 Jun 2012 15:44:10 -0500 |
| parents | 6f1457157688 |
| children | f5bd73181349 |
comparison
equal
deleted
inserted
replaced
| 66:6f1457157688 | 67:673fd9893f1e |
|---|---|
| 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 self.oocQueue = {} |
| 10 -- config settings - account wide shared profile by default | 10 -- config settings - account wide shared profile by default |
| 11 self.db = LibStub("AceDB-3.0"):New("KBFSavedVars", self.defaultConfig, true) | 11 self.db = LibStub("AceDB-3.0"):New("KBFSavedVars", self.defaultConfig, true) |
| 12 -- 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 |
| 13 -- the UI. | 13 -- the UI. |
| 14 self.anchor, self.secureHeader, self.consolidateHeader, self.consolidateProxy = self:CreateCoreFrames() | 14 self.anchor, self.secureHeader, self.consolidateHeader, self.consolidateProxy = self:CreateCoreFrames() |
| 15 self.debuffFrames = {} | 15 self.debuffFrames = {} |
| 16 self:RegisterEvent("UNIT_AURA") | 16 self:RegisterEvent("UNIT_AURA") |
| 17 self:RegisterEvent("UNIT_ENTERING_VEHICLE", "PollForVehicleChange") | 17 self:RegisterEvent("UNIT_ENTERING_VEHICLE", "PollForVehicleChange") |
| 18 self:RegisterEvent("UNIT_EXITING_VEHICLE", "PollForVehicleChange") | 18 self:RegisterEvent("UNIT_EXITING_VEHICLE", "PollForVehicleChange") |
| 19 LibStub("AceConfig-3.0"):RegisterOptionsTable("KBF", self.options); | 19 LibStub("AceConfig-3.0"):RegisterOptionsTable("KBF", self.options); |
| 22 | 22 |
| 23 | 23 |
| 24 end | 24 end |
| 25 | 25 |
| 26 function kbf:OnEnable() | 26 function kbf:OnEnable() |
| 27 -- set up the countdown timer | 27 -- set up the countdown timer |
| 28 -- 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. |
| 29 -- Not a big deal, how often do you care about that | 29 -- Not a big deal, how often do you care about that |
| 30 -- also TODO: Maybe should bucket OnUpdates somehow | 30 -- also TODO: Maybe should bucket OnUpdates somehow |
| 31 -- AceTimer repeating events can only happen at 0.1 seconds, which is probably | 31 -- AceTimer repeating events can only happen at 0.1 seconds, which is probably |
| 32 -- fast enough for updating, but makes the animation look jerky | 32 -- fast enough for updating, but makes the animation look jerky |
| 45 -- so this only works out of combat. But thats better than nothing... | 45 -- so this only works out of combat. But thats better than nothing... |
| 46 function kbf:PollForVehicleChange(event, unit) | 46 function kbf:PollForVehicleChange(event, unit) |
| 47 if unit ~= "player" then return end | 47 if unit ~= "player" then return end |
| 48 self.dirty = true | 48 self.dirty = true |
| 49 local function performSwap() | 49 local function performSwap() |
| 50 if UnitHasVehicleUI("player") then | 50 if UnitHasVehicleUI("player") then |
| 51 -- only swap if we're in a "real" vehicle with its own actions | 51 -- only swap if we're in a "real" vehicle with its own actions |
| 52 -- There is possibly a timing issue here where | 52 -- There is possibly a timing issue here where |
| 53 -- we have set the poll flag but the unit is not | 53 -- we have set the poll flag but the unit is not |
| 54 -- actually "in" the vehicle yet. I'm hoping thats | 54 -- actually "in" the vehicle yet. I'm hoping thats |
| 55 -- handled by using exited/entered events instead of exiting/entering | 55 -- handled by using exited/entered events instead of exiting/entering |
| 56 self.secureHeader:SetAttribute("unit", "vehicle") | 56 self.secureHeader:SetAttribute("unit", "vehicle") |
| 57 else | 57 else |
| 58 self.secureHeader:SetAttribute("unit", "player") | 58 self.secureHeader:SetAttribute("unit", "player") |
| 59 end | 59 end |
| 60 end | 60 end |
| 78 -- enqueues a callable that will be run once in-combat lockdown is past | 78 -- enqueues a callable that will be run once in-combat lockdown is past |
| 79 -- all callables will be executed in a single run, in the order they were enqueued | 79 -- all callables will be executed in a single run, in the order they were enqueued |
| 80 -- if called when OOC, the function will be called immediately, unless the alwaysQueue parameter is true, | 80 -- if called when OOC, the function will be called immediately, unless the alwaysQueue parameter is true, |
| 81 -- in which case it will be appended normally | 81 -- in which case it will be appended normally |
| 82 function kbf:QueueForOOC(func, alwaysQueue) | 82 function kbf:QueueForOOC(func, alwaysQueue) |
| 83 if InCombatLockdown() or alwaysQueue then | 83 if InCombatLockdown() or alwaysQueue then |
| 84 tinsert(self.oocQueue, func) | 84 tinsert(self.oocQueue, func) |
| 85 else | 85 else |
| 86 func() | 86 func() |
| 87 end | 87 end |
| 88 end | 88 end |
| 89 | 89 |
| 90 function kbf:OnUpdate() | 90 function kbf:OnUpdate() |
| 91 -- TODO: only start this polling when we leave combat? | 91 -- TODO: only start this polling when we leave combat? |
| 92 while #self.oocQueue > 0 and not InCombatLockdown() do | 92 while #self.oocQueue > 0 and not InCombatLockdown() do |
| 93 local func = table.remove(self.oocQueue) | 93 local func = table.remove(self.oocQueue) |
| 94 func() | 94 func() |
| 95 end | 95 end |
| 96 | 96 |
| 97 local unit = self.secureHeader:GetAttribute("unit") | 97 local unit = self.secureHeader:GetAttribute("unit") |
| 98 local buffCount = 0 | 98 local buffCount = 0 |
| 99 for idx=1,99 do | 99 for idx=1,99 do |
| 100 local frame = self.secureHeader:GetAttribute("child"..idx) | 100 local frame = self.secureHeader:GetAttribute("child"..idx) |
| 101 if not (frame and frame:IsShown()) then break end | 101 if not (frame and frame:IsShown()) then break end |
| 102 local boundIndex = frame:GetAttribute("index") | 102 local boundIndex = frame:GetAttribute("index") |
| 103 if not boundIndex then | 103 if not boundIndex then |
| 104 break | 104 break |
| 105 end | 105 end |
| 106 if self.dirty then | 106 if self.dirty then |
| 107 local hasbuff = UnitAura(unit, boundIndex) | 107 local hasbuff = UnitAura(unit, boundIndex) |
| 108 --self:Print(hasbuff, idx, boundIndex) | 108 --self:Print(hasbuff, idx, boundIndex) |
| 109 if not hasbuff then | 109 if not hasbuff then |
| 110 if frame.icon then frame.icon:Hide() end | 110 if frame.icon then frame.icon:Hide() end |
| 111 if frame.statusbar then frame.statusbar:Hide() end | 111 if frame.statusbar then frame.statusbar:Hide() end |
| 112 if frame.statusbarbg then frame.statusbarbg:Hide() end | 112 if frame.statusbarbg then frame.statusbarbg:Hide() end |
| 113 if frame.text then frame.text:Hide() end | 113 if frame.text then frame.text:Hide() end |
| 114 if frame.timertext then frame.timertext:Hide() end | 114 if frame.timertext then frame.timertext:Hide() end |
| 115 break | 115 break |
| 116 end | 116 end |
| 117 buffCount = buffCount + 1 | 117 buffCount = buffCount + 1 |
| 118 | 118 |
| 119 if self.dirty then | 119 if self.dirty then |
| 120 if self:BindBarToBuff(frame, unit) then break end | 120 if self:BindBarToBuff(frame, unit) then break end |
| 121 end | 121 end |
| 122 frame.icon:Show() | 122 frame.icon:Show() |
| 123 frame.statusbar:Show() | 123 frame.statusbar:Show() |
| 124 frame.statusbarbg:Show() | 124 frame.statusbarbg:Show() |
| 125 frame.text:Show() | 125 frame.text:Show() |
| 126 frame.timertext:Show() | 126 frame.timertext:Show() |
| 127 end | 127 end |
| 128 self:UpdateBarExpirationTime(frame) | 128 self:UpdateBarExpirationTime(frame) |
| 129 -- Don't forget to refresh shown tooltips | 129 -- Don't forget to refresh shown tooltips |
| 130 if (GameTooltip:IsOwned(frame)) then | 130 if (GameTooltip:IsOwned(frame)) then |
| 131 self:OnEnter(frame) | 131 self:OnEnter(frame) |
| 132 end | 132 end |
| 133 end | 133 end |
| 134 -- consolidated buffs | 134 -- consolidated buffs |
| 135 if self.consolidateProxy:IsShown() then | 135 if self.consolidateProxy:IsShown() then |
| 136 for idx=1,99 do | 136 for idx=1,99 do |
| 137 local frame = self.consolidateHeader:GetAttribute("child"..idx) | 137 local frame = self.consolidateHeader:GetAttribute("child"..idx) |
| 138 if not (frame and frame:IsShown()) then break end | 138 if not (frame and frame:IsShown()) then break end |
| 139 if self.dirty then | 139 if self.dirty then |
| 140 if self:BindBarToBuff(frame, unit) then break end | 140 if self:BindBarToBuff(frame, unit) then break end |
| 141 end | 141 end |
| 142 self:UpdateBarExpirationTime(frame) | 142 self:UpdateBarExpirationTime(frame) |
| 143 -- Don't forget to refresh shown tooltips | 143 -- Don't forget to refresh shown tooltips |
| 144 if ( GameTooltip:IsOwned(frame) ) then | 144 if ( GameTooltip:IsOwned(frame) ) then |
| 145 self:OnEnter(frame) | 145 self:OnEnter(frame) |
| 146 end | 146 end |
| 147 end | 147 end |
| 148 buffCount = buffCount+1 | 148 buffCount = buffCount+1 |
| 149 end | 149 end |
| 150 -- SAH correctly binds the weapon enchant templates now, but when temp enchants | 150 -- SAH correctly binds the weapon enchant templates now, but when temp enchants |
| 151 -- are present and used, it seems that it doesn't correctly hide un-bound | 151 -- are present and used, it seems that it doesn't correctly hide un-bound |
| 152 -- buff frames, which breaks all the layout and so forth. | 152 -- buff frames, which breaks all the layout and so forth. |
| 153 for weapon=3,1,-1 do | 153 for weapon=3,1,-1 do |
| 154 local tempEnchant = self.secureHeader:GetAttribute("tempEnchant"..weapon) | 154 local tempEnchant = self.secureHeader:GetAttribute("tempEnchant"..weapon) |
| 155 if tempEnchant and tempEnchant:IsShown() then | 155 if tempEnchant and tempEnchant:IsShown() then |
| 156 self:BindBarToWeaponEnchant(tempEnchant) | 156 self:BindBarToWeaponEnchant(tempEnchant) |
| 157 self:UpdateBarExpirationTime(tempEnchant) | 157 self:UpdateBarExpirationTime(tempEnchant) |
| 158 buffCount = buffCount + 1 | 158 buffCount = buffCount + 1 |
| 159 end | 159 end |
| 160 end | 160 end |
| 161 | 161 |
| 162 -- debuffs | 162 -- debuffs |
| 163 -- Since debuffs aren't cancellable, don't need to use the secure header | 163 -- Since debuffs aren't cancellable, don't need to use the secure header |
| 164 -- for them. This could be rewritten to support useful features like | 164 -- for them. This could be rewritten to support useful features like |
| 165 -- sorting & scaling and stuff. Honestly, should at least be alphabetical. | 165 -- sorting & scaling and stuff. Honestly, should at least be alphabetical. |
| 166 for idx=1,99 do | 166 for idx=1,99 do |
| 167 local frame = self.debuffFrames[idx] | 167 local frame = self.debuffFrames[idx] |
| 168 if self.dirty then | 168 if self.dirty then |
| 169 local name, rank, icon, stacks, debuffType, duration, expirationTime = UnitAura(unit, idx, "HARMFUL") | 169 local name, rank, icon, stacks, debuffType, duration, expirationTime = UnitAura(unit, idx, "HARMFUL") |
| 170 if not name then | 170 if not name then |
| 231 local remaining = remaining / 1000 | 231 local remaining = remaining / 1000 |
| 232 | 232 |
| 233 local icon = GetInventoryItemTexture("player", slot) | 233 local icon = GetInventoryItemTexture("player", slot) |
| 234 local maxDuration | 234 local maxDuration |
| 235 if select(2, UnitClass("player")) == "ROGUE" then | 235 if select(2, UnitClass("player")) == "ROGUE" then |
| 236 -- Rogues are probably using poisons, which are an hour | 236 -- Rogues are probably using poisons, which are an hour |
| 237 maxDuration = 60 * 60 | 237 maxDuration = 60 * 60 |
| 238 else | 238 else |
| 239 -- everyone else is probably using something thats a half hour | 239 -- everyone else is probably using something thats a half hour |
| 240 maxDuration = 30 * 60 | 240 maxDuration = 30 * 60 |
| 241 end | 241 end |
| 242 local duration = max(maxDuration, remaining) | 242 local duration = max(maxDuration, remaining) |
| 243 local expirationTime = GetTime() + remaining | 243 local expirationTime = GetTime() + remaining |
| 244 local name = GetItemInfo(GetInventoryItemID("player", slot)) | 244 local name = GetItemInfo(GetInventoryItemID("player", slot)) |
| 245 -- try to figure out what the weapon enchant is | 245 -- try to figure out what the weapon enchant is |
| 246 -- tooltip string -> {spellid, duration} | 246 -- tooltip string -> {spellid, duration} |
| 247 local knownEnchants = { | 247 local knownEnchants = { |
| 248 ["Flametongue"] = {8024, 30*60}, | 248 ["Flametongue"] = {8024, 30*60}, |
| 249 ["Frostbrand"] = {8033, 30*60}, | 249 ["Frostbrand"] = {8033, 30*60}, |
| 250 ["Earthliving"] = {51730, 30*60}, | 250 ["Earthliving"] = {51730, 30*60}, |
| 251 ["Windfury"] = {8232, 30*60}, | 251 ["Windfury"] = {8232, 30*60}, |
| 252 ["Instant Poison"] = {8680, 60*60}, | 252 ["Instant Poison"] = {8680, 60*60}, |
| 253 ["Wound Poison"] = {13218, 60*60}, | 253 ["Wound Poison"] = {13218, 60*60}, |
| 254 ["Deadly Poison"] = {2823, 60*60}, | 254 ["Deadly Poison"] = {2823, 60*60}, |
| 255 ["Crippling Poison"] = {3408, 60*60} | 255 ["Crippling Poison"] = {3408, 60*60} |
| 256 | 256 |
| 257 } | 257 } |
| 258 local spellId = nil | 258 local spellId = nil |
| 259 if gratt then | 259 if gratt then |
| 260 gratt:SetInventoryItem("player", slot) | 260 gratt:SetInventoryItem("player", slot) |
| 261 for tag, info in pairs(knownEnchants) do | 261 for tag, info in pairs(knownEnchants) do |
| 262 if gratt:Find(tag) then | 262 if gratt:Find(tag) then |
| 263 spellId, duration = unpack(info) | 263 spellId, duration = unpack(info) |
| 264 name, _, _ = GetSpellInfo(spellId) | 264 name, _, _ = GetSpellInfo(spellId) |
| 265 local slots = {[16] = "Main Hand", [17] = "Off Hand", [18] = "Thrown"} | 265 local slots = {[16] = "Main Hand", [17] = "Off Hand", [18] = "Thrown"} |
| 266 name = tag .. " (" .. slots[slot] .. ")" | 266 name = tag .. " (" .. slots[slot] .. ")" |
| 267 break | 267 break |
| 268 end | 268 end |
| 269 end | 269 end |
| 270 end | 270 end |
| 271 parentFrame.spellId = spellId | 271 parentFrame.spellId = spellId |
| 272 if not parentFrame.icon then | 272 if not parentFrame.icon then |
| 273 self:ConstructBar(parentFrame, 1, 0, 1) | 273 self:ConstructBar(parentFrame, 1, 0, 1) |
| 274 end | 274 end |
| 275 self:SetBarAppearance(parentFrame, name, icon, enchantCharges, duration, expirationTime) | 275 self:SetBarAppearance(parentFrame, name, icon, enchantCharges, duration, expirationTime) |
| 340 GameTooltip:SetUnitAura(unit, index, filter); | 340 GameTooltip:SetUnitAura(unit, index, filter); |
| 341 return | 341 return |
| 342 end | 342 end |
| 343 local slot = button:GetAttribute("target-slot") -- temp enchant | 343 local slot = button:GetAttribute("target-slot") -- temp enchant |
| 344 if slot then | 344 if slot then |
| 345 GameTooltip:SetOwner(button, "ANCHOR_BOTTOMLEFT"); | 345 GameTooltip:SetOwner(button, "ANCHOR_BOTTOMLEFT"); |
| 346 GameTooltip:SetFrameLevel(button:GetFrameLevel() + 2); | 346 GameTooltip:SetFrameLevel(button:GetFrameLevel() + 2); |
| 347 if button.spellId then | 347 if button.spellId then |
| 348 -- TODO: This might be too big of a tooltip to care about that much. | 348 -- TODO: This might be too big of a tooltip to care about that much. |
| 349 -- Maybe I should just have a single line with the weapon name | 349 -- Maybe I should just have a single line with the weapon name |
| 350 --GameTooltip:SetInventoryItem(unit, slot) | 350 --GameTooltip:SetInventoryItem(unit, slot) |
| 351 local name = GetItemInfo(GetInventoryItemID("player", slot)) | 351 local name = GetItemInfo(GetInventoryItemID("player", slot)) |
| 352 local r, g, b = GetItemQualityColor(GetInventoryItemQuality("player", slot)) | 352 local r, g, b = GetItemQualityColor(GetInventoryItemQuality("player", slot)) |
| 353 GameTooltip:SetText(name, r, g, b) | 353 GameTooltip:SetText(name, r, g, b) |
| 354 local slots = {[16] = "Main Hand", [17] = "Off Hand", [18] = "Thrown"} | 354 local slots = {[16] = "Main Hand", [17] = "Off Hand", [18] = "Thrown"} |
| 355 GameTooltip:AddLine(slots[slot]) | 355 GameTooltip:AddLine(slots[slot]) |
| 356 GameTooltip:AddLine(" ") | 356 GameTooltip:AddLine(" ") |
| 357 GameTooltip:AddSpellByID(button.spellId) | 357 GameTooltip:AddSpellByID(button.spellId) |
| 358 else | 358 else |
| 359 GameTooltip:SetInventoryItem(unit, slot) | 359 GameTooltip:SetInventoryItem(unit, slot) |
| 360 end | 360 end |
| 361 end | 361 end |
| 362 end | 362 end |
| 363 | 363 |
| 364 -- creates a icon + statusbar bar | 364 -- creates a icon + statusbar bar |
| 365 function kbf:ConstructBar(frame, r, g, b) | 365 function kbf:ConstructBar(frame, r, g, b) |
| 366 local texture = "Interface\\TargetingFrame\\UI-StatusBar" | 366 local texture = "Interface\\TargetingFrame\\UI-StatusBar" |
| 387 bar.icon = CreateFrame("Button", "ABC-Icon", bar) -- the icon | 387 bar.icon = CreateFrame("Button", "ABC-Icon", bar) -- the icon |
| 388 bar.statusbarbg = CreateFrame("StatusBar", "ABC-BG", bar) -- the bars background | 388 bar.statusbarbg = CreateFrame("StatusBar", "ABC-BG", bar) -- the bars background |
| 389 bar.statusbar = CreateFrame("StatusBar", "ABC-status", bar) -- and the bars foreground | 389 bar.statusbar = CreateFrame("StatusBar", "ABC-status", bar) -- and the bars foreground |
| 390 bar.text = bar.statusbar:CreateFontString(nil, "OVERLAY") -- the label text | 390 bar.text = bar.statusbar:CreateFontString(nil, "OVERLAY") -- the label text |
| 391 bar.timertext = bar.statusbar:CreateFontString(nil, "OVERLAY") -- and the timer text | 391 bar.timertext = bar.statusbar:CreateFontString(nil, "OVERLAY") -- and the timer text |
| 392 | 392 |
| 393 | 393 |
| 394 -- the icon | 394 -- the icon |
| 395 bar.icon:ClearAllPoints() | 395 bar.icon:ClearAllPoints() |
| 396 bar.icon:SetPoint("LEFT", bar, "LEFT", 0, 0) | 396 bar.icon:SetPoint("LEFT", bar, "LEFT", 0, 0) |
| 397 -- icons are square | 397 -- icons are square |
| 436 bar.text:SetTextColor(textcolor[1], textcolor[2], textcolor[3], textcolor[4]) | 436 bar.text:SetTextColor(textcolor[1], textcolor[2], textcolor[3], textcolor[4]) |
| 437 return bar | 437 return bar |
| 438 end | 438 end |
| 439 | 439 |
| 440 function kbf:CreateCoreFrames() | 440 function kbf:CreateCoreFrames() |
| 441 -- this is the visible anchor frame that the user interacts with | 441 -- this is the visible anchor frame that the user interacts with |
| 442 -- to move the buffs around | 442 -- to move the buffs around |
| 443 local height = self.staticConfig.BAR_HEIGHT | 443 local height = self.staticConfig.BAR_HEIGHT |
| 444 local width = self.staticConfig.BAR_WIDTH -- this is the width *without* the icon | 444 local width = self.staticConfig.BAR_WIDTH -- this is the width *without* the icon |
| 445 local anchor = CreateFrame("FRAME", "KBFAnchorFrame", UIParent) | 445 local anchor = CreateFrame("FRAME", "KBFAnchorFrame", UIParent) |
| 446 anchor:SetClampedToScreen(true) | 446 anchor:SetClampedToScreen(true) |
| 447 anchor:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", | 447 anchor:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", |
| 448 edgeFile = "Interface/Tooltips/UI-Tooltip-Border", | 448 edgeFile = "Interface/Tooltips/UI-Tooltip-Border", |
| 466 anchor:ClearAllPoints() | 466 anchor:ClearAllPoints() |
| 467 anchor:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0) | 467 anchor:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0) |
| 468 anchor:Hide() | 468 anchor:Hide() |
| 469 -- this is the parent & host for the secure aura buttons. | 469 -- this is the parent & host for the secure aura buttons. |
| 470 | 470 |
| 471 local secureHeader = CreateFrame("FRAME", "KBFBuffFrame", UIParent, "SecureAuraHeaderTemplate") | 471 local secureHeader = CreateFrame("FRAME", "KBFBuffFrame", UIParent, "SecureAuraHeaderTemplate") |
| 472 self:SetCommonSecureHeaderAttributes(secureHeader) | 472 self:SetCommonSecureHeaderAttributes(secureHeader) |
| 473 if self.db.profile.consolidateBuffs then | 473 if self.db.profile.consolidateBuffs then |
| 474 secureHeader:SetAttribute("consolidateTo", 99) | 474 secureHeader:SetAttribute("consolidateTo", 99) |
| 475 end | 475 secureHeader:SetAttribute("consolidateDuration", -1) -- put 0 duration buffs into consolidation |
| 476 end | |
| 476 secureHeader:SetPoint("TOP", anchor, "TOP", 0, 0) | 477 secureHeader:SetPoint("TOP", anchor, "TOP", 0, 0) |
| 477 | 478 |
| 478 -- this is the "button" in the aura flow that represents the consolidated buffs. | 479 -- this is the "button" in the aura flow that represents the consolidated buffs. |
| 479 -- pre-creating it here in order to perform customization | 480 -- pre-creating it here in order to perform customization |
| 480 local consolidateProxy = CreateFrame("BUTTON", "KBFConsolidateProxy", UIParent, "SecureHandlerClickTemplate") | 481 local consolidateProxy = CreateFrame("BUTTON", "KBFConsolidateProxy", UIParent, "SecureHandlerClickTemplate") |
| 481 consolidateProxy:SetFrameStrata("HIGH") | 482 consolidateProxy:SetFrameStrata("HIGH") |
| 482 consolidateProxy:SetNormalTexture("Interface\\TargetingFrame\\UI-StatusBar") | 483 consolidateProxy:SetNormalTexture("Interface\\TargetingFrame\\UI-StatusBar") |
| 483 consolidateProxy:SetWidth(200 +16) | 484 consolidateProxy:SetWidth(200 +16) |
| 484 consolidateProxy:SetHeight(16) | 485 consolidateProxy:SetHeight(16) |
| 485 secureHeader:SetAttribute("consolidateProxy", consolidateProxy) | 486 secureHeader:SetAttribute("consolidateProxy", consolidateProxy) |
| 486 --secureHeader:SetFrameRef("proxy", consolidateProxy) | 487 --secureHeader:SetFrameRef("proxy", consolidateProxy) |
| 487 | 488 |
| 488 | 489 |
| 489 -- this is the equivilent of the secureHeader for the consolidated buffs | 490 -- this is the equivilent of the secureHeader for the consolidated buffs |
| 490 -- pre-creating again, so we can customize/size/position it | 491 -- pre-creating again, so we can customize/size/position it |
| 491 local consolidateHeader = CreateFrame("FRAME", "KBFConsolidatedAnchorFrame", consolidateProxy) | 492 local consolidateHeader = CreateFrame("FRAME", "KBFConsolidatedAnchorFrame", consolidateProxy) |
| 492 self:SetCommonSecureHeaderAttributes(consolidateHeader) | 493 self:SetCommonSecureHeaderAttributes(consolidateHeader) |
| 493 secureHeader:SetAttribute("consolidateHeader", consolidateHeader) | 494 secureHeader:SetAttribute("consolidateHeader", consolidateHeader) |
| 494 consolidateProxy:SetAttribute("header", consolidateHeader); | 495 consolidateProxy:SetAttribute("header", consolidateHeader); |
| 495 consolidateProxy:SetFrameRef("header", consolidateHeader) | 496 consolidateProxy:SetFrameRef("header", consolidateHeader) |
| 496 | 497 |
| 497 consolidateProxy:SetAttribute("_onclick", [[ | 498 consolidateProxy:SetAttribute("_onclick", [[ |
| 498 local frame = self:GetFrameRef("header") | 499 local frame = self:GetFrameRef("header") |
| 499 if frame:IsShown() then frame:Hide() else frame:Show() end | 500 if frame:IsShown() then frame:Hide() else frame:Show() end |
| 500 ]]) | 501 ]]) |
| 501 consolidateProxy:EnableMouse(true) | 502 consolidateProxy:EnableMouse(true) |
| 502 consolidateProxy:RegisterForClicks("AnyUp") | 503 consolidateProxy:RegisterForClicks("AnyUp") |
| 503 | 504 |
| 504 -- position it relative to the proxy, so it can appear where we want it | 505 -- position it relative to the proxy, so it can appear where we want it |
| 505 consolidateHeader:SetPoint("TOPRIGHT", anchor, "TOPLEFT", 0, 0) | 506 consolidateHeader:SetPoint("TOPRIGHT", anchor, "TOPLEFT", 0, 0) |
| 506 consolidateHeader:SetWidth(height + width) | 507 consolidateHeader:SetWidth(height + width) |
| 507 consolidateHeader:SetHeight(height) | 508 consolidateHeader:SetHeight(height) |
| 508 consolidateHeader:Show() | 509 consolidateHeader:Show() |
| 509 | 510 |
| 510 return anchor, secureHeader, consolidateHeader, consolidateProxy | 511 return anchor, secureHeader, consolidateHeader, consolidateProxy |
| 511 end | 512 end |
| 512 | 513 |
| 513 --- sets the attributes needed by all the headers | 514 --- sets the attributes needed by all the headers |
| 514 function kbf:SetCommonSecureHeaderAttributes(frame) | 515 function kbf:SetCommonSecureHeaderAttributes(frame) |
| 522 frame:SetAttribute("minHeight", 16) | 523 frame:SetAttribute("minHeight", 16) |
| 523 frame:SetAttribute("unit", "player") | 524 frame:SetAttribute("unit", "player") |
| 524 frame:SetAttribute("sortMethod", "NAME") | 525 frame:SetAttribute("sortMethod", "NAME") |
| 525 frame:SetAttribute("sortOrder", "-") | 526 frame:SetAttribute("sortOrder", "-") |
| 526 frame:SetAttribute("weaponTemplate", "KBFSecureWeaponEnchantTemplate") | 527 frame:SetAttribute("weaponTemplate", "KBFSecureWeaponEnchantTemplate") |
| 527 -- TODO: 4.3 SAH has a bug that messes up buff binding when a consolidate proxy | 528 -- TODO: 4.3 SAH has a bug that messes up buff binding when a consolidate proxy |
| 528 -- and/or weapon enchants are present, don't use them. Set up a standalone enchant window to be managed | 529 -- and/or weapon enchants are present, don't use them. Set up a standalone enchant window to be managed |
| 529 -- independently | 530 -- independently |
| 530 frame:SetAttribute("includeWeapons", 100) | 531 frame:SetAttribute("includeWeapons", 100) |
| 531 frame:Show() -- has to be shown, otherwise the child frames don't show | 532 frame:Show() -- has to be shown, otherwise the child frames don't show |
| 532 return frame | 533 return frame |
| 533 end | 534 end |
| 534 | 535 |
| 549 self:HideAnchor() | 550 self:HideAnchor() |
| 550 else | 551 else |
| 551 self:ShowAnchor() | 552 self:ShowAnchor() |
| 552 end | 553 end |
| 553 end | 554 end |
| 554 |
