- added some protection against error messages that were popping up related to SetTexCoord

- added some protection against a nil access in the player's cast bar under certain circumstances
This commit is contained in:
Parnic
2009-04-16 13:39:37 +00:00
parent 75787ff956
commit 7d37890a31
7 changed files with 27 additions and 10 deletions

View File

@ -695,6 +695,8 @@ end
function IceBarElement.prototype:SetScale(texture, scale)
local oldScale = self.CurrScale
scale = IceHUD:Clamp(scale, 0, 1)
self.CurrScale = self:LerpScale(scale)
if oldScale ~= self.CurrScale then

View File

@ -207,15 +207,18 @@ end
function IceCastBar.prototype:StartBar(action, message)
self.action = action
self.actionStartTime = GetTime()
self.actionMessage = message
local spell, rank, displayName, icon, startTime, endTime, isTradeSkill = UnitCastingInfo(self.unit)
if not (spell) then
spell, rank, displayName, icon, startTime, endTime = UnitChannelInfo(self.unit)
end
if not spell then
return
end
self.action = action
self.actionStartTime = GetTime()
self.actionMessage = message
if (startTime and endTime) then
self.actionDuration = (endTime - startTime) / 1000

View File

@ -805,3 +805,13 @@ function IceHUD:OnProfileEnable(oldName, oldData)
self.IceCore:SetModuleDatabases()
self.IceCore:Enable()
end
function IceHUD:Clamp(value, min, max)
if value < min then
value = min
elseif value > max then
value = max
end
return value
end

View File

@ -380,7 +380,7 @@ function CastBar.prototype:SpellCastStart(unit, spell, rank)
local lag = GetTime() - (self.spellCastSent or 0)
local pos = lag / self.actionDuration
local pos = IceHUD:Clamp(lag / self.actionDuration, 0, 1)
local y = self.settings.barHeight - (pos * self.settings.barHeight)
if (self.moduleSettings.side == IceCore.Side.Left) then
@ -400,9 +400,9 @@ function CastBar.prototype:SpellCastChannelStart(unit)
local lag = GetTime() - (self.spellCastSent or 0)
local pos = lag / self.actionDuration
local pos = IceHUD:Clamp(lag / self.actionDuration, 0, 1)
local y = self.settings.barHeight - (pos * self.settings.barHeight)
if (self.moduleSettings.side == IceCore.Side.Left) then
self.lagBar.bar:SetTexCoord(1, 0, 1-pos, 1)
else

View File

@ -903,6 +903,8 @@ function PlayerHealth.prototype:Update(unit)
barValue = 1
end
barValue = IceHUD:Clamp(barValue, 0, 1)
if (self.moduleSettings.side == IceCore.Side.Left) then
self.healFrame.bar:SetTexCoord(1, 0, barValue, 1)
else

View File

@ -275,7 +275,7 @@ function SliceAndDice.prototype:UpdateDurationBar(unit)
PotentialSnDDuration = self:GetMaxBuffTime(points)
-- compute the scale from the current number of combo points
scale = PotentialSnDDuration / CurrMaxSnDDuration
scale = IceHUD:Clamp(PotentialSnDDuration / CurrMaxSnDDuration, 0, 1)
-- sadly, animation uses bar-local variables so we can't use the animation for 2 bar textures on the same bar element
if (self.moduleSettings.side == IceCore.Side.Left) then

View File

@ -271,7 +271,7 @@ function IHUD_Threat.prototype:Update(unit)
if ( self.aggroBarMulti ~= threatMulti ) then
self.aggroBarMulti = threatMulti
local pos = 1 - (1 / threatMulti)
local pos = IceHUD:Clamp(1 - (1 / threatMulti), 0, 1)
local y = self.settings.barHeight - ( pos * self.settings.barHeight )
if ( self.moduleSettings.side == IceCore.Side.Left ) then