changeset 41:15a0ceebbd83

Updates to weapon enchant handling - add a phantom frame for the third enchant, move them to the bottom
author Chris Mellon <arkanes@gmail.com>
date Sat, 15 Jan 2011 18:12:29 -0600
parents 5def7d061738
children d792f986400f
files KBF.lua
diffstat 1 files changed, 31 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/KBF.lua	Tue Jan 11 18:09:33 2011 -0600
+++ b/KBF.lua	Sat Jan 15 18:12:29 2011 -0600
@@ -93,7 +93,6 @@
     
     -- consolidated buffs
     if self.consolidateProxy:IsShown() then
-    	--self.consolidateHeader:Show() -- *** STATE DRIVEN
 		for idx=1,99 do
 			local frame = self.consolidateHeader:GetAttribute("child"..idx)
 			if not (frame and frame:IsShown()) then break end
@@ -106,24 +105,19 @@
 				self:OnEnter(frame)
 			end
 		end
-	else
-		--self.consolidateHeader:Hide() -- *** STATE DRIVEN
+		buffCount = buffCount+1
 	end
 	
     -- temporary enchants
     local tempEnchant = self.secureHeader:GetAttribute("tempEnchant1")
     if tempEnchant and tempEnchant:IsShown() then
-        if self.dirty or true then
-            self:BindBarToWeaponEnchant(tempEnchant, 16)
-        end
+		self:BindBarToWeaponEnchant(tempEnchant, 16)
         self:UpdateBarExpirationTime(tempEnchant)
         buffCount = buffCount + 1
     end
     tempEnchant = self.secureHeader:GetAttribute("tempEnchant2")
     if tempEnchant and tempEnchant:IsShown() then
-        if self.dirty or true then
-            self:BindBarToWeaponEnchant(tempEnchant, 17)
-        end
+		self:BindBarToWeaponEnchant(tempEnchant, 17)
         self:UpdateBarExpirationTime(tempEnchant)
         buffCount = buffCount + 1
         -- SAH binds the offhand enchant to the main hand for removal purposes.
@@ -133,11 +127,31 @@
         	tempEnchant:SetAttribute('target-slot', 17)
        	end
     end
-    -- there's also a third temp enchant for thrown weapons, which the 
-    -- current SAH doesn't support at all.
-    -- Since I can't insert bars into the flow, can't support this
-    -- until I either go to multiple secure headers & figure out how to position them
-    -- or blizz fixes SAH
+    -- make a fake third buff bar. It can't be used to cancel the buff, but
+    -- at least you can see it.
+    
+    local thirdWeaponInfo = select(7, GetWeaponEnchantInfo())
+    if thirdWeaponInfo then
+		if not self.tempEnchant3 then
+			-- largely copy/pasted code from SAH to bind to third weapon
+			self.tempEnchant3 = CreateFrame("Button", nil, self.secureHeader);
+			self.tempEnchant3:SetWidth(200+16)
+			self.tempEnchant3:SetHeight(16)
+			self.tempEnchant3:Show()
+		end
+		self.tempEnchant3:Show()
+    end
+    if self.tempEnchant3 and not thirdWeaponInfo then
+		self.tempEnchant3:Hide()
+	end
+    tempEnchant = self.tempEnchant3
+    if tempEnchant and tempEnchant:IsShown() then
+		self.tempEnchant3:ClearAllPoints()
+    	self.tempEnchant3:SetPoint("TOP", self.secureHeader, "TOP", 0, (buffCount * -16))
+		self:BindBarToWeaponEnchant(tempEnchant, 18)
+        self:UpdateBarExpirationTime(tempEnchant)
+        buffCount = buffCount + 1
+    end
     
     -- debuffs
     -- Since debuffs aren't cancellable, don't need to use the secure header
@@ -162,7 +176,7 @@
             self:SetBarAppearance(frame, name, icon, stacks, duration, expirationTime)
             frame:ClearAllPoints()
             -- position it under all the buffs, with a half-bar spacing
-            frame:SetPoint("TOP", self.anchor, "BOTTOM", 0, (buffCount * -16))
+            frame:SetPoint("TOP", self.secureHeader, "TOP", 0, (buffCount * -16) - 8)
             frame:Show()
             frame.filter = "HARMFUL"
             frame.unit = unit
@@ -199,7 +213,6 @@
 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
@@ -450,9 +463,9 @@
     frame:SetAttribute("unit", "player")
     frame:SetAttribute("sortMethod", "NAME")
     frame:SetAttribute("sortOrder", "-")
-    -- TODO: SecureAuraHeader doesn't correcltly implement the temp enchants
+    -- TODO: SecureAuraHeader doesn't correctly implement the temp enchants
     frame:SetAttribute("weaponTemplate", "KBFSecureUnitAuraTemplate")
-    frame:SetAttribute("includeWeapons", 1)
+    frame:SetAttribute("includeWeapons", 100)
     frame:Show() -- has to be shown, otherwise the child frames don't show
     return frame
 end