mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 14:50:13 -05:00
- vehicle fixes! vehicles now regenerate mana/energy properly instead of relying on events to fire (which seem to be too slow)
- pet bar is now properly colored for all types of vehicles (was sometimes failing previously for vehicles with energy)
This commit is contained in:
@ -55,6 +55,7 @@ function PetMana.prototype:Enable(core)
|
||||
self:RegisterEvent("PLAYER_PET_CHANGED", "CheckPet");
|
||||
self:RegisterEvent("PET_BAR_CHANGED", "CheckPet");
|
||||
self:RegisterEvent("UNIT_PET", "CheckPet");
|
||||
self:RegisterEvent("UNIT_ENTERED_VEHICLE", "CheckPet")
|
||||
|
||||
self:RegisterEvent("UNIT_MANA", "Update")
|
||||
self:RegisterEvent("UNIT_MAXMANA", "Update")
|
||||
@ -73,8 +74,11 @@ end
|
||||
|
||||
|
||||
function PetMana.prototype:CheckPet()
|
||||
self:CheckForVehicle()
|
||||
|
||||
if (UnitExists(self.unit)) then
|
||||
self:Show(true)
|
||||
self:ManaType(self.unit)
|
||||
self:Update(self.unit)
|
||||
else
|
||||
self:Show(false)
|
||||
@ -92,8 +96,49 @@ function PetMana.prototype:ManaType(unit)
|
||||
end
|
||||
|
||||
|
||||
function PetMana.prototype:SetupOnUpdate(enable)
|
||||
if enable then
|
||||
self.frame:SetScript("OnUpdate", function() self:Update(self.unit) end)
|
||||
else
|
||||
-- make sure the animation has a chance to finish filling up the bar before we cut it off completely
|
||||
if self.CurrScale ~= self.DesiredScale then
|
||||
self.frame:SetScript("OnUpdate", function() self:MyOnUpdate() end)
|
||||
else
|
||||
self.frame:SetScript("OnUpdate", nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function PetMana.prototype:MyOnUpdate()
|
||||
PetMana.super.prototype.MyOnUpdate(self)
|
||||
|
||||
if self.CurrScale == self.DesiredScale then
|
||||
self:SetupOnUpdate(false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function PetMana.prototype:CheckForVehicle()
|
||||
local lastUnit = self.unit
|
||||
|
||||
if UnitIsUnit("pet", "vehicle") or UnitHasVehicleUI("player") then
|
||||
self.unit = "vehicle"
|
||||
else
|
||||
self.unit = "pet"
|
||||
end
|
||||
|
||||
if self.unit ~= lastUnit then
|
||||
self:ManaType(self.unit)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function PetMana.prototype:Update(unit)
|
||||
self:CheckForVehicle()
|
||||
|
||||
PetMana.super.prototype.Update(self)
|
||||
|
||||
if (unit and (unit ~= self.unit)) then
|
||||
return
|
||||
end
|
||||
@ -105,6 +150,13 @@ function PetMana.prototype:Update(unit)
|
||||
self:Show(true)
|
||||
end
|
||||
|
||||
if (self.manaPercentage == 1 and self.manaType ~= 1 and self.manaType ~= 6)
|
||||
or (self.manaPercentage == 0 and (self.manaType == 1 or self.manaType == 6)) then
|
||||
self:SetupOnUpdate(false)
|
||||
elseif GetCVarBool("predictedPower") then
|
||||
self:SetupOnUpdate(true)
|
||||
end
|
||||
|
||||
local color = "PetMana"
|
||||
if (self.moduleSettings.scaleManaColor) then
|
||||
color = "ScaledManaColor"
|
||||
|
Reference in New Issue
Block a user