- added support to player health, mana, and cast bars to change which unit they are monitoring to be the vehicle when the player enters one
This commit is contained in:
Parnic
2009-07-08 02:48:30 +00:00
parent b9c9182c27
commit 50dcfb6a8c
3 changed files with 70 additions and 2 deletions

View File

@ -283,12 +283,29 @@ end
function CastBar.prototype:Enable(core) function CastBar.prototype:Enable(core)
CastBar.super.prototype.Enable(self, core) CastBar.super.prototype.Enable(self, core)
self:RegisterEvent("UNIT_ENTERED_VEHICLE", "EnteringVehicle")
self:RegisterEvent("UNIT_ENTERING_VEHICLE", "EnteringVehicle")
self:RegisterEvent("UNIT_EXITING_VEHICLE", "ExitingVehicle")
self:RegisterEvent("UNIT_EXITED_VEHICLE", "ExitingVehicle")
if self.moduleSettings.enabled and not self.moduleSettings.showBlizzCast then if self.moduleSettings.enabled and not self.moduleSettings.showBlizzCast then
self:ToggleBlizzCast(false) self:ToggleBlizzCast(false)
end end
end end
function CastBar.prototype:EnteringVehicle()
self.unit = "vehicle"
self:Update(self.unit)
end
function CastBar.prototype:ExitingVehicle()
self.unit = "player"
self:Update(self.unit)
end
function CastBar.prototype:Disable(core) function CastBar.prototype:Disable(core)
CastBar.super.prototype.Disable(self, core) CastBar.super.prototype.Disable(self, core)
@ -381,6 +398,9 @@ function CastBar.prototype:SpellCastStart(unit, spell, rank)
local lag = GetTime() - (self.spellCastSent or 0) local lag = GetTime() - (self.spellCastSent or 0)
local pos = IceHUD:Clamp(lag / self.actionDuration, 0, 1) local pos = IceHUD:Clamp(lag / self.actionDuration, 0, 1)
if self.unit == "vehicle" then
pos = 0
end
local y = self.settings.barHeight - (pos * self.settings.barHeight) local y = self.settings.barHeight - (pos * self.settings.barHeight)
if (self.moduleSettings.side == IceCore.Side.Left) then if (self.moduleSettings.side == IceCore.Side.Left) then
@ -401,6 +421,9 @@ function CastBar.prototype:SpellCastChannelStart(unit)
local lag = GetTime() - (self.spellCastSent or 0) local lag = GetTime() - (self.spellCastSent or 0)
local pos = IceHUD:Clamp(lag / self.actionDuration, 0, 1) local pos = IceHUD:Clamp(lag / self.actionDuration, 0, 1)
if self.unit == "vehicle" then
pos = 0
end
local y = self.settings.barHeight - (pos * self.settings.barHeight) local y = self.settings.barHeight - (pos * self.settings.barHeight)
if (self.moduleSettings.side == IceCore.Side.Left) then if (self.moduleSettings.side == IceCore.Side.Left) then

View File

@ -75,6 +75,11 @@ function PlayerHealth.prototype:Enable(core)
self:RegisterEvent("PLAYER_FLAGS_CHANGED", "CheckPvP") self:RegisterEvent("PLAYER_FLAGS_CHANGED", "CheckPvP")
self:RegisterEvent("UNIT_FACTION", "CheckPvP") self:RegisterEvent("UNIT_FACTION", "CheckPvP")
self:RegisterEvent("UNIT_ENTERED_VEHICLE", "EnteringVehicle")
self:RegisterEvent("UNIT_ENTERING_VEHICLE", "EnteringVehicle")
self:RegisterEvent("UNIT_EXITING_VEHICLE", "ExitingVehicle")
self:RegisterEvent("UNIT_EXITED_VEHICLE", "ExitingVehicle")
if AceLibrary:HasInstance("LibHealComm-3.0") then if AceLibrary:HasInstance("LibHealComm-3.0") then
HealComm = AceLibrary("LibHealComm-3.0") HealComm = AceLibrary("LibHealComm-3.0")
HealComm.RegisterCallback(self, "HealComm_DirectHealStart", function(event, healerName, healSize, endTime, ...) self:HealComm_DirectHealStart(event, healerName, healSize, endTime, ...) end) HealComm.RegisterCallback(self, "HealComm_DirectHealStart", function(event, healerName, healSize, endTime, ...) self:HealComm_DirectHealStart(event, healerName, healSize, endTime, ...) end)
@ -643,6 +648,20 @@ function PlayerHealth.prototype:GetOptions()
end end
function PlayerHealth.prototype:EnteringVehicle()
self.unit = "vehicle"
self:RegisterFontStrings()
self:Update(self.unit)
end
function PlayerHealth.prototype:ExitingVehicle()
self.unit = "player"
self:RegisterFontStrings()
self:Update(self.unit)
end
function PlayerHealth.prototype:CreateFrame() function PlayerHealth.prototype:CreateFrame()
PlayerHealth.super.prototype.CreateFrame(self) PlayerHealth.super.prototype.CreateFrame(self)

View File

@ -111,6 +111,11 @@ function PlayerMana.prototype:Enable(core)
self:RegisterEvent("UNIT_ENERGY", "UpdateEnergy") self:RegisterEvent("UNIT_ENERGY", "UpdateEnergy")
self:RegisterEvent("UNIT_RUNIC_POWER", "Update") self:RegisterEvent("UNIT_RUNIC_POWER", "Update")
self:RegisterEvent("UNIT_ENTERED_VEHICLE", "EnteringVehicle")
self:RegisterEvent("UNIT_ENTERING_VEHICLE", "EnteringVehicle")
self:RegisterEvent("UNIT_EXITING_VEHICLE", "ExitingVehicle")
self:RegisterEvent("UNIT_EXITED_VEHICLE", "ExitingVehicle")
-- allow new 'predicted power' stuff to show the power updates constantly instead of ticking -- allow new 'predicted power' stuff to show the power updates constantly instead of ticking
if GetCVarBool("predictedPower") then if GetCVarBool("predictedPower") then
self:SetupOnUpdate(true) self:SetupOnUpdate(true)
@ -139,6 +144,20 @@ function PlayerMana.prototype:SetupOnUpdate(enable)
end end
function PlayerMana.prototype:EnteringVehicle()
self.unit = "vehicle"
self:RegisterFontStrings()
self:Update(self.unit)
end
function PlayerMana.prototype:ExitingVehicle()
self.unit = "player"
self:RegisterFontStrings()
self:Update(self.unit)
end
function PlayerMana.prototype:MyOnUpdate() function PlayerMana.prototype:MyOnUpdate()
PlayerMana.super.prototype.MyOnUpdate(self) PlayerMana.super.prototype.MyOnUpdate(self)
@ -192,10 +211,17 @@ end
function PlayerMana.prototype:Update(unit) function PlayerMana.prototype:Update(unit)
PlayerMana.super.prototype.Update(self) PlayerMana.super.prototype.Update(self)
if (unit and (unit ~= "player")) then if (unit and (unit ~= self.unit)) then
return return
end end
if self.unit == "vehicle" and ((not UnitExists(unit)) or (self.maxMana == 0)) then
self:Show(false)
return
else
self:Show(true)
end
-- the user can toggle the predictedPower cvar at any time and the addon will not get notified. handle it. -- the user can toggle the predictedPower cvar at any time and the addon will not get notified. handle it.
if not self.tickerFrame and self:ShouldUseTicker() then if not self.tickerFrame and self:ShouldUseTicker() then
self:CreateTickerFrame() self:CreateTickerFrame()
@ -272,7 +298,7 @@ end
function PlayerMana.prototype:UpdateEnergy(unit) function PlayerMana.prototype:UpdateEnergy(unit)
if (unit and (unit ~= "player")) then if (unit and (unit ~= self.unit)) then
return return
end end