From 41806602df1d546e7232e0fb1b077e216e1c2be3 Mon Sep 17 00:00:00 2001 From: Parnic Date: Tue, 20 Jul 2010 01:34:21 +0000 Subject: [PATCH] - user-submitted patch for an 'invert' option in addition to the 'reverse' option for all bars. now 'reverse' controls bar movement direction while 'invert' controls bar fill behavior http://www.wowace.com/addons/ice-hud/tickets/73-reversing-cast-bars-and-channels --- IceBarElement.lua | 34 +++++++++++++++++++++++++++++----- IceCastBar.lua | 20 +++++++++++++++++++- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/IceBarElement.lua b/IceBarElement.lua index 09d81fc..d33e984 100644 --- a/IceBarElement.lua +++ b/IceBarElement.lua @@ -64,6 +64,7 @@ function IceBarElement.prototype:GetDefaultSettings() settings["side"] = IceCore.Side.Left settings["offset"] = 1 settings["scale"] = 1 + settings["inverse"] = false settings["reverse"] = false settings["barFontSize"] = 12 settings["lockUpperTextAlpha"] = true @@ -166,6 +167,25 @@ function IceBarElement.prototype:GetOptions() order = 32 } + opts["inverse"] = + { + type = 'toggle', + name = 'Invert bar', + desc = 'Filling behaviour of bar', + get = function() + return self.moduleSettings.inverse + end, + set = function(value) + self.moduleSettings.inverse = value + self:SetBarFramePoints() + self:Redraw() + end, + disabled = function() + return not self.moduleSettings.enabled + end, + order = 32 + } + opts["reverse"] = { type = 'toggle', @@ -545,7 +565,7 @@ end function IceBarElement.prototype:SetBarFramePoints() self.barFrame:ClearAllPoints() - if (self.moduleSettings.reverse) then + if (self.moduleSettings.inverse) then self.barFrame:SetPoint("TOPLEFT", self.frame, "TOPLEFT") else self.barFrame:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT") @@ -768,11 +788,15 @@ function IceBarElement.prototype:SetScale(scale, force) self.CurrScale = IceHUD:Clamp(self:LerpScale(scale), 0, 1) if force or oldScale ~= self.CurrScale then - if (self.moduleSettings.reverse) then + local scale = self.CurrScale + if (self.moduleSettings.reverse) then + scale = 1 - scale + end + if (self.moduleSettings.inverse) then min_y = 0; - max_y = self.CurrScale; + max_y = scale; else - min_y = 1-self.CurrScale; + min_y = 1-scale; max_y = 1; end if (self.moduleSettings.side == IceCore.Side.Left) then @@ -781,7 +805,7 @@ function IceBarElement.prototype:SetScale(scale, force) self.barFrame.bar:SetTexCoord(0, 1, min_y, max_y) end - self.barFrame:SetHeight(self.settings.barHeight * self.CurrScale) + self.barFrame:SetHeight(self.settings.barHeight * scale) if self.CurrScale == 0 then self.barFrame.bar:Hide() diff --git a/IceCastBar.lua b/IceCastBar.lua index 7d289d9..493f0db 100644 --- a/IceCastBar.lua +++ b/IceCastBar.lua @@ -65,6 +65,7 @@ function IceCastBar.prototype:GetDefaultSettings() settings["displayAuraIcon"] = false settings["auraIconXOffset"] = 40 settings["auraIconYOffset"] = 0 + settings["reverseChannel"] = true return settings end @@ -178,6 +179,23 @@ function IceCastBar.prototype:GetOptions() order = 53, } + opts["reverseChannel"] = { + type = 'toggle', + name = "Reverse channel direction", + desc = "Whether or not to reverse the direction of a channel's castbar", + get = function() + return self.moduleSettings.reverseChannel + end, + set = function(v) + self.moduleSettings.reverseChannel = v + end, + disabled = function() + return not self.moduleSettings.enabled + end, + usage = "", + order = 32.5, + } + return opts end @@ -233,7 +251,7 @@ function IceCastBar.prototype:OnUpdate() local remainingTime = self.actionStartTime + self.actionDuration - time local scale = 1 - (self.actionDuration ~= 0 and remainingTime / self.actionDuration or 0) - if (self.action == IceCastBar.Actions.Channel) then + if (self.moduleSettings.reverseChannel and self.action == IceCastBar.Actions.Channel) then scale = self.actionDuration ~= 0 and remainingTime / self.actionDuration or 0 end