From 5474530f8f17d98f330a0941847d9bc0bb007046 Mon Sep 17 00:00:00 2001 From: Parnic Date: Sun, 24 Aug 2008 03:20:43 +0000 Subject: [PATCH] - updated SunderCount/LacerateCount modules to use the new UnitDebuff return values in wotlk properly/register the changed wotlk events - updated SliceAndDice module to be more efficient outside of combat (avoids unnecessary OnUpdate stuff) - updated SliceAndDice module to use the new UnitBuff return values in wotlk properly/register the changed wotlk events/new combo point parameters - updated DruidMana module to update every frame in wotlk since the other mana frames need to...this still needs dogtag to be updated to work fully in wotlk - updated ComboPoints module to use the new combo point functionality and events in wotlk --- modules/ComboPoints.lua | 13 +++++- modules/DruidMana.lua | 11 ++++- modules/LacerateCount.lua | 7 +++- modules/SliceAndDice.lua | 88 ++++++++++++++++++++++++++++++++------- modules/SunderCount.lua | 7 +++- 5 files changed, 105 insertions(+), 21 deletions(-) diff --git a/modules/ComboPoints.lua b/modules/ComboPoints.lua index 4ab7af3..354ef62 100644 --- a/modules/ComboPoints.lua +++ b/modules/ComboPoints.lua @@ -126,7 +126,11 @@ function ComboPoints.prototype:Enable(core) ComboPoints.super.prototype.Enable(self, core) self:RegisterEvent("PLAYER_TARGET_CHANGED", "UpdateComboPoints") - self:RegisterEvent("PLAYER_COMBO_POINTS", "UpdateComboPoints") + if IceHUD.WowVer >= 30000 then + self:RegisterEvent("UNIT_COMBO_POINTS", "UpdateComboPoints") + else + self:RegisterEvent("PLAYER_COMBO_POINTS", "UpdateComboPoints") + end end @@ -204,7 +208,12 @@ end function ComboPoints.prototype:UpdateComboPoints() - local points = GetComboPoints("target") + local points + if IceHUD.WowVer >= 30000 then + points = GetComboPoints("player", "target") + else + points = GetComboPoints("target") + end if (points == 0) then points = nil diff --git a/modules/DruidMana.lua b/modules/DruidMana.lua index cc78f46..a6a04ae 100644 --- a/modules/DruidMana.lua +++ b/modules/DruidMana.lua @@ -44,8 +44,17 @@ function DruidMana.prototype:Enable(core) if LibDruidMana then self:RegisterEvent("UPDATE_SHAPESHIFT_FORM", "Update") - self:RegisterEvent("UNIT_MANA", "Update") self:RegisterEvent("UNIT_MAXMANA", "Update") + + if IceHUD.WowVer >= 30000 then + if GetCVarBool("predictedPower") and self.frame then + self.frame:SetScript("OnUpdate", function() self:Update(self.unit) end) + else + self:RegisterEvent("UNIT_MANA", "Update") + end + else + self:RegisterEvent("UNIT_MANA", "Update") + end end end diff --git a/modules/LacerateCount.lua b/modules/LacerateCount.lua index 81467dd..6708e49 100644 --- a/modules/LacerateCount.lua +++ b/modules/LacerateCount.lua @@ -205,7 +205,12 @@ end function LacerateCount.prototype:GetDebuffCount(unit, ability, onlyMine) for i = 1, MAX_DEBUFF_COUNT do - local name, _, texture, applications, _, duration = UnitDebuff(unit, i) + local name, texture, applications, duration + if IceHUD.WowVer >= 30000 then + name, _, texture, applications, _, _, duration = UnitDebuff(unit, i) + else + name, _, texture, applications, _, duration = UnitDebuff(unit, i) + end if not texture then break diff --git a/modules/SliceAndDice.lua b/modules/SliceAndDice.lua index 1ba1877..0c683b2 100644 --- a/modules/SliceAndDice.lua +++ b/modules/SliceAndDice.lua @@ -13,6 +13,8 @@ local impSndTalentPage = 2 local impSndTalentIdx = 4 local impSndBonusPerRank = 0.15 local maxComboPoints = 5 +local sndEndTime = 0 +local sndDuration = 0 local CurrMaxSnDDuration = 0 local PotentialSnDDuration = 0 @@ -35,11 +37,14 @@ end function SliceAndDice.prototype:Enable(core) SliceAndDice.super.prototype.Enable(self, core) - self:RegisterEvent("PLAYER_AURAS_CHANGED", "UpdateSliceAndDice") self:RegisterEvent("PLAYER_TARGET_CHANGED", "UpdateDurationBar") - self:RegisterEvent("PLAYER_COMBO_POINTS", "UpdateDurationBar") - - self:ScheduleRepeatingEvent(self.elementName, self.UpdateSliceAndDice, 0.1, self) + if IceHUD.WowVer >= 30000 then + self:RegisterEvent("UNIT_AURA", "UpdateSliceAndDice") + self:RegisterEvent("UNIT_COMBO_POINTS", "UpdateDurationBar") + else + self:RegisterEvent("PLAYER_AURAS_CHANGED", "UpdateSliceAndDice") + self:RegisterEvent("PLAYER_COMBO_POINTS", "UpdateDurationBar") + end self:Show(false) @@ -159,47 +164,94 @@ end -- 'Protected' methods -------------------------------------------------------- -function _GetBuffDuration(unitName, buffName) +function SliceAndDice.prototype:GetBuffDuration(unitName, buffName) local i = 1 - local buff, rank, texture, count, duration, remaining = UnitBuff(unitName, i) + local buff, rank, texture, count, type, duration, endTime, remaining + if IceHUD.WowVer >= 30000 then + buff, rank, texture, count, type, duration, endTime = UnitBuff(unitName, i) + else + buff, rank, texture, count, duration, remaining = UnitBuff(unitName, i) + end while buff do if (texture and string.match(texture, buffName)) then + if endTime and not remaining then + remaining = endTime - GetTime() + end return duration, remaining end i = i + 1; - buff, rank, texture, count, duration, remaining = UnitBuff(unitName, i) + if IceHUD.WowVer >= 30000 then + buff, rank, texture, count, type, duration, endTime = UnitBuff(unitName, i) + else + buff, rank, texture, count, duration, remaining = UnitBuff(unitName, i) + end end return nil, nil end -function SliceAndDice.prototype:UpdateSliceAndDice() - local duration, remaining = _GetBuffDuration("player", "Ability_Rogue_SliceDice") +function SliceAndDice.prototype:UpdateSliceAndDice(unit, fromUpdate) + if unit and unit ~= self.unit then + return + end + + local now = GetTime() + local remaining = nil + + if not fromUpdate or IceHUD.WowVer < 30000 then + sndDuration, remaining = self:GetBuffDuration(self.unit, "Ability_Rogue_SliceDice") + + if not remaining then + sndEndTime = 0 + else + sndEndTime = remaining + now + end + end + + if sndEndTime and sndEndTime >= now then + if not fromUpdate then + self.frame:SetScript("OnUpdate", function() self:UpdateSliceAndDice(self.unit, true) end) + end - if duration ~= nil and remaining ~= nil then self:Show(true) - self:UpdateBar(remaining / (self.moduleSettings.showAsPercentOfMax and CurrMaxSnDDuration or duration), "SliceAndDice") + if not remaining then + remaining = sndEndTime - now + end + self:UpdateBar(remaining / (self.moduleSettings.showAsPercentOfMax and CurrMaxSnDDuration or sndDuration), "SliceAndDice") formatString = self.moduleSettings.upperText or '' else self:UpdateBar(0, "SliceAndDice") - if GetComboPoints("target") == 0 or not UnitExists("target") then - self:Show(false) + if ((IceHUD.WowVer >= 30000 and GetComboPoints(self.unit, "target") == 0) or (IceHUD.WowVer < 30000 and GetComboPoints("target") == 0)) or not UnitExists("target") then + if self.bIsVisible then + self.frame:SetScript("OnUpdate", nil) + end + + self:Show(false) end end -- somewhat redundant, but we also need to check potential remaining time - if (duration ~= nil and remaining ~= nil) or PotentialSnDDuration > 0 then + if (remaining ~= nil) or PotentialSnDDuration > 0 then self:SetBottomText1(self.moduleSettings.upperText .. tostring(floor(remaining or 0)) .. " (" .. PotentialSnDDuration .. ")") end end -function SliceAndDice.prototype:UpdateDurationBar() - local points = GetComboPoints("target") +function SliceAndDice.prototype:UpdateDurationBar(unit) + if unit and unit ~= self.unit then + return + end + + local points + if IceHUD.WowVer >= 30000 then + points = GetComboPoints(self.unit, "target") + else + points = GetComboPoints("target") + end local scale -- first, set the cached upper limit of SnD duration @@ -226,6 +278,10 @@ function SliceAndDice.prototype:UpdateDurationBar() else self.durationFrame.bar:SetTexCoord(0, 1, 1-scale, 1) end + + if sndEndTime < GetTime() then + self:SetBottomText1(self.moduleSettings.upperText .. "0 (" .. PotentialSnDDuration .. ")") + end end function SliceAndDice.prototype:GetMaxBuffTime(numComboPoints) diff --git a/modules/SunderCount.lua b/modules/SunderCount.lua index 27884f6..03d2ca8 100644 --- a/modules/SunderCount.lua +++ b/modules/SunderCount.lua @@ -205,7 +205,12 @@ end function SunderCount.prototype:GetDebuffCount(unit, ability, onlyMine) for i = 1, MAX_DEBUFF_COUNT do - local name, _, texture, applications, _, duration = UnitDebuff(unit, i) + local name, texture, applications, duration + if IceHUD.WowVer >= 30000 then + name, _, texture, applications, _, _, duration = UnitDebuff(unit, i) + else + name, _, texture, applications, _, duration = UnitDebuff(unit, i) + end if not texture then break