Include a working version of oUF_SmoothUpdate
Andrew Mordecai [07-15-16 - 14:53]
Include a working version of oUF_SmoothUpdate
diff --git a/Plugins/Smooth.lua b/Plugins/Smooth.lua
new file mode 100755
index 0000000..a9146ad
--- /dev/null
+++ b/Plugins/Smooth.lua
@@ -0,0 +1,47 @@
+local NAME, ns = ...
+local oUF = ns.oUF or oUF
+assert(oUF, NAME.." was unable to locate oUF install.")
+
+local f = CreateFrame('Frame')
+local smoothing = {}
+local abs, min, max, next = math.abs, math.min, math.max, next
+
+f:SetScript('OnUpdate', function()
+ local limit = 30/GetFramerate()
+ for bar, value in next, smoothing do
+ local cur = bar:GetValue()
+ local new = cur + min((value-cur)/3, max(value-cur, limit))
+ if new ~= new then
+ -- Mad hax to prevent QNAN.
+ new = value
+ end
+ bar:SetValue_(new)
+ if cur == value or abs(new - value) < 2 then
+ bar:SetValue_(value)
+ smoothing[bar] = nil
+ end
+ end
+end)
+
+local function Smooth(self, value)
+ local _, max = self:GetMinMaxValues()
+ if value == self:GetValue() or (self._max and self._max ~= max) then
+ smoothing[self] = nil
+ self:SetValue_(value)
+ else
+ smoothing[self] = value
+ end
+ self._max = max
+end
+
+local function SmoothBar(self, bar, unset)
+ if unset and bar.SetValue_ then
+ bar.SetValue = bar.SetValue_
+ bar.SetValue_ = nil
+ elseif not unset and not bar.SetValue_ then
+ bar.SetValue_ = bar.SetValue
+ bar.SetValue = Smooth
+ end
+end
+
+oUF:RegisterMetaFunction('SmoothBar', SmoothBar)
diff --git a/oUF_Stardust.toc b/oUF_Stardust.toc
index 0848834..3cf61c6 100644
--- a/oUF_Stardust.toc
+++ b/oUF_Stardust.toc
@@ -11,6 +11,8 @@ Libs/LibStub.lua
Libs/CallbackHandler-1.0.lua
Libs/LibSharedMedia-3.0.lua
+Plugins/Smooth.lua
+
Elements/BurningEmbers.lua
Elements/DemonicFury.lua