From ecb71c9abcb1e9c4bd17c73a52682c3aa124ce0f Mon Sep 17 00:00:00 2001 From: Parnic Date: Tue, 20 Jul 2010 03:17:49 +0000 Subject: [PATCH] - moved the xor method out to IceHUD instead of being a CastBar local function - made second threat bar and aggro bar behave properly with new invert/reverse --- IceHUD.lua | 4 ++++ modules/CastBar.lua | 10 +++------- modules/Threat.lua | 21 ++++++++++++++------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/IceHUD.lua b/IceHUD.lua index 0af9007..fccc803 100644 --- a/IceHUD.lua +++ b/IceHUD.lua @@ -883,3 +883,7 @@ function IceHUD:ShouldSwapToVehicle(...) return true end end + +function IceHUD:xor(val1, val2) + return val1 and not val2 or val2 and not val1 +end diff --git a/modules/CastBar.lua b/modules/CastBar.lua index 2fb90f2..9dc2b46 100644 --- a/modules/CastBar.lua +++ b/modules/CastBar.lua @@ -422,10 +422,6 @@ function CastBar.prototype:SpellCastSent(unit, spell, rank, target) self.spellCastSent = GetTime() end -local function xor(val1, val2) - return val1 and not val2 or val2 and not val1 -end - -- OVERRIDE function CastBar.prototype:SpellCastStart(unit, spell, rank) CastBar.super.prototype.SpellCastStart(self, unit, spell, rank) @@ -437,7 +433,7 @@ function CastBar.prototype:SpellCastStart(unit, spell, rank) self.lagBar:SetFrameStrata("BACKGROUND") self.lagBar:ClearAllPoints() - if not xor(self.moduleSettings.reverse, self.moduleSettings.inverse) then + if not IceHUD:xor(self.moduleSettings.reverse, self.moduleSettings.inverse) then self.lagBar:SetPoint("TOPLEFT", self.frame, "TOPLEFT") else self.lagBar:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT") @@ -453,7 +449,7 @@ function CastBar.prototype:SpellCastStart(unit, spell, rank) local min_y = 0 local max_y = pos - if xor(self.moduleSettings.reverse, self.moduleSettings.inverse) then + if IceHUD:xor(self.moduleSettings.reverse, self.moduleSettings.inverse) then min_y = 1-pos max_y = 1 end @@ -483,7 +479,7 @@ function CastBar.prototype:SpellCastChannelStart(unit) return end - local lagTop = not xor(self.moduleSettings.reverse, self.moduleSettings.inverse) + local lagTop = not IceHUD:xor(self.moduleSettings.reverse, self.moduleSettings.inverse) if self.moduleSettings.reverseChannel then lagTop = not lagTop end diff --git a/modules/Threat.lua b/modules/Threat.lua index 8f24eb9..7119af8 100644 --- a/modules/Threat.lua +++ b/modules/Threat.lua @@ -202,11 +202,13 @@ function IceThreat.prototype:CreateAggroBar() self.aggroBar = CreateFrame("Frame", nil, self.frame) end + local aggroTop = not IceHUD:xor(self.moduleSettings.reverse, self.moduleSettings.inverse) + self.aggroBar:SetFrameStrata("BACKGROUND") self.aggroBar:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0)) self.aggroBar:SetHeight(self.settings.barHeight) self.aggroBar:ClearAllPoints() - if not self.moduleSettings.reverse then + if aggroTop then self.aggroBar:SetPoint("TOPLEFT", self.frame, "TOPLEFT") else self.aggroBar:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT") @@ -236,12 +238,12 @@ function IceThreat.prototype:CreateSecondThreatBar() if not (self.secondThreatBar) then self.secondThreatBar = CreateFrame("Frame", nil, self.frame) end - + self.secondThreatBar:SetFrameStrata("MEDIUM") self.secondThreatBar:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0)) self.secondThreatBar:SetHeight(self.settings.barHeight) self.secondThreatBar:ClearAllPoints() - if self.moduleSettings.reverse then + if self.moduleSettings.inverse then self.secondThreatBar:SetPoint("TOPLEFT", self.frame, "TOPLEFT") else self.secondThreatBar:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT") @@ -374,14 +376,15 @@ function IceThreat.prototype:Update(unit) self:UpdateBar( scaledPercentZeroToOne, self.color ) -- do the aggro indicator bar stuff, but only if it has changed - if ( self.aggroBarMulti ~= rangeMulti ) then + --if ( self.aggroBarMulti ~= rangeMulti ) then self.aggroBarMulti = rangeMulti local pos = IceHUD:Clamp(1 - (1 / rangeMulti), 0, 1) + local fromTop = not IceHUD:xor(self.moduleSettings.reverse, self.moduleSettings.inverse) local min_y = 0 local max_y = pos - if self.moduleSettings.reverse then + if not fromTop then min_y = 1-pos max_y = 1 end @@ -399,7 +402,7 @@ function IceThreat.prototype:Update(unit) end self.aggroBar:SetHeight(self.settings.barHeight * pos) - end + --end self:UpdateAlpha() self:UpdateSecondHighestThreatBar(secondHighestThreat, threatValue) @@ -411,9 +414,13 @@ function IceThreat.prototype:UpdateSecondHighestThreatBar(secondHighestThreat, t else local pos = IceHUD:Clamp(secondHighestThreat / threatValue, 0, 1) + if self.moduleSettings.reverse then + pos = 1-pos + end + local min_y = 0 local max_y = pos - if self.moduleSettings.reverse then + if self.moduleSettings.inverse then min_y = 1-pos max_y = 1 end