arkanes@0: local _, kbf = ... arkanes@0: arkanes@0: KBF = kbf -- make global for debugging arkanes@0: arkanes@0: local kbf = LibStub("AceAddon-3.0"):NewAddon(kbf, "KBF", "AceEvent-3.0", "AceConsole-3.0") arkanes@0: arkanes@0: arkanes@0: function kbf:OnInitialize() arkanes@54: -- config settings - account wide shared profile by default arkanes@54: self.db = LibStub("AceDB-3.0"):New("KBFSavedVars", self.defaultConfig, true) arkanes@45: -- create frames here so that they will be correctly stored in location cache by arkanes@45: -- the UI. arkanes@45: self.anchor, self.secureHeader, self.consolidateHeader, self.consolidateProxy = self:CreateCoreFrames() arkanes@10: self.debuffFrames = {} arkanes@0: self:RegisterEvent("UNIT_AURA") arkanes@27: self:RegisterEvent("UNIT_ENTERING_VEHICLE", "PollForVehicleChange") arkanes@27: self:RegisterEvent("UNIT_EXITING_VEHICLE", "PollForVehicleChange") arkanes@57: LibStub("AceConfig-3.0"):RegisterOptionsTable("KBF", self.options); arkanes@57: self.profilesFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("KBF", "KBF"); arkanes@38: self:RegisterChatCommand("kbf", "ToggleAnchor") arkanes@45: arkanes@45: self.oocQueue = {} arkanes@38: end arkanes@38: arkanes@38: function kbf:OnEnable() arkanes@38: -- set up the countdown timer arkanes@4: -- TODO: Fancy enable/disable based on whether you have any timed buffs. arkanes@4: -- Not a big deal, how often do you care about that arkanes@8: -- also TODO: Maybe should bucket OnUpdates somehow arkanes@18: -- AceTimer repeating events can only happen at 0.1 seconds, which is probably arkanes@18: -- fast enough for updating, but makes the animation look jerky arkanes@27: -- need to experiment with using animation groups arkanes@18: self.update = CreateFrame("FRAME") arkanes@18: self.update:SetScript("OnUpdate", function() self:OnUpdate() end) arkanes@7: self.dirty = true -- force an immediate scan on login arkanes@14: self:HideBlizzardBuffFrames() arkanes@0: end arkanes@1: -- naming convention arkanes@17: -- a "frame" is the top-level button (secure button from the header, or one I make myself) arkanes@17: -- that will contain the UI information about the buff arkanes@17: -- a "bar" is a frame that has the icon, status bar, ect associated with it arkanes@0: arkanes@20: -- Secure aura header doesn't self-bind to vehicle, arkanes@27: -- so this only works out of combat. But thats better than nothing... arkanes@27: function kbf:PollForVehicleChange(event, unit) arkanes@20: if unit ~= "player" then return end arkanes@20: self.dirty = true arkanes@51: local function performSwap() arkanes@51: if UnitHasVehicleUI("player") then arkanes@51: -- only swap if we're in a "real" vehicle with its own actions arkanes@51: -- There is possibly a timing issue here where arkanes@51: -- we have set the poll flag but the unit is not arkanes@51: -- actually "in" the vehicle yet. I'm hoping thats arkanes@51: -- handled by using exited/entered events instead of exiting/entering arkanes@51: self.secureHeader:SetAttribute("unit", "vehicle") arkanes@51: else arkanes@51: self.secureHeader:SetAttribute("unit", "player") arkanes@51: end arkanes@51: end arkanes@51: self:QueueForOOC(performSwap) arkanes@20: end arkanes@20: arkanes@8: function kbf:HideBlizzardBuffFrames() arkanes@8: local function HideBlizFrame(frame) arkanes@8: if not frame then return end arkanes@8: frame:UnregisterAllEvents() arkanes@8: frame:SetScript("OnUpdate", nil) arkanes@8: frame:Hide() arkanes@8: frame.Show = function() end arkanes@8: end arkanes@8: HideBlizFrame(BuffFrame) arkanes@8: HideBlizFrame(ConsolidatedBuffs) arkanes@18: HideBlizFrame(TemporaryEnchantFrame) arkanes@8: arkanes@8: end arkanes@8: arkanes@45: -- enqueues a callable that will be run once in-combat lockdown is past arkanes@45: -- all callables will be executed in a single run, in the order they were enqueued arkanes@45: -- if called when OOC, the function will be called immediately, unless the alwaysQueue parameter is true, arkanes@45: -- in which case it will be appended normally arkanes@45: function kbf:QueueForOOC(func, alwaysQueue) arkanes@46: if InCombatLockdown() or alwaysQueue then arkanes@45: tinsert(self.oocQueue, func) arkanes@45: else arkanes@45: func() arkanes@45: end arkanes@45: end arkanes@45: arkanes@51: function kbf:OnUpdate() arkanes@49: -- TODO: only start this polling when we leave combat? arkanes@49: while #self.oocQueue > 0 and not InCombatLockdown() do arkanes@51: local func = table.remove(self.oocQueue) arkanes@45: func() arkanes@45: end arkanes@45: arkanes@38: local unit = self.secureHeader:GetAttribute("unit") arkanes@10: local buffCount = 0 arkanes@4: for idx=1,99 do arkanes@38: local frame = self.secureHeader:GetAttribute("child"..idx) arkanes@10: if not (frame and frame:IsShown()) then break end arkanes@65: local boundIndex = frame:GetAttribute("index") arkanes@65: if not boundIndex then arkanes@65: break arkanes@65: end arkanes@65: local hasbuff = UnitAura(unit, boundIndex) arkanes@65: --self:Print(hasbuff, idx, boundIndex) arkanes@65: if not hasbuff then arkanes@65: if frame.icon then frame.icon:Hide() end arkanes@65: if frame.statusbar then frame.statusbar:Hide() end arkanes@65: if frame.statusbarbg then frame.statusbarbg:Hide() end arkanes@65: if frame.text then frame.text:Hide() end arkanes@65: if frame.timertext then frame.timertext:Hide() end arkanes@65: break arkanes@65: end arkanes@10: buffCount = buffCount + 1 arkanes@65: arkanes@6: if self.dirty then arkanes@10: if self:BindBarToBuff(frame, unit) then break end arkanes@9: end arkanes@65: frame.icon:Show() arkanes@65: frame.statusbar:Show() arkanes@65: frame.statusbarbg:Show() arkanes@65: frame.text:Show() arkanes@65: frame.timertext:Show() arkanes@10: self:UpdateBarExpirationTime(frame) arkanes@12: -- Don't forget to refresh shown tooltips arkanes@45: if (GameTooltip:IsOwned(frame)) then arkanes@15: self:OnEnter(frame) arkanes@12: end arkanes@10: end arkanes@37: -- consolidated buffs arkanes@37: if self.consolidateProxy:IsShown() then arkanes@37: for idx=1,99 do arkanes@37: local frame = self.consolidateHeader:GetAttribute("child"..idx) arkanes@37: if not (frame and frame:IsShown()) then break end arkanes@37: if self.dirty then arkanes@37: if self:BindBarToBuff(frame, unit) then break end arkanes@37: end arkanes@37: self:UpdateBarExpirationTime(frame) arkanes@37: -- Don't forget to refresh shown tooltips arkanes@37: if ( GameTooltip:IsOwned(frame) ) then arkanes@37: self:OnEnter(frame) arkanes@37: end arkanes@37: end arkanes@41: buffCount = buffCount+1 arkanes@37: end arkanes@64: -- SAH correctly binds the weapon enchant templates now, but when temp enchants arkanes@64: -- are present and used, it seems that it doesn't correctly hide un-bound arkanes@64: -- buff frames, which breaks all the layout and so forth. arkanes@64: for weapon=3,1,-1 do arkanes@64: local tempEnchant = self.secureHeader:GetAttribute("tempEnchant"..weapon) arkanes@64: if tempEnchant and tempEnchant:IsShown() then arkanes@64: self:BindBarToWeaponEnchant(tempEnchant) arkanes@64: self:UpdateBarExpirationTime(tempEnchant) arkanes@64: buffCount = buffCount + 1 arkanes@64: end arkanes@64: end arkanes@37: arkanes@64: -- debuffs arkanes@64: -- Since debuffs aren't cancellable, don't need to use the secure header arkanes@64: -- for them. This could be rewritten to support useful features like arkanes@64: -- sorting & scaling and stuff. Honestly, should at least be alphabetical. arkanes@10: for idx=1,99 do arkanes@10: local frame = self.debuffFrames[idx] arkanes@10: if self.dirty then arkanes@10: local name, rank, icon, stacks, debuffType, duration, expirationTime = UnitAura(unit, idx, "HARMFUL") arkanes@10: if not name then arkanes@10: -- out of debuffs, hide all the rest of them arkanes@10: for jdx = idx, 99 do arkanes@10: local bar = self.debuffFrames[jdx] arkanes@10: if bar then bar:Hide() else break end arkanes@10: end arkanes@10: break arkanes@10: end arkanes@10: if not frame then arkanes@10: frame = self:ConstructBar(nil, 1, 0, 0) arkanes@10: self.debuffFrames[idx] = frame arkanes@10: end arkanes@10: self:SetBarAppearance(frame, name, icon, stacks, duration, expirationTime) arkanes@10: frame:ClearAllPoints() arkanes@10: -- position it under all the buffs, with a half-bar spacing arkanes@41: frame:SetPoint("TOP", self.secureHeader, "TOP", 0, (buffCount * -16) - 8) arkanes@10: frame:Show() arkanes@13: frame.filter = "HARMFUL" arkanes@13: frame.unit = unit arkanes@16: frame.index = idx arkanes@13: frame:SetScript("OnEnter", function() kbf:OnEnter(frame) end) arkanes@13: frame:SetScript("OnLeave", function() GameTooltip:Hide() end) arkanes@23: frame:EnableMouse(true) arkanes@10: buffCount = buffCount + 1 arkanes@10: else arkanes@10: -- not dirty, so no frame means we're done arkanes@10: if not frame then break end arkanes@6: end arkanes@10: self:UpdateBarExpirationTime(frame) arkanes@13: if ( GameTooltip:IsOwned(frame) ) then arkanes@15: self:OnEnter(frame) arkanes@13: end arkanes@4: end arkanes@6: self.dirty = nil arkanes@4: end arkanes@4: arkanes@0: function kbf:UNIT_AURA(event, unit) arkanes@38: if unit ~= self.secureHeader:GetAttribute("unit") then return end arkanes@6: self.dirty = true arkanes@0: end arkanes@0: arkanes@10: function kbf:UpdateBarExpirationTime(frame) arkanes@10: if frame.expirationTime then arkanes@10: local remaining = frame.expirationTime - GetTime() arkanes@10: remaining = math.max(0, remaining) arkanes@10: local perc = remaining / frame.duration arkanes@10: frame.timertext:SetText(self:FormatTimeText(remaining)) arkanes@10: frame.statusbar:SetValue(remaining) arkanes@10: end arkanes@10: end arkanes@10: arkanes@42: local gratt = LibStub:GetLibrary("LibGratuity-3.0") arkanes@42: arkanes@17: function kbf:BindBarToWeaponEnchant(parentFrame, slotOverride) arkanes@17: -- allow passing of explicit slot in order to work around aura header bug arkanes@17: local slot = slotOverride or parentFrame:GetAttribute("target-slot") arkanes@17: local itemIndex = slot - 15 -- 1MH, 2OF arkanes@17: local RETURNS_PER_ITEM = 3 arkanes@17: local hasEnchant, remaining, enchantCharges = select(RETURNS_PER_ITEM * (itemIndex - 1) + 1, GetWeaponEnchantInfo()) arkanes@17: -- remaining time is in milliseconds arkanes@26: if not hasEnchant then return end -- this should never happen arkanes@17: local remaining = remaining / 1000 arkanes@42: arkanes@17: local icon = GetInventoryItemTexture("player", slot) arkanes@42: local maxDuration arkanes@42: if select(2, UnitClass("player")) == "ROGUE" then arkanes@42: -- Rogues are probably using poisons, which are an hour arkanes@42: maxDuration = 60 * 60 arkanes@42: else arkanes@42: -- everyone else is probably using something thats a half hour arkanes@42: maxDuration = 30 * 60 arkanes@42: end arkanes@42: local duration = max(maxDuration, remaining) arkanes@17: local expirationTime = GetTime() + remaining arkanes@17: local name = GetItemInfo(GetInventoryItemID("player", slot)) arkanes@42: -- try to figure out what the weapon enchant is arkanes@42: -- tooltip string -> {spellid, duration} arkanes@42: local knownEnchants = { arkanes@42: ["Flametongue"] = {8024, 30*60}, arkanes@42: ["Frostbrand"] = {8033, 30*60}, arkanes@51: ["Earthliving"] = {51730, 30*60}, arkanes@61: ["Windfury"] = {8232, 30*60}, arkanes@44: ["Instant Poison"] = {8680, 60*60}, arkanes@44: ["Wound Poison"] = {13218, 60*60}, arkanes@44: ["Deadly Poison"] = {2823, 60*60}, arkanes@42: arkanes@42: } arkanes@42: local spellId = nil arkanes@42: if gratt then arkanes@42: gratt:SetInventoryItem("player", slot) arkanes@42: for tag, info in pairs(knownEnchants) do arkanes@42: if gratt:Find(tag) then arkanes@42: spellId, duration = unpack(info) arkanes@42: name, _, _ = GetSpellInfo(spellId) arkanes@47: local slots = {[16] = "Main Hand", [17] = "Off Hand", [18] = "Thrown"} arkanes@62: name = tag .. " (" .. slots[slot] .. ")" arkanes@42: break arkanes@42: end arkanes@42: end arkanes@42: end arkanes@42: parentFrame.spellId = spellId arkanes@17: if not parentFrame.icon then arkanes@17: self:ConstructBar(parentFrame, 1, 0, 1) arkanes@17: end arkanes@17: self:SetBarAppearance(parentFrame, name, icon, enchantCharges, duration, expirationTime) arkanes@17: end arkanes@17: arkanes@3: function kbf:BindBarToBuff(parentFrame, unit) arkanes@3: local index = parentFrame:GetAttribute("index") arkanes@3: local filter = parentFrame:GetAttribute("filter") arkanes@10: local name, rank, icon, stacks, debuffType, duration, expirationTime, arkanes@3: unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(unit, index, filter) arkanes@10: if not name then return end arkanes@2: if not parentFrame.icon then arkanes@2: self:ConstructBar(parentFrame) arkanes@0: end arkanes@10: self:SetBarAppearance(parentFrame, name, icon, stacks, duration, expirationTime) arkanes@10: end arkanes@10: arkanes@10: function kbf:SetBarAppearance(parentFrame, name, icon, stacks, duration, expirationTime) arkanes@2: parentFrame.icon:SetNormalTexture(icon) arkanes@0: if stacks and stacks > 0 then arkanes@2: parentFrame.text:SetText(string.format("%s(%d)", name, stacks)) arkanes@0: else arkanes@2: parentFrame.text:SetText(name) arkanes@0: end arkanes@4: parentFrame.timertext:SetText(self:FormatTimeText(duration)) arkanes@4: -- store duration information arkanes@6: if duration and duration > 0 then arkanes@4: parentFrame.expirationTime = expirationTime arkanes@4: parentFrame.duration = duration arkanes@4: parentFrame.statusbar:SetMinMaxValues(0, duration) arkanes@4: else arkanes@4: parentFrame.expirationTime = nil arkanes@4: parentFrame.duration = 0 arkanes@4: parentFrame.statusbar:SetMinMaxValues(0,1) arkanes@4: parentFrame.statusbar:SetValue(1) arkanes@4: end arkanes@4: end arkanes@4: arkanes@17: -- expects time seconds arkanes@4: function kbf:FormatTimeText(time) arkanes@4: if not time or time == 0 then return "" end arkanes@4: local timetext arkanes@4: local h = floor(time/3600) arkanes@4: local m = time - (h*3600) arkanes@4: m = floor(m/60) arkanes@4: local s = time - ((h*3600) + (m*60)) arkanes@4: if h > 0 then arkanes@4: timetext = ("%d:%02d"):format(h, m) arkanes@4: elseif m > 0 then arkanes@4: timetext = string.format("%d:%02d", m, floor(s)) arkanes@4: elseif s < 10 then arkanes@4: timetext = string.format("%1.1f", s) arkanes@4: else arkanes@4: timetext = string.format("%.0f", floor(s)) arkanes@4: end arkanes@4: return timetext arkanes@0: end arkanes@0: arkanes@12: function KBF:OnEnter(button, motion) arkanes@12: -- this is for the secure buttons, so use the attributes arkanes@26: local unit = SecureButton_GetModifiedUnit(button) or button.unit -- will perform vehicle toggle arkanes@21: local filter = button:GetAttribute("filter") or button.filter arkanes@15: local index = button:GetAttribute("index") or button.index arkanes@17: if unit and filter and index then arkanes@21: -- I'd like a better place to position this but it's funky for right now, handle it later arkanes@17: GameTooltip:SetOwner(button, "ANCHOR_BOTTOMLEFT"); arkanes@17: GameTooltip:SetFrameLevel(button:GetFrameLevel() + 2); arkanes@17: GameTooltip:SetUnitAura(unit, index, filter); arkanes@17: return arkanes@17: end arkanes@17: local slot = button:GetAttribute("target-slot") -- temp enchant arkanes@42: if slot then arkanes@42: GameTooltip:SetOwner(button, "ANCHOR_BOTTOMLEFT"); arkanes@42: GameTooltip:SetFrameLevel(button:GetFrameLevel() + 2); arkanes@42: if button.spellId then arkanes@42: -- TODO: This might be too big of a tooltip to care about that much. arkanes@42: -- Maybe I should just have a single line with the weapon name arkanes@42: --GameTooltip:SetInventoryItem(unit, slot) arkanes@42: local name = GetItemInfo(GetInventoryItemID("player", slot)) arkanes@42: local r, g, b = GetItemQualityColor(GetInventoryItemQuality("player", slot)) arkanes@42: GameTooltip:SetText(name, r, g, b) arkanes@62: local slots = {[16] = "Main Hand", [17] = "Off Hand", [18] = "Thrown"} arkanes@62: GameTooltip:AddLine(slots[slot]) arkanes@42: GameTooltip:AddLine(" ") arkanes@42: GameTooltip:AddSpellByID(button.spellId) arkanes@42: else arkanes@42: GameTooltip:SetInventoryItem(unit, slot) arkanes@42: end arkanes@42: end arkanes@12: end arkanes@12: arkanes@1: -- creates a icon + statusbar bar arkanes@10: function kbf:ConstructBar(frame, r, g, b) arkanes@0: local texture = "Interface\\TargetingFrame\\UI-StatusBar" arkanes@1: -- Because of secureframe suckiness, these height & width numbers arkanes@1: -- have to be consistent with the stuff in KBF.xml arkanes@54: local height = self.staticConfig.BAR_HEIGHT arkanes@54: local width = self.staticConfig.BAR_WIDTH -- this is the width *without* the icon arkanes@22: local font, _, style = GameFontHighlight:GetFont() arkanes@10: local r = r or 0 arkanes@10: local g = g or 1 arkanes@10: local b = b or 0 arkanes@10: local bgcolor = {r, g, b, 0.5} arkanes@10: local color = {r, g, b, 1} arkanes@0: local fontsize = 11 arkanes@0: local timertextwidth = fontsize * 3.6 arkanes@0: local textcolor = {1, 1, 1, 1} arkanes@0: local timertextcolor = {1, 1, 1, 1} arkanes@10: if not frame then arkanes@10: frame = CreateFrame("Button", nil, UIParent) -- the "top level" frame that represents the bar as a whole arkanes@54: frame:SetHeight(height) arkanes@54: frame:SetWidth(width + height) arkanes@10: end arkanes@1: local bar = frame arkanes@0: bar.icon = CreateFrame("Button", nil, bar) -- the icon arkanes@0: bar.statusbarbg = CreateFrame("StatusBar", nil, bar) -- the bars background arkanes@0: bar.statusbar = CreateFrame("StatusBar", nil, bar) -- and the bars foreground arkanes@0: bar.text = bar.statusbar:CreateFontString(nil, "OVERLAY") -- the label text arkanes@0: bar.timertext = bar.statusbar:CreateFontString(nil, "OVERLAY") -- and the timer text arkanes@0: arkanes@0: -- the icon arkanes@0: bar.icon:ClearAllPoints() arkanes@0: bar.icon:SetPoint("LEFT", bar, "LEFT", 0, 0) arkanes@0: -- icons are square arkanes@0: bar.icon:SetWidth(height) arkanes@0: bar.icon:SetHeight(height) arkanes@2: --bar.icon:EnableMouse(false) arkanes@0: -- the status bar background & foreground arkanes@0: local function setupStatusBar(sb, color) arkanes@0: sb:ClearAllPoints() arkanes@0: sb:SetHeight(height) arkanes@0: sb:SetWidth(width) arkanes@0: -- offset the height of the frame on the x-axis for the icon. arkanes@0: sb:SetPoint("TOPLEFT", bar, "TOPLEFT", height, 0) arkanes@0: sb:SetStatusBarTexture(texture) arkanes@0: sb:GetStatusBarTexture():SetVertTile(false) arkanes@0: sb:GetStatusBarTexture():SetHorizTile(false) arkanes@0: sb:SetStatusBarColor(unpack(color)) arkanes@0: sb:SetMinMaxValues(0,1) arkanes@0: sb:SetValue(1) arkanes@0: end arkanes@0: setupStatusBar(bar.statusbarbg, bgcolor) arkanes@0: setupStatusBar(bar.statusbar, color) arkanes@0: bar.statusbarbg:SetFrameLevel(bar.statusbarbg:GetFrameLevel()-1) -- make sure the bg frame stays in the back arkanes@0: -- timer text arkanes@0: bar.timertext:SetFontObject(GameFontHighlight) arkanes@0: bar.timertext:SetFont(GameFontHighlight:GetFont()) arkanes@0: bar.timertext:SetHeight(height) arkanes@0: bar.timertext:SetWidth(timertextwidth) arkanes@24: bar.timertext:SetPoint("LEFT", bar.statusbar, "LEFT", 2, 0) arkanes@24: bar.timertext:SetJustifyH("LEFT") arkanes@0: bar.timertext:SetText("time") arkanes@0: bar.timertext:SetTextColor(timertextcolor[1], timertextcolor[2], timertextcolor[3], timertextcolor[4]) arkanes@0: arkanes@0: -- and the label text arkanes@0: bar.text:SetFontObject(GameFontHighlight) arkanes@0: bar.text:SetFont(GameFontHighlight:GetFont()) arkanes@0: bar.text:SetHeight(height) arkanes@24: bar.text:SetPoint("LEFT", bar.timertext, "RIGHT", 0, 0) arkanes@0: bar.text:SetPoint("RIGHT", bar.statusbar, "RIGHT", 0, 0) arkanes@0: bar.text:SetJustifyH("LEFT") arkanes@0: bar.text:SetText("text") arkanes@0: bar.text:SetTextColor(textcolor[1], textcolor[2], textcolor[3], textcolor[4]) arkanes@0: return bar arkanes@0: end arkanes@0: arkanes@38: function kbf:CreateCoreFrames() arkanes@38: -- this is the visible anchor frame that the user interacts with arkanes@38: -- to move the buffs around arkanes@54: local height = self.staticConfig.BAR_HEIGHT arkanes@54: local width = self.staticConfig.BAR_WIDTH -- this is the width *without* the icon arkanes@0: local anchor = CreateFrame("FRAME", "KBFAnchorFrame", UIParent) arkanes@0: anchor:SetClampedToScreen(true) arkanes@0: anchor:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", arkanes@0: edgeFile = "Interface/Tooltips/UI-Tooltip-Border", arkanes@54: tile = true, tileSize = height, edgeSize = 12, arkanes@0: insets = { left = 4, right = 4, top = 4, bottom = 4 }, arkanes@0: }) arkanes@0: local text = anchor:CreateFontString(nil, "OVERLAY") -- the label text arkanes@0: text:SetFontObject(GameFontHighlight) arkanes@0: text:SetFont(GameFontHighlight:GetFont()) arkanes@0: text:SetPoint("TOPLEFT", anchor, "TOPLEFT", 0, 0) arkanes@0: text:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", 0, 0) arkanes@0: text:SetText("KBF ANCHOR") arkanes@54: anchor:SetWidth(height + width) arkanes@54: anchor:SetHeight(height) arkanes@0: -- movability arkanes@0: anchor:EnableMouse(true) arkanes@0: anchor:SetMovable(true) arkanes@0: anchor:RegisterForDrag("LeftButton") arkanes@0: anchor:SetScript("OnDragStart", anchor.StartMoving) arkanes@0: anchor:SetScript("OnDragStop", anchor.StopMovingOrSizing) arkanes@0: anchor:ClearAllPoints() arkanes@22: anchor:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0) arkanes@0: anchor:Hide() arkanes@38: -- this is the parent & host for the secure aura buttons. arkanes@0: arkanes@38: local secureHeader = CreateFrame("FRAME", "KBFBuffFrame", UIParent, "SecureAuraHeaderTemplate") arkanes@38: self:SetCommonSecureHeaderAttributes(secureHeader) arkanes@54: if self.db.profile.consolidateBuffs then arkanes@54: secureHeader:SetAttribute("consolidateTo", 99) arkanes@54: end arkanes@38: secureHeader:SetPoint("TOP", anchor, "TOP", 0, 0) arkanes@38: arkanes@38: -- this is the "button" in the aura flow that represents the consolidated buffs. arkanes@38: -- pre-creating it here in order to perform customization arkanes@40: local consolidateProxy = CreateFrame("BUTTON", nil, UIParent, "SecureHandlerClickTemplate") arkanes@39: consolidateProxy:SetNormalTexture("Interface\\TargetingFrame\\UI-StatusBar") arkanes@39: consolidateProxy:SetWidth(200 +16) arkanes@39: consolidateProxy:SetHeight(16) arkanes@38: secureHeader:SetAttribute("consolidateProxy", consolidateProxy) arkanes@40: --secureHeader:SetFrameRef("proxy", consolidateProxy) arkanes@40: arkanes@40: arkanes@38: -- this is the equivilent of the secureHeader for the consolidated buffs arkanes@38: -- pre-creating again, so we can customize/size/position it arkanes@38: local consolidateHeader = CreateFrame("FRAME", "KBFConsolidatedAnchorFrame", consolidateProxy) arkanes@38: self:SetCommonSecureHeaderAttributes(consolidateHeader) arkanes@38: secureHeader:SetAttribute("consolidateHeader", consolidateHeader) arkanes@39: consolidateProxy:SetAttribute("header", consolidateHeader); arkanes@40: consolidateProxy:SetFrameRef("header", consolidateHeader) arkanes@40: arkanes@40: consolidateProxy:SetAttribute("_onclick", [[ arkanes@40: local frame = self:GetFrameRef("header") arkanes@40: if frame:IsShown() then frame:Hide() else frame:Show() end arkanes@40: ]]) arkanes@40: consolidateProxy:EnableMouse(true) arkanes@40: consolidateProxy:RegisterForClicks("AnyUp") arkanes@39: arkanes@39: -- position it relative to the proxy, so it can appear where we want it arkanes@40: consolidateHeader:SetPoint("TOPRIGHT", anchor, "TOPLEFT", 0, 0) arkanes@54: consolidateHeader:SetWidth(height + width) arkanes@54: consolidateHeader:SetHeight(height) arkanes@38: consolidateHeader:Show() arkanes@39: arkanes@38: return anchor, secureHeader, consolidateHeader, consolidateProxy arkanes@37: end arkanes@37: arkanes@38: --- sets the attributes needed by all the headers arkanes@38: function kbf:SetCommonSecureHeaderAttributes(frame) arkanes@0: frame:SetAttribute("filter", "HELPFUL") arkanes@20: frame:SetAttribute("toggleForVehicle", true) -- this doesn't actually work right now, but maybe it eventually will arkanes@0: frame:SetAttribute("template", "KBFSecureUnitAuraTemplate") arkanes@3: frame:SetAttribute("point", "TOP") arkanes@2: frame:SetAttribute("xOffset", 0) arkanes@3: frame:SetAttribute("yOffset", -16) arkanes@3: frame:SetAttribute("minWidth", 216) arkanes@3: frame:SetAttribute("minHeight", 16) arkanes@25: frame:SetAttribute("unit", "player") arkanes@3: frame:SetAttribute("sortMethod", "NAME") arkanes@3: frame:SetAttribute("sortOrder", "-") arkanes@65: frame:SetAttribute("weaponTemplate", "KBFSecureWeaponEnchantTemplate") arkanes@65: -- TODO: 4.3 SAH has a bug that messes up buff binding when a consolidate proxy arkanes@65: -- and/or weapon enchants are present, don't use them. Set up a standalone enchant window to be managed arkanes@65: -- independently arkanes@64: frame:SetAttribute("includeWeapons", nil) arkanes@5: frame:Show() -- has to be shown, otherwise the child frames don't show arkanes@37: return frame arkanes@0: end arkanes@18: arkanes@18: function kbf:ShowAnchor() arkanes@38: self.secureHeader:ClearAllPoints() arkanes@38: self.secureHeader:SetPoint("TOP", self.anchor, "BOTTOM", 0, 0) arkanes@18: self.anchor:Show() arkanes@18: end arkanes@18: arkanes@18: function kbf:HideAnchor() arkanes@38: self.secureHeader:ClearAllPoints() arkanes@38: self.secureHeader:SetPoint("TOP", self.anchor, "TOP", 0, 0) arkanes@18: self.anchor:Hide() arkanes@18: end arkanes@18: arkanes@18: function kbf:ToggleAnchor() arkanes@18: if self.anchor:IsShown() then arkanes@18: self:HideAnchor() arkanes@18: else arkanes@18: self:ShowAnchor() arkanes@18: end arkanes@18: end arkanes@65: