Mercurial > wow > kbf
comparison KBF.lua @ 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 |
comparison
equal
deleted
inserted
replaced
40:5def7d061738 | 41:15a0ceebbd83 |
---|---|
91 end | 91 end |
92 end | 92 end |
93 | 93 |
94 -- consolidated buffs | 94 -- consolidated buffs |
95 if self.consolidateProxy:IsShown() then | 95 if self.consolidateProxy:IsShown() then |
96 --self.consolidateHeader:Show() -- *** STATE DRIVEN | |
97 for idx=1,99 do | 96 for idx=1,99 do |
98 local frame = self.consolidateHeader:GetAttribute("child"..idx) | 97 local frame = self.consolidateHeader:GetAttribute("child"..idx) |
99 if not (frame and frame:IsShown()) then break end | 98 if not (frame and frame:IsShown()) then break end |
100 if self.dirty then | 99 if self.dirty then |
101 if self:BindBarToBuff(frame, unit) then break end | 100 if self:BindBarToBuff(frame, unit) then break end |
104 -- Don't forget to refresh shown tooltips | 103 -- Don't forget to refresh shown tooltips |
105 if ( GameTooltip:IsOwned(frame) ) then | 104 if ( GameTooltip:IsOwned(frame) ) then |
106 self:OnEnter(frame) | 105 self:OnEnter(frame) |
107 end | 106 end |
108 end | 107 end |
109 else | 108 buffCount = buffCount+1 |
110 --self.consolidateHeader:Hide() -- *** STATE DRIVEN | |
111 end | 109 end |
112 | 110 |
113 -- temporary enchants | 111 -- temporary enchants |
114 local tempEnchant = self.secureHeader:GetAttribute("tempEnchant1") | 112 local tempEnchant = self.secureHeader:GetAttribute("tempEnchant1") |
115 if tempEnchant and tempEnchant:IsShown() then | 113 if tempEnchant and tempEnchant:IsShown() then |
116 if self.dirty or true then | 114 self:BindBarToWeaponEnchant(tempEnchant, 16) |
117 self:BindBarToWeaponEnchant(tempEnchant, 16) | |
118 end | |
119 self:UpdateBarExpirationTime(tempEnchant) | 115 self:UpdateBarExpirationTime(tempEnchant) |
120 buffCount = buffCount + 1 | 116 buffCount = buffCount + 1 |
121 end | 117 end |
122 tempEnchant = self.secureHeader:GetAttribute("tempEnchant2") | 118 tempEnchant = self.secureHeader:GetAttribute("tempEnchant2") |
123 if tempEnchant and tempEnchant:IsShown() then | 119 if tempEnchant and tempEnchant:IsShown() then |
124 if self.dirty or true then | 120 self:BindBarToWeaponEnchant(tempEnchant, 17) |
125 self:BindBarToWeaponEnchant(tempEnchant, 17) | |
126 end | |
127 self:UpdateBarExpirationTime(tempEnchant) | 121 self:UpdateBarExpirationTime(tempEnchant) |
128 buffCount = buffCount + 1 | 122 buffCount = buffCount + 1 |
129 -- SAH binds the offhand enchant to the main hand for removal purposes. | 123 -- SAH binds the offhand enchant to the main hand for removal purposes. |
130 -- fix it up if we're out of combat | 124 -- fix it up if we're out of combat |
131 -- TODO: maybe this should only happen if we're dirty | 125 -- TODO: maybe this should only happen if we're dirty |
132 if not InCombatLockdown() then | 126 if not InCombatLockdown() then |
133 tempEnchant:SetAttribute('target-slot', 17) | 127 tempEnchant:SetAttribute('target-slot', 17) |
134 end | 128 end |
135 end | 129 end |
136 -- there's also a third temp enchant for thrown weapons, which the | 130 -- make a fake third buff bar. It can't be used to cancel the buff, but |
137 -- current SAH doesn't support at all. | 131 -- at least you can see it. |
138 -- Since I can't insert bars into the flow, can't support this | 132 |
139 -- until I either go to multiple secure headers & figure out how to position them | 133 local thirdWeaponInfo = select(7, GetWeaponEnchantInfo()) |
140 -- or blizz fixes SAH | 134 if thirdWeaponInfo then |
135 if not self.tempEnchant3 then | |
136 -- largely copy/pasted code from SAH to bind to third weapon | |
137 self.tempEnchant3 = CreateFrame("Button", nil, self.secureHeader); | |
138 self.tempEnchant3:SetWidth(200+16) | |
139 self.tempEnchant3:SetHeight(16) | |
140 self.tempEnchant3:Show() | |
141 end | |
142 self.tempEnchant3:Show() | |
143 end | |
144 if self.tempEnchant3 and not thirdWeaponInfo then | |
145 self.tempEnchant3:Hide() | |
146 end | |
147 tempEnchant = self.tempEnchant3 | |
148 if tempEnchant and tempEnchant:IsShown() then | |
149 self.tempEnchant3:ClearAllPoints() | |
150 self.tempEnchant3:SetPoint("TOP", self.secureHeader, "TOP", 0, (buffCount * -16)) | |
151 self:BindBarToWeaponEnchant(tempEnchant, 18) | |
152 self:UpdateBarExpirationTime(tempEnchant) | |
153 buffCount = buffCount + 1 | |
154 end | |
141 | 155 |
142 -- debuffs | 156 -- debuffs |
143 -- Since debuffs aren't cancellable, don't need to use the secure header | 157 -- Since debuffs aren't cancellable, don't need to use the secure header |
144 -- for them. This could be rewritten to support useful features like | 158 -- for them. This could be rewritten to support useful features like |
145 -- sorting & scaling and stuff. Honestly, should at least be alphabetical. | 159 -- sorting & scaling and stuff. Honestly, should at least be alphabetical. |
160 self.debuffFrames[idx] = frame | 174 self.debuffFrames[idx] = frame |
161 end | 175 end |
162 self:SetBarAppearance(frame, name, icon, stacks, duration, expirationTime) | 176 self:SetBarAppearance(frame, name, icon, stacks, duration, expirationTime) |
163 frame:ClearAllPoints() | 177 frame:ClearAllPoints() |
164 -- position it under all the buffs, with a half-bar spacing | 178 -- position it under all the buffs, with a half-bar spacing |
165 frame:SetPoint("TOP", self.anchor, "BOTTOM", 0, (buffCount * -16)) | 179 frame:SetPoint("TOP", self.secureHeader, "TOP", 0, (buffCount * -16) - 8) |
166 frame:Show() | 180 frame:Show() |
167 frame.filter = "HARMFUL" | 181 frame.filter = "HARMFUL" |
168 frame.unit = unit | 182 frame.unit = unit |
169 frame.index = idx | 183 frame.index = idx |
170 frame:SetScript("OnEnter", function() kbf:OnEnter(frame) end) | 184 frame:SetScript("OnEnter", function() kbf:OnEnter(frame) end) |
197 frame.statusbar:SetValue(remaining) | 211 frame.statusbar:SetValue(remaining) |
198 end | 212 end |
199 end | 213 end |
200 | 214 |
201 function kbf:BindBarToWeaponEnchant(parentFrame, slotOverride) | 215 function kbf:BindBarToWeaponEnchant(parentFrame, slotOverride) |
202 local index = parentFrame:GetAttribute("index") | |
203 -- allow passing of explicit slot in order to work around aura header bug | 216 -- allow passing of explicit slot in order to work around aura header bug |
204 local slot = slotOverride or parentFrame:GetAttribute("target-slot") | 217 local slot = slotOverride or parentFrame:GetAttribute("target-slot") |
205 local itemIndex = slot - 15 -- 1MH, 2OF | 218 local itemIndex = slot - 15 -- 1MH, 2OF |
206 local RETURNS_PER_ITEM = 3 | 219 local RETURNS_PER_ITEM = 3 |
207 local hasEnchant, remaining, enchantCharges = select(RETURNS_PER_ITEM * (itemIndex - 1) + 1, GetWeaponEnchantInfo()) | 220 local hasEnchant, remaining, enchantCharges = select(RETURNS_PER_ITEM * (itemIndex - 1) + 1, GetWeaponEnchantInfo()) |
448 frame:SetAttribute("minWidth", 216) | 461 frame:SetAttribute("minWidth", 216) |
449 frame:SetAttribute("minHeight", 16) | 462 frame:SetAttribute("minHeight", 16) |
450 frame:SetAttribute("unit", "player") | 463 frame:SetAttribute("unit", "player") |
451 frame:SetAttribute("sortMethod", "NAME") | 464 frame:SetAttribute("sortMethod", "NAME") |
452 frame:SetAttribute("sortOrder", "-") | 465 frame:SetAttribute("sortOrder", "-") |
453 -- TODO: SecureAuraHeader doesn't correcltly implement the temp enchants | 466 -- TODO: SecureAuraHeader doesn't correctly implement the temp enchants |
454 frame:SetAttribute("weaponTemplate", "KBFSecureUnitAuraTemplate") | 467 frame:SetAttribute("weaponTemplate", "KBFSecureUnitAuraTemplate") |
455 frame:SetAttribute("includeWeapons", 1) | 468 frame:SetAttribute("includeWeapons", 100) |
456 frame:Show() -- has to be shown, otherwise the child frames don't show | 469 frame:Show() -- has to be shown, otherwise the child frames don't show |
457 return frame | 470 return frame |
458 end | 471 end |
459 | 472 |
460 function kbf:ShowAnchor() | 473 function kbf:ShowAnchor() |