From 4f4c8923064ec5d7b6a600c9a64106f128bd2b85 Mon Sep 17 00:00:00 2001 From: rokiyo Date: Fri, 5 Nov 2010 04:12:37 +0000 Subject: [PATCH] - Suppress bar animations if update rate is less than 15/sec --- IceBarElement.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/IceBarElement.lua b/IceBarElement.lua index 0831fca..590d1f2 100644 --- a/IceBarElement.lua +++ b/IceBarElement.lua @@ -22,6 +22,8 @@ local lastMarkerColorConfig = {r=1, b=0, g=0, a=1} local lastMarkerHeightConfig = 6 local lastEditMarkerConfig = 1 +local MIN_ANIMATED_UPDATED_RATE = 15 + -- Constructor -- function IceBarElement.prototype:init(name, ...) IceBarElement.super.prototype.init(self, name, ...) @@ -357,9 +359,28 @@ do end, set = function(info, value) self.moduleSettings.shouldAnimate = value + self.moduleSettings.wasAnimated = value self:Redraw() end, disabled = function() + -- If below threshold, turn off and remember if we were on + if 1/IceHUD.IceCore:UpdatePeriod() < MIN_ANIMATED_UPDATED_RATE then + if self.moduleSettings.shouldAnimate then + self.moduleSettings.wasAnimated = true + self.moduleSettings.shouldAnimate = false + IceHUD:NotifyOptionsChange() + self:Redraw() + end + return true + + -- If above threshold, if we're off but were on, turn back on + elseif not self.moduleSettings.shouldAnimate and self.moduleSettings.wasAnimated then + self.moduleSettings.shouldAnimate = true + self.moduleSettings.wasAnimated = false + IceHUD:NotifyOptionsChange() + self:Redraw() + end + return not self.moduleSettings.enabled end, order = 111