Skip to content

Commit

Permalink
Merge branch 'master' into classic
Browse files Browse the repository at this point in the history
  • Loading branch information
d87 committed Sep 6, 2019
2 parents 375ff9d + a098472 commit 10ff914
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions NugEnergy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local textoutline = false
local spenderFeedback = true
local doFadeOut = true
local fadeAfter = 5
local fadeTime = 1
local onlyText = false
local shouldBeFull = false
local isFull = true
Expand Down Expand Up @@ -52,6 +53,8 @@ local twStart
local twLength
local twCrossfade

local DruidRecentlyLeftCat = false
local DruidLeftCatTimeout = 0

local EPT = Enum.PowerType
local Enum_PowerType_Insanity = EPT.Insanity
Expand Down Expand Up @@ -318,9 +321,18 @@ function NugEnergy.Initialize(self)
self.UNIT_DISPLAYPOWER = function(self)
local newPowerType = select(2,UnitPowerType("player"))
shouldBeFull = false

if newPowerType == "MANA" then
if PowerFilter == "ENERGY" and not DruidRecentlyLeftCat then
DruidRecentlyLeftCat = true
DruidLeftCatTimeout = fadeAfter + fadeTime + 1
end
else
DruidRecentlyLeftCat = false
end
-- restore to original MAXPOWER in case it was switched for classic energy
NugEnergy.UNIT_MAXPOWER = NugEnergy.__UNIT_MAXPOWER
if (newPowerType == "ENERGY" or GetShapeshiftForm() == 0) and NugEnergyDB.energy then
if (newPowerType == "ENERGY" or DruidRecentlyLeftCat) and NugEnergyDB.energy then
PowerFilter = "ENERGY"
PowerTypeIndex = Enum.PowerType.Energy
shouldBeFull = true
Expand Down Expand Up @@ -403,14 +415,24 @@ function NugEnergy.UNIT_POWER_UPDATE(self,event,unit,powertype)
if powertype == PowerFilter then self:UpdateEnergy() end
end
NugEnergy.UNIT_POWER_FREQUENT = NugEnergy.UNIT_POWER_UPDATE
function NugEnergy.UpdateEnergy(self)
function NugEnergy.UpdateEnergy(self, elapsed)
local p, p2, execute, shine, capped, insufficient = GetPower("player")
local wasFull = isFull
isFull = p == GetPowerMax("player", PowerTypeIndex)
if isFull ~= wasFull then
NugEnergy:UPDATE_STEALTH(nil, true)
end

if DruidLeftCatTimeout > 0 and elapsed then
DruidLeftCatTimeout = DruidLeftCatTimeout - elapsed
if DruidLeftCatTimeout <= 0 then
DruidRecentlyLeftCat = false
PowerFilter = nil
self:UNIT_DISPLAYPOWER()
end

end

p2 = p2 or p
self.text:SetText(p2)
if not onlyText then
Expand Down Expand Up @@ -507,7 +529,6 @@ function NugEnergy.UNIT_MAXPOWER(self)
end
NugEnergy.__UNIT_MAXPOWER = NugEnergy.UNIT_MAXPOWER

local fadeTime = 1
local fader = CreateFrame("Frame", nil, NugEnergy)
NugEnergy.fader = fader
local HideTimer = function(self, time)
Expand Down Expand Up @@ -549,7 +570,7 @@ end

function NugEnergy.UPDATE_STEALTH(self, event, fromUpdateEnergy)
local inCombat = UnitAffectingCombat("player")
local isShiftedToHumanFormInClassic = (isClassic and class=="DRUID" and GetShapeshiftForm() == 0)
local isShiftedToHumanFormInClassic = (isClassic and DruidRecentlyLeftCat)
if ((inCombat and not isShiftedToHumanFormInClassic) or
((class == "ROGUE" or class == "DRUID") and IsStealthed() and (isClassic or (shouldBeFull and not isFull))) or
ForcedToShow)
Expand Down

0 comments on commit 10ff914

Please sign in to comment.