Updated ComboPointsBar for Legion

Also fixed a very minor leak in it where a table was being generated every call to Update when the player had > 0 combo points.
This commit is contained in:
Parnic
2016-05-29 00:17:08 -05:00
parent 2646481d11
commit 8fef3a2b8c

View File

@ -84,6 +84,8 @@ function ComboPointsBar.prototype:CreateFrame()
self:UpdateComboPoints() self:UpdateComboPoints()
end end
local color = {}
function ComboPointsBar.prototype:UpdateComboPoints(...) function ComboPointsBar.prototype:UpdateComboPoints(...)
if select('#', ...) >= 3 and select(1, ...) == "UNIT_POWER" and select(3, ...) ~= "COMBO_POINTS" then if select('#', ...) >= 3 and select(1, ...) == "UNIT_POWER" and select(3, ...) ~= "COMBO_POINTS" then
return return
@ -91,13 +93,13 @@ function ComboPointsBar.prototype:UpdateComboPoints(...)
local points local points
if IceHUD.IceCore:IsInConfigMode() then if IceHUD.IceCore:IsInConfigMode() then
points = 5 points = UnitPowerMax("player", SPELL_POWER_COMBO_POINTS)
elseif IceHUD.WowVer >= 30000 then elseif IceHUD.WowVer >= 30000 then
-- Parnic: apparently some fights have combo points while the player is in a vehicle? -- Parnic: apparently some fights have combo points while the player is in a vehicle?
local isInVehicle = UnitHasVehicleUI("player") local isInVehicle = UnitHasVehicleUI("player")
local checkUnit = isInVehicle and "vehicle" or "player" local checkUnit = isInVehicle and "vehicle" or "player"
if IceHUD.WowVer >= 60000 then if IceHUD.WowVer >= 60000 then
points = UnitPower(checkUnit, 4) points = UnitPower(checkUnit, SPELL_POWER_COMBO_POINTS)
else else
points = GetComboPoints(checkUnit, "target") points = GetComboPoints(checkUnit, "target")
end end
@ -114,9 +116,8 @@ function ComboPointsBar.prototype:UpdateComboPoints(...)
self:UpdateBar(0, "undef") self:UpdateBar(0, "undef")
else else
self:Show(true) self:Show(true)
local color = {}
self:SetScaledColor(color, (points - 1) / 4.0, self.settings.colors["ComboPointsBarMax"], self.settings.colors["ComboPointsBarMin"]) self:SetScaledColor(color, (points - 1) / 4.0, self.settings.colors["ComboPointsBarMax"], self.settings.colors["ComboPointsBarMin"])
self:UpdateBar(points / 5.0, "undef") self:UpdateBar(points / UnitPowerMax("player", SPELL_POWER_COMBO_POINTS), "undef")
self.barFrame.bar:SetVertexColor(color.r, color.g, color.b, self.alpha) self.barFrame.bar:SetVertexColor(color.r, color.g, color.b, self.alpha)
end end