Animations: absolute alpha and setToFinalAlpha, combat feedback text fades on an animation group

Combat feedback text fades in, holds and fades out on an animation group
on the font string instead of an OnUpdate helper frame. Autohide and the
XP/rep bars keep the faded-out alpha with SetToFinalAlpha instead of an
OnFinished that sets it. Pulses, the mail blink, the holiday dusk and the
candle flicker give their alphas with SetFromAlpha / SetToAlpha.
This commit is contained in:
Brues
2026-11-03 01:07:03 -06:00
parent 1c1be19711
commit 646174fc60
6 changed files with 41 additions and 42 deletions
+1 -1
View File
@@ -1404,10 +1404,10 @@ function pfUI.api.EnableAutohide(frame, timeout, combat)
if not frame.hover.fade then if not frame.hover.fade then
frame.hover.fade = frame:CreateAnimationGroup() frame.hover.fade = frame:CreateAnimationGroup()
frame.hover.fade:SetToFinalAlpha(true)
local fade = frame.hover.fade:CreateAnimation("Alpha") local fade = frame.hover.fade:CreateAnimation("Alpha")
fade:SetChange(-1) fade:SetChange(-1)
fade:SetDuration(1) fade:SetDuration(1)
frame.hover.fade:SetScript("OnFinished", function() frame:SetAlpha(0) end)
end end
if combat then if combat then
+21 -27
View File
@@ -781,7 +781,6 @@ function pfUI.uf:UpdateConfig()
if f.config.hitindicator == "1" then if f.config.hitindicator == "1" then
f.feedbackText:SetFont(pfUI.media[f.config.hitindicatorfont], f.config.hitindicatorsize, "OUTLINE") f.feedbackText:SetFont(pfUI.media[f.config.hitindicatorfont], f.config.hitindicatorsize, "OUTLINE")
f.feedbackFontHeight = f.config.hitindicatorsize f.feedbackFontHeight = f.config.hitindicatorsize
f.feedbackStartTime = GetTime()
if f.config.portrait == "bar" or f.config.portrait == "off" then if f.config.portrait == "bar" or f.config.portrait == "off" then
f.feedbackText:SetParent(f.texts) f.feedbackText:SetParent(f.texts)
f.feedbackText:ClearAllPoints() f.feedbackText:ClearAllPoints()
@@ -793,8 +792,8 @@ function pfUI.uf:UpdateConfig()
end end
f.combatfeedback = true f.combatfeedback = true
else else
f.feedback:Stop()
f.feedbackText:Hide() f.feedbackText:Hide()
f.feedback:Hide()
f.combatfeedback = nil f.combatfeedback = nil
end end
@@ -1177,8 +1176,10 @@ function pfUI.uf.OnEvent()
elseif event == "UNIT_CONNECTION" then elseif event == "UNIT_CONNECTION" then
pfUI.uf:QueueUpdate(this, "full") pfUI.uf:QueueUpdate(this, "full")
elseif event == "UNIT_COMBAT" then elseif event == "UNIT_COMBAT" then
-- every hit starts the fade over
this.feedback:Stop()
CombatFeedback_OnCombatEvent(arg2, arg3, arg4, arg5) CombatFeedback_OnCombatEvent(arg2, arg3, arg4, arg5)
this.feedback:Show() this.feedback:Play()
elseif event == "INCOMING_RESURRECT_CHANGED" then elseif event == "INCOMING_RESURRECT_CHANGED" then
pfUI.uf:QueueUpdate(this, "indicators") pfUI.uf:QueueUpdate(this, "indicators")
else else
@@ -1317,25 +1318,6 @@ C_Timer.NewTicker(.5, function()
end end
end) end)
-- Fade the combat feedback text in, hold it, and fade it out -- the timing of
-- CombatFeedback_OnUpdate. Runs on a child frame shown only while the text is.
local function FeedbackOnUpdate()
local frame = this:GetParent()
local text = frame.feedbackText
local elapsed = GetTime() - frame.feedbackStartTime
local fadein, hold = COMBATFEEDBACK_FADEINTIME, COMBATFEEDBACK_HOLDTIME
if elapsed < fadein then
text:SetAlpha(elapsed / fadein)
elseif elapsed < fadein + hold then
text:SetAlpha(1)
elseif elapsed < fadein + hold + COMBATFEEDBACK_FADEOUTTIME then
text:SetAlpha(1 - (elapsed - hold - fadein) / COMBATFEEDBACK_FADEOUTTIME)
else
text:Hide()
this:Hide()
end
end
-- The unit events whose arg1 is the frame's OWN unit -- everything the OnEvent -- The unit events whose arg1 is the frame's OWN unit -- everything the OnEvent
-- routes through its "UNIT_XXX Events" branch. These are not registered here: -- routes through its "UNIT_XXX Events" branch. These are not registered here:
-- UpdateVisibility owns them, because it owns the frame's unit (below). -- UpdateVisibility owns them, because it owns the frame's unit (below).
@@ -1592,11 +1574,11 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick)
f.glow = CreateFrame("Frame", nil, f) f.glow = CreateFrame("Frame", nil, f)
-- Pulse between .8 and .4 for good. The group only advances while the glow -- Pulse between .8 and .4 for good. The group only advances while the glow
-- is shown, so a hidden glow costs nothing. -- is shown, so a hidden glow costs nothing.
f.glow:SetAlpha(.8)
f.glow.pulse = f.glow:CreateAnimationGroup() f.glow.pulse = f.glow:CreateAnimationGroup()
f.glow.pulse:SetLooping("BOUNCE") f.glow.pulse:SetLooping("BOUNCE")
local fade = f.glow.pulse:CreateAnimation("Alpha") local fade = f.glow.pulse:CreateAnimation("Alpha")
fade:SetChange(-.4) fade:SetFromAlpha(.8)
fade:SetToAlpha(.4)
fade:SetDuration(1.3) fade:SetDuration(1.3)
fade:SetSmoothing("IN_OUT") fade:SetSmoothing("IN_OUT")
f.glow.pulse:Play() f.glow.pulse:Play()
@@ -1654,9 +1636,21 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick)
f.portrait.model = CreateFrame("PlayerModel", "pfPortraitModel" .. f.label .. f.id, f.portrait) f.portrait.model = CreateFrame("PlayerModel", "pfPortraitModel" .. f.label .. f.id, f.portrait)
f.portrait.model.next = CreateFrame("PlayerModel", nil, nil) f.portrait.model.next = CreateFrame("PlayerModel", nil, nil)
f.feedbackText = f:CreateFontString("pfHitIndicator" .. f.label .. f.id, "OVERLAY", "NumberFontNormalHuge") f.feedbackText = f:CreateFontString("pfHitIndicator" .. f.label .. f.id, "OVERLAY", "NumberFontNormalHuge")
f.feedback = CreateFrame("Frame", nil, f)
f.feedback:Hide() -- Fade the combat feedback text in, hold it, and fade it out -- the timing
f.feedback:SetScript("OnUpdate", FeedbackOnUpdate) -- of CombatFeedback_OnUpdate -- then hide it.
f.feedback = f.feedbackText:CreateAnimationGroup()
local fadein = f.feedback:CreateAnimation("Alpha")
fadein:SetOrder(1)
fadein:SetDuration(COMBATFEEDBACK_FADEINTIME)
fadein:SetToAlpha(1)
local fadeout = f.feedback:CreateAnimation("Alpha")
fadeout:SetOrder(2)
fadeout:SetStartDelay(COMBATFEEDBACK_HOLDTIME)
fadeout:SetDuration(COMBATFEEDBACK_FADEOUTTIME)
fadeout:SetFromAlpha(1)
fadeout:SetToAlpha(0)
f.feedback:SetScript("OnFinished", function() f.feedbackText:Hide() end)
if f.label == "raid" and mod(f.id, 5) == 1 then if f.label == "raid" and mod(f.id, 5) == 1 then
local group = math.ceil(f.id/5) local group = math.ceil(f.id/5)
+12 -9
View File
@@ -30,15 +30,15 @@ pfUI:RegisterModule("easteregg", function ()
scene.dtext:SetPoint("TOP", 0, -430) scene.dtext:SetPoint("TOP", 0, -430)
scene.dtext:SetText(info and info .. "\n\n" .. exit or exit) scene.dtext:SetText(info and info .. "\n\n" .. exit or exit)
-- Fade the night in by playing a fade-out backwards. The scene keeps an -- Fade the night in. The scene keeps an alpha of 1, which comes back
-- alpha of 1, which comes back when the fade ends. -- when the fade ends.
scene.dusk = scene:CreateAnimationGroup() scene.dusk = scene:CreateAnimationGroup()
local fade = scene.dusk:CreateAnimation("Alpha") local fade = scene.dusk:CreateAnimation("Alpha")
fade:SetChange(-1) fade:SetToAlpha(1)
fade:SetDuration(.8) fade:SetDuration(.8)
scene:SetScript("OnShow", function() scene:SetScript("OnShow", function()
this.dusk:Play(true) this.dusk:Play()
end) end)
-- start over on the next AFK -- start over on the next AFK
@@ -159,7 +159,7 @@ pfUI:RegisterModule("easteregg", function ()
halloween.text:SetTextColor(1, .5, 0) halloween.text:SetTextColor(1, .5, 0)
-- Candlelight glows in from the screen edges. It flickers in uneven -- Candlelight glows in from the screen edges. It flickers in uneven
-- steps of { duration, change } that end where they began, so the loop -- steps of { duration, alpha } that end where they began, so the loop
-- never jumps. -- never jumps.
local candle = CreateFrame("Frame", nil, halloween) local candle = CreateFrame("Frame", nil, halloween)
candle:SetAllPoints() candle:SetAllPoints()
@@ -169,16 +169,19 @@ pfUI:RegisterModule("easteregg", function ()
candle.flicker = candle:CreateAnimationGroup() candle.flicker = candle:CreateAnimationGroup()
candle.flicker:SetLooping("REPEAT") candle.flicker:SetLooping("REPEAT")
local steps = { local steps = {
{ .18, -.25 }, { .09, .1 }, { .22, -.2 }, { .14, .3 }, { .3, -.1 }, { .18, .75 }, { .09, .85 }, { .22, .65 }, { .14, .95 }, { .3, .85 },
{ .11, -.15 }, { .2, .2 }, { .16, -.3 }, { .26, .25 }, { .12, .15 }, { .11, .7 }, { .2, .9 }, { .16, .6 }, { .26, .85 }, { .12, 1 },
} }
local from = 1
for order, step in ipairs(steps) do for order, step in ipairs(steps) do
local duration, change = unpack(step) local duration, alpha = unpack(step)
local fade = candle.flicker:CreateAnimation("Alpha") local fade = candle.flicker:CreateAnimation("Alpha")
fade:SetOrder(order) fade:SetOrder(order)
fade:SetDuration(duration) fade:SetDuration(duration)
fade:SetChange(change) fade:SetFromAlpha(from)
fade:SetToAlpha(alpha)
fade:SetSmoothing("IN_OUT") fade:SetSmoothing("IN_OUT")
from = alpha
end end
-- Once the night has fallen, undead rise along the bottom one after -- Once the night has fallen, undead rise along the bottom one after
+4 -3
View File
@@ -111,15 +111,16 @@ pfUI:RegisterModule("minimap", function ()
-- Blink ten times between .9 and .1, then hide -- Blink ten times between .9 and .1, then hide
local highlight = this.highlight local highlight = this.highlight
highlight:SetAlpha(.9)
highlight.blink = highlight:CreateAnimationGroup() highlight.blink = highlight:CreateAnimationGroup()
for i = 1, 10 do for i = 1, 10 do
local down = highlight.blink:CreateAnimation("Alpha") local down = highlight.blink:CreateAnimation("Alpha")
down:SetChange(-.8) down:SetFromAlpha(.9)
down:SetToAlpha(.1)
down:SetDuration(.3) down:SetDuration(.3)
down:SetOrder(i * 2 - 1) down:SetOrder(i * 2 - 1)
local up = highlight.blink:CreateAnimation("Alpha") local up = highlight.blink:CreateAnimation("Alpha")
up:SetChange(.8) up:SetFromAlpha(.1)
up:SetToAlpha(.9)
up:SetDuration(.3) up:SetDuration(.3)
up:SetOrder(i * 2) up:SetOrder(i * 2)
end end
+2 -1
View File
@@ -38,7 +38,8 @@ pfUI:RegisterModule("tracking", function ()
pfUI.tracking.pulse = pfUI.tracking.icon:CreateAnimationGroup() pfUI.tracking.pulse = pfUI.tracking.icon:CreateAnimationGroup()
pfUI.tracking.pulse:SetLooping("BOUNCE") pfUI.tracking.pulse:SetLooping("BOUNCE")
local fade = pfUI.tracking.pulse:CreateAnimation("Alpha") local fade = pfUI.tracking.pulse:CreateAnimation("Alpha")
fade:SetChange(-.5) fade:SetFromAlpha(1)
fade:SetToAlpha(.5)
fade:SetDuration(.5) fade:SetDuration(.5)
fade:SetSmoothing("IN_OUT") fade:SetSmoothing("IN_OUT")
+1 -1
View File
@@ -381,10 +381,10 @@ end
if not b.fade then if not b.fade then
b.fade = b:CreateAnimationGroup() b.fade = b:CreateAnimationGroup()
b.fade:SetToFinalAlpha(true)
local fade = b.fade:CreateAnimation("Alpha") local fade = b.fade:CreateAnimation("Alpha")
fade:SetChange(-1) fade:SetChange(-1)
fade:SetDuration(.3) fade:SetDuration(.3)
b.fade:SetScript("OnFinished", function() b:SetAlpha(0) end)
end end
b:RegisterEvent("FACTION_STANDING_CHANGED") b:RegisterEvent("FACTION_STANDING_CHANGED")