From 646174fc60baf4031ac5caeeb25d47b0da4fe73b Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Mon, 2 Nov 2026 23:43:18 -0600 Subject: [PATCH] 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. --- api/api.lua | 2 +- api/unitframes.lua | 48 +++++++++++++++++++------------------------ modules/easteregg.lua | 21 +++++++++++-------- modules/minimap.lua | 7 ++++--- modules/tracking.lua | 3 ++- modules/xpbar.lua | 2 +- 6 files changed, 41 insertions(+), 42 deletions(-) diff --git a/api/api.lua b/api/api.lua index 94b38b03..440bf8d8 100644 --- a/api/api.lua +++ b/api/api.lua @@ -1404,10 +1404,10 @@ function pfUI.api.EnableAutohide(frame, timeout, combat) if not frame.hover.fade then frame.hover.fade = frame:CreateAnimationGroup() + frame.hover.fade:SetToFinalAlpha(true) 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 diff --git a/api/unitframes.lua b/api/unitframes.lua index b8991e81..971fdf8e 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -781,7 +781,6 @@ function pfUI.uf:UpdateConfig() if f.config.hitindicator == "1" then f.feedbackText:SetFont(pfUI.media[f.config.hitindicatorfont], f.config.hitindicatorsize, "OUTLINE") f.feedbackFontHeight = f.config.hitindicatorsize - f.feedbackStartTime = GetTime() if f.config.portrait == "bar" or f.config.portrait == "off" then f.feedbackText:SetParent(f.texts) f.feedbackText:ClearAllPoints() @@ -793,8 +792,8 @@ function pfUI.uf:UpdateConfig() end f.combatfeedback = true else + f.feedback:Stop() f.feedbackText:Hide() - f.feedback:Hide() f.combatfeedback = nil end @@ -1177,8 +1176,10 @@ function pfUI.uf.OnEvent() elseif event == "UNIT_CONNECTION" then pfUI.uf:QueueUpdate(this, "full") elseif event == "UNIT_COMBAT" then + -- every hit starts the fade over + this.feedback:Stop() CombatFeedback_OnCombatEvent(arg2, arg3, arg4, arg5) - this.feedback:Show() + this.feedback:Play() elseif event == "INCOMING_RESURRECT_CHANGED" then pfUI.uf:QueueUpdate(this, "indicators") else @@ -1317,25 +1318,6 @@ C_Timer.NewTicker(.5, function() 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 -- routes through its "UNIT_XXX Events" branch. These are not registered here: -- 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) -- 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:SetFromAlpha(.8) + fade:SetToAlpha(.4) fade:SetDuration(1.3) fade:SetSmoothing("IN_OUT") 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.next = CreateFrame("PlayerModel", nil, nil) f.feedbackText = f:CreateFontString("pfHitIndicator" .. f.label .. f.id, "OVERLAY", "NumberFontNormalHuge") - f.feedback = CreateFrame("Frame", nil, f) - f.feedback:Hide() - f.feedback:SetScript("OnUpdate", FeedbackOnUpdate) + + -- Fade the combat feedback text in, hold it, and fade it out -- the timing + -- 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 local group = math.ceil(f.id/5) diff --git a/modules/easteregg.lua b/modules/easteregg.lua index 86355e96..984155fb 100644 --- a/modules/easteregg.lua +++ b/modules/easteregg.lua @@ -30,15 +30,15 @@ pfUI:RegisterModule("easteregg", function () scene.dtext:SetPoint("TOP", 0, -430) 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 - -- alpha of 1, which comes back when the fade ends. + -- Fade the night in. The scene keeps an alpha of 1, which comes back + -- when the fade ends. scene.dusk = scene:CreateAnimationGroup() local fade = scene.dusk:CreateAnimation("Alpha") - fade:SetChange(-1) + fade:SetToAlpha(1) fade:SetDuration(.8) scene:SetScript("OnShow", function() - this.dusk:Play(true) + this.dusk:Play() end) -- start over on the next AFK @@ -159,7 +159,7 @@ pfUI:RegisterModule("easteregg", function () halloween.text:SetTextColor(1, .5, 0) -- 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. local candle = CreateFrame("Frame", nil, halloween) candle:SetAllPoints() @@ -169,16 +169,19 @@ pfUI:RegisterModule("easteregg", function () candle.flicker = candle:CreateAnimationGroup() candle.flicker:SetLooping("REPEAT") local steps = { - { .18, -.25 }, { .09, .1 }, { .22, -.2 }, { .14, .3 }, { .3, -.1 }, - { .11, -.15 }, { .2, .2 }, { .16, -.3 }, { .26, .25 }, { .12, .15 }, + { .18, .75 }, { .09, .85 }, { .22, .65 }, { .14, .95 }, { .3, .85 }, + { .11, .7 }, { .2, .9 }, { .16, .6 }, { .26, .85 }, { .12, 1 }, } + local from = 1 for order, step in ipairs(steps) do - local duration, change = unpack(step) + local duration, alpha = unpack(step) local fade = candle.flicker:CreateAnimation("Alpha") fade:SetOrder(order) fade:SetDuration(duration) - fade:SetChange(change) + fade:SetFromAlpha(from) + fade:SetToAlpha(alpha) fade:SetSmoothing("IN_OUT") + from = alpha end -- Once the night has fallen, undead rise along the bottom one after diff --git a/modules/minimap.lua b/modules/minimap.lua index 6f337517..93ae3101 100644 --- a/modules/minimap.lua +++ b/modules/minimap.lua @@ -111,15 +111,16 @@ pfUI:RegisterModule("minimap", function () -- Blink ten times between .9 and .1, then hide local highlight = this.highlight - highlight:SetAlpha(.9) highlight.blink = highlight:CreateAnimationGroup() for i = 1, 10 do local down = highlight.blink:CreateAnimation("Alpha") - down:SetChange(-.8) + down:SetFromAlpha(.9) + down:SetToAlpha(.1) down:SetDuration(.3) down:SetOrder(i * 2 - 1) local up = highlight.blink:CreateAnimation("Alpha") - up:SetChange(.8) + up:SetFromAlpha(.1) + up:SetToAlpha(.9) up:SetDuration(.3) up:SetOrder(i * 2) end diff --git a/modules/tracking.lua b/modules/tracking.lua index 974edc97..814e9fe0 100644 --- a/modules/tracking.lua +++ b/modules/tracking.lua @@ -38,7 +38,8 @@ pfUI:RegisterModule("tracking", function () pfUI.tracking.pulse = pfUI.tracking.icon:CreateAnimationGroup() pfUI.tracking.pulse:SetLooping("BOUNCE") local fade = pfUI.tracking.pulse:CreateAnimation("Alpha") - fade:SetChange(-.5) + fade:SetFromAlpha(1) + fade:SetToAlpha(.5) fade:SetDuration(.5) fade:SetSmoothing("IN_OUT") diff --git a/modules/xpbar.lua b/modules/xpbar.lua index ed771af9..8df6adac 100644 --- a/modules/xpbar.lua +++ b/modules/xpbar.lua @@ -381,10 +381,10 @@ end if not b.fade then b.fade = b:CreateAnimationGroup() + b.fade:SetToFinalAlpha(true) local fade = b.fade:CreateAnimation("Alpha") fade:SetChange(-1) fade:SetDuration(.3) - b.fade:SetScript("OnFinished", function() b:SetAlpha(0) end) end b:RegisterEvent("FACTION_STANDING_CHANGED")