Mercurial > wow > kbf
changeset 17:233745d4774b
basic, buggy, temp weapon enchant support. Secure headers are totally screwed with these
author | Chris Mellon <arkanes@gmai.com> |
---|---|
date | Fri, 15 Oct 2010 21:41:55 -0500 |
parents | 87131aeedc3f |
children | 27aa0d9ffe43 |
files | KBF.lua |
diffstat | 1 files changed, 54 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/KBF.lua Wed Oct 13 12:29:17 2010 -0500 +++ b/KBF.lua Fri Oct 15 21:41:55 2010 -0500 @@ -19,8 +19,10 @@ self:HideBlizzardBuffFrames() end -- naming convention --- "frame" is the secure aura button created by the group handler --- "bar" is the set of icon + status bars that we create to show the buff time +-- a "frame" is the top-level button (secure button from the header, or one I make myself) +-- that will contain the UI information about the buff + +-- a "bar" is a frame that has the icon, status bar, ect associated with it function kbf:HideBlizzardBuffFrames() local function HideBlizFrame(frame) @@ -56,6 +58,20 @@ -- TODO: The blizz secure aura header binds both temp enchants -- to the main hand. No support for cancelling weapon enchants -- until this gets fixed up + local tempEnchant = self.secureFrame:GetAttribute("tempEnchant1") + if tempEnchant and tempEnchant:IsShown() then + if self.dirty or true then + self:BindBarToWeaponEnchant(tempEnchant, 16) + end + self:UpdateBarExpirationTime(tempEnchant) + end + tempEnchant = self.secureFrame:GetAttribute("tempEnchant2") + if tempEnchant and tempEnchant:IsShown() then + if self.dirty or true then + self:BindBarToWeaponEnchant(tempEnchant, 17) + end + self:UpdateBarExpirationTime(tempEnchant) + end -- debuffs -- Since debuffs aren't cancellable, don't need to use the secure header @@ -115,6 +131,31 @@ end end +function kbf:BindBarToWeaponEnchant(parentFrame, slotOverride) + local index = parentFrame:GetAttribute("index") + -- allow passing of explicit slot in order to work around aura header bug + local slot = slotOverride or parentFrame:GetAttribute("target-slot") + local itemIndex = slot - 15 -- 1MH, 2OF + local RETURNS_PER_ITEM = 3 + local hasEnchant, remaining, enchantCharges = select(RETURNS_PER_ITEM * (itemIndex - 1) + 1, GetWeaponEnchantInfo()) + -- remaining time is in milliseconds + if not hasEnchant then return end + local remaining = remaining / 1000 + if not hasEnchant then return end -- this should never happen + local icon = GetInventoryItemTexture("player", slot) + -- this is terrible, but I hate myself and everyone else. + -- We're going to assume that the duration of the temp enchant + -- is either 60 minutes, or however long is left, because poisons are 1 hour + local duration = max((60 * 60), remaining) + local expirationTime = GetTime() + remaining + -- TODO + local name = GetItemInfo(GetInventoryItemID("player", slot)) + if not parentFrame.icon then + self:ConstructBar(parentFrame, 1, 0, 1) + end + self:SetBarAppearance(parentFrame, name, icon, enchantCharges, duration, expirationTime) +end + function kbf:BindBarToBuff(parentFrame, unit) local index = parentFrame:GetAttribute("index") local filter = parentFrame:GetAttribute("filter") @@ -148,6 +189,7 @@ end end +-- expects time seconds function kbf:FormatTimeText(time) if not time or time == 0 then return "" end local timetext @@ -173,9 +215,16 @@ local unit = button.unit or button:GetAttribute("unit") local filter = button.filter or button:GetAttribute("filter") local index = button:GetAttribute("index") or button.index + if unit and filter and index then + GameTooltip:SetOwner(button, "ANCHOR_BOTTOMLEFT"); + GameTooltip:SetFrameLevel(button:GetFrameLevel() + 2); + GameTooltip:SetUnitAura(unit, index, filter); + return + end + local slot = button:GetAttribute("target-slot") -- temp enchant GameTooltip:SetOwner(button, "ANCHOR_BOTTOMLEFT"); GameTooltip:SetFrameLevel(button:GetFrameLevel() + 2); - GameTooltip:SetUnitAura(unit, index, filter); + GameTooltip:SetInventoryItem("player", slot) end -- creates a icon + statusbar bar @@ -297,8 +346,8 @@ frame:SetAttribute("sortMethod", "NAME") frame:SetAttribute("sortOrder", "-") -- TODO: SecureAuraHeader doesn't correcltly implement the temp enchants - --frame:SetAttribute("weaponTemplate", "KBFSecureUnitAuraTemplate") - --frame:SetAttribute("includeWeapons", 1) + frame:SetAttribute("weaponTemplate", "KBFSecureUnitAuraTemplate") + frame:SetAttribute("includeWeapons", 1) frame:SetPoint("TOP", anchor, "BOTTOM", 0, 0) frame:Show() -- has to be shown, otherwise the child frames don't show self.secureFrame = frame