load oUF_Smooth & relocate oUF_AuraBars

This commit is contained in:
Crum
2018-05-30 21:59:33 -05:00
parent b0fbf06068
commit d3ea62443b
5 changed files with 63 additions and 1 deletions
@@ -0,0 +1,3 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="oUF_AuraBars.lua"/>
</Ui>
+2 -1
View File
@@ -1,3 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="oUF_AuraBars.lua"/>
<Include file="oUF_AuraBars\oUF_AuraBars.xml"/>
<Include file="oUF_Smooth\oUF_Smooth.xml"/>
</Ui>
@@ -0,0 +1,55 @@
local ns = oUF
local oUF = ns.oUF
assert(oUF, "<name> was unable to locate oUF install.")
local smoothing = {}
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(bar)
if not bar.SetValue_ then
bar.SetValue_ = bar.SetValue;
bar.SetValue = Smooth;
end
end
local function hook(frame)
if frame.Health then
SmoothBar(frame.Health)
end
if frame.Power then
SmoothBar(frame.Power)
end
end
for i, frame in ipairs(oUF.objects) do hook(frame) end
oUF:RegisterInitCallback(hook)
local f, min, max = CreateFrame("Frame"), math.min, math.max
f:SetScript("OnUpdate", function()
local limit = 30/GetFramerate()
for bar, value in pairs(smoothing) do
local cur = bar:GetValue()
local new = cur + min((value-cur)/(bar.SmoothSpeed or 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) and bar.Smooth then
bar:SetValue_(value)
smoothing[bar] = nil
elseif not bar.Smooth then
bar:SetValue_(value)
smoothing[bar] = nil
end
end
end)
@@ -0,0 +1,3 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="oUF_Smooth.lua"/>
</Ui>