mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-25 21:40:49 +00:00
Use ClassicAPI animation groups for fades and pulses
Replace hand-rolled OnUpdate alpha loops with engine animation groups: unit frame aggro/combat glow, tracking icon pulse, new-mail blink, castbar fade-out, autohide, XP/rep bar fade, info box timeout and the unlock-mode scale label. Timing no longer depends on framerate, and the always-running glow driver and tracking OnUpdate are gone. The XP bar tracks hover through OnEnter/OnLeave instead of MouseIsOver, so a fade can't restart under the cursor.
This commit is contained in:
+13
-3
@@ -1555,11 +1555,20 @@ function pfUI.api.EnableAutohide(frame, timeout, combat)
|
||||
frame.hover.parent = frame
|
||||
frame.hover:Show()
|
||||
|
||||
if not frame.hover.fade then
|
||||
frame.hover.fade = frame:CreateAnimationGroup()
|
||||
local fade = frame.hover.fade:CreateAnimation("Alpha")
|
||||
fade:SetChange(-1)
|
||||
fade:SetDuration(1)
|
||||
frame.hover.fade:SetScript("OnFinished", function() frame:SetAlpha(0) end)
|
||||
end
|
||||
|
||||
if combat then
|
||||
frame.hover:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
frame.hover:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||
frame.hover:SetScript("OnEvent", function()
|
||||
if event == "PLAYER_REGEN_DISABLED" then
|
||||
this.fade:Stop()
|
||||
this.parent:SetAlpha(1)
|
||||
this.activeTo = "keep"
|
||||
elseif event == "PLAYER_REGEN_ENABLED" then
|
||||
@@ -1577,11 +1586,11 @@ function pfUI.api.EnableAutohide(frame, timeout, combat)
|
||||
|
||||
if MouseIsOver(this, 10, -10, -10, 10) then
|
||||
this.activeTo = GetTime() + timeout
|
||||
this.fade:Stop()
|
||||
this.parent:SetAlpha(1)
|
||||
elseif this.activeTo then
|
||||
if this.activeTo < GetTime() and this.parent:GetAlpha() > 0 then
|
||||
local fps = (60 / math.max(GetFramerate(), 1))
|
||||
this.parent:SetAlpha(this.parent:GetAlpha() - 0.05*fps)
|
||||
if this.activeTo < GetTime() and this.parent:GetAlpha() > 0 and not this.fade:IsPlaying() then
|
||||
this.fade:Play()
|
||||
end
|
||||
else
|
||||
this.activeTo = GetTime() + timeout
|
||||
@@ -1598,6 +1607,7 @@ function pfUI.api.DisableAutohide(frame)
|
||||
frame.hover:SetScript("OnEvent", nil)
|
||||
frame.hover:SetScript("OnUpdate", nil)
|
||||
frame.hover:Hide()
|
||||
frame.hover.fade:Stop()
|
||||
frame:SetAlpha(1)
|
||||
end
|
||||
|
||||
|
||||
+11
-6
@@ -1160,17 +1160,21 @@ function pfUI.api.CreateInfoBox(text, time, parent, height)
|
||||
infobox = CreateFrame("Button", "pfInfoBox", UIParent)
|
||||
infobox:Hide()
|
||||
|
||||
infobox.fade = infobox:CreateAnimationGroup()
|
||||
local fade = infobox.fade:CreateAnimation("Alpha")
|
||||
fade:SetChange(-1)
|
||||
fade:SetDuration(.3)
|
||||
infobox.fade:SetScript("OnFinished", function()
|
||||
infobox:Hide()
|
||||
infobox:SetAlpha(1)
|
||||
end)
|
||||
|
||||
infobox:SetScript("OnUpdate", function()
|
||||
local time = infobox.lastshow + infobox.duration - GetTime()
|
||||
infobox.timeout:SetValue(time)
|
||||
|
||||
if GetTime() > infobox.lastshow + infobox.duration then
|
||||
infobox:SetAlpha(infobox:GetAlpha()-0.05)
|
||||
|
||||
if infobox:GetAlpha() <= 0.1 then
|
||||
infobox:Hide()
|
||||
infobox:SetAlpha(1)
|
||||
end
|
||||
if not infobox.fade:IsPlaying() then infobox.fade:Play() end
|
||||
elseif MouseIsOver(this) then
|
||||
this:SetAlpha(max(0.4, this:GetAlpha() - .1))
|
||||
else
|
||||
@@ -1214,6 +1218,7 @@ function pfUI.api.CreateInfoBox(text, time, parent, height)
|
||||
infobox:SetParent(parent)
|
||||
|
||||
infobox:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||
infobox.fade:Stop()
|
||||
infobox:Show()
|
||||
end
|
||||
|
||||
|
||||
+12
-23
@@ -219,27 +219,6 @@ function pfUI.api.UnitHasAggro(unit)
|
||||
return data.state
|
||||
end
|
||||
|
||||
pfUI.uf.glow = CreateFrame("Frame", nil, UIParent)
|
||||
pfUI.uf.glow:SetScript("OnUpdate", function()
|
||||
local fpsmod = GetFramerate() / 30
|
||||
if not this.val or this.val >= .8 then
|
||||
this.mod = -0.01 / fpsmod
|
||||
elseif this.val <= .4 then
|
||||
this.mod = 0.01 / fpsmod
|
||||
end
|
||||
this.val = this.val + this.mod
|
||||
end)
|
||||
|
||||
pfUI.uf.glow.mod = 0
|
||||
pfUI.uf.glow.val = 0.6
|
||||
|
||||
function pfUI.uf.glow.UpdateGlowAnimation()
|
||||
local val = pfUI.uf.glow.val or 0.6
|
||||
if val < 0.4 then val = 0.4 end
|
||||
if val > 0.8 then val = 0.8 end
|
||||
this:SetAlpha(val)
|
||||
end
|
||||
|
||||
function pfUI.uf:UpdateVisibility()
|
||||
local self = self or this
|
||||
|
||||
@@ -451,7 +430,6 @@ function pfUI.uf:UpdateConfig()
|
||||
f.glow:SetBackdrop(glow2)
|
||||
f.glow:SetPoint("TOPLEFT", f, "TOPLEFT", -6 - default_border,6 + default_border)
|
||||
f.glow:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 6 + default_border,-6 - default_border)
|
||||
f.glow:SetScript("OnUpdate", pfUI.uf.glow.UpdateGlowAnimation)
|
||||
f.glow:Hide()
|
||||
|
||||
f.combat:SetSize(tonumber(f.config.squaresize), tonumber(f.config.squaresize))
|
||||
@@ -1482,7 +1460,18 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick)
|
||||
end
|
||||
|
||||
f.glow = CreateFrame("Frame", nil, f)
|
||||
f.combat = CreateFrame("Frame", nil, f.hp.bar)
|
||||
-- Pulse between .8 and .4 for good. The group only advances while the glow
|
||||
-- is shown, so a hidden glow costs nothing.
|
||||
f.glow:SetAlpha(.8)
|
||||
f.glow.pulse = f.glow:CreateAnimationGroup()
|
||||
f.glow.pulse:SetLooping("BOUNCE")
|
||||
local fade = f.glow.pulse:CreateAnimation("Alpha")
|
||||
fade:SetChange(-.4)
|
||||
fade:SetDuration(1.3)
|
||||
fade:SetSmoothing("IN_OUT")
|
||||
f.glow.pulse:Play()
|
||||
|
||||
f.combat =CreateFrame("Frame", nil, f.hp.bar)
|
||||
f.combat.tex = f.combat:CreateTexture(nil, "OVERLAY")
|
||||
f.combat.tex:SetAllPoints()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user