Skip to content

Commit

Permalink
power: account for a possible non-zero altpower min value
Browse files Browse the repository at this point in the history
  • Loading branch information
Rainrider authored and haste committed Oct 14, 2014
1 parent 26202c5 commit 509c0ea
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions elements/power.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ oUF.colors.power[8] = oUF.colors.power["ECLIPSE"]
oUF.colors.power[9] = oUF.colors.power["HOLY_POWER"]

local GetDisplayPower = function(unit)
local _, _, _, _, _, _, showOnRaid = UnitAlternatePowerInfo(unit)
local _, min, _, _, _, _, showOnRaid = UnitAlternatePowerInfo(unit)
if(showOnRaid) then
return ALTERNATE_POWER_INDEX
return ALTERNATE_POWER_INDEX, min
end
end

Expand All @@ -129,10 +129,13 @@ local Update = function(self, event, unit)

if(power.PreUpdate) then power:PreUpdate(unit) end

local displayType = power.displayAltPower and GetDisplayPower(unit)
local displayType, min
if power.displayAltPower then
displayType, min = GetDisplayPower(unit)
end
local cur, max = UnitPower(unit, displayType), UnitPowerMax(unit, displayType)
local disconnected = not UnitIsConnected(unit)
power:SetMinMaxValues(0, max)
power:SetMinMaxValues(min or 0, max)

if(disconnected) then
power:SetValue(max)
Expand Down Expand Up @@ -172,7 +175,8 @@ local Update = function(self, event, unit)
elseif(power.colorReaction and UnitReaction(unit, 'player')) then
t = self.colors.reaction[UnitReaction(unit, "player")]
elseif(power.colorSmooth) then
r, g, b = self.ColorGradient(cur, max, unpack(power.smoothGradient or self.colors.smooth))
local adjust = 0 - (min or 0)
r, g, b = self.ColorGradient(cur + adjust, max + adjust, unpack(power.smoothGradient or self.colors.smooth))
end

if(t) then
Expand All @@ -190,7 +194,7 @@ local Update = function(self, event, unit)
end

if(power.PostUpdate) then
return power:PostUpdate(unit, cur, max)
return power:PostUpdate(unit, cur, max, min)
end
end

Expand Down

0 comments on commit 509c0ea

Please sign in to comment.