diff --git a/api/api.lua b/api/api.lua index 70c29697..577c312b 100644 --- a/api/api.lua +++ b/api/api.lua @@ -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 diff --git a/api/ui-widgets.lua b/api/ui-widgets.lua index fb96e3d0..6f3c8130 100644 --- a/api/ui-widgets.lua +++ b/api/ui-widgets.lua @@ -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 diff --git a/api/unitframes.lua b/api/unitframes.lua index 4ca1797d..cf6e59e8 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -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() diff --git a/modules/castbar.lua b/modules/castbar.lua index f802ab8d..c781c9b0 100644 --- a/modules/castbar.lua +++ b/modules/castbar.lua @@ -36,7 +36,7 @@ pfUI:RegisterModule("castbar", function () cb.bar:SetValue(1) end if cb.bar.spark then cb.bar.spark:Hide() end - cb.fadeout = 1 + if cb:GetAlpha() > 0 and not cb.fade:IsPlaying() then cb.fade:Play() end end -- "Spellname (N)" label for an active tradeskill merge — N is the number @@ -94,8 +94,8 @@ pfUI:RegisterModule("castbar", function () cb.activeName = name cb.isTradeskill = isTradeskill cb.delay = (delayMs or 0) / 1000 + cb.fade:Stop() cb:SetAlpha(1) - cb.fadeout = nil -- Shield an uninterruptible cast. Not on the player's own bar: the flag is -- measured against the reader's own interrupts and silences, so on your own @@ -248,8 +248,14 @@ pfUI:RegisterModule("castbar", function () cb.bar.spark:SetPoint("BOTTOM", cb.bar, "BOTTOMLEFT", 0, 0) cb.bar.spark:Hide() - -- OnUpdate animates the bar fill and fades it out on completion. All - -- state transitions (cast start/stop/interrupt, channel start/stop, + -- Fade-out after a cast ends. The bar stays at alpha 0 while idle. + cb.fade = cb:CreateAnimationGroup() + local fade = cb.fade:CreateAnimation("Alpha") + fade:SetChange(-1) + fade:SetDuration(.4) + cb.fade:SetScript("OnFinished", function() cb:SetAlpha(0) end) + + -- OnUpdate animates the bar fill. All state transitions (cast start/stop/interrupt, channel start/stop, -- pushback) come from the event handler below — we never poll C_Spell -- here. cb:SetScript("OnUpdate", function() @@ -257,15 +263,12 @@ pfUI:RegisterModule("castbar", function () this.tick = GetTime() + 0.020 -- ~50 FPS if this.drag and this.drag:IsShown() then + this.fade:Stop() this:SetAlpha(1) return end - if this.fadeout and this:GetAlpha() > 0 then - this:SetAlpha(this:GetAlpha() - 0.05) - if this:GetAlpha() <= 0 then this.fadeout = nil end - return - end + if this.fade:IsPlaying() then return end if not this.endTime then if this:GetAlpha() ~= 0 then this:SetAlpha(0) end diff --git a/modules/minimap.lua b/modules/minimap.lua index 0783a7b7..10928c50 100644 --- a/modules/minimap.lua +++ b/modules/minimap.lua @@ -109,24 +109,26 @@ pfUI:RegisterModule("minimap", function () this.highlight.tex:SetPoint("BOTTOMRIGHT", MiniMapMailIcon, "BOTTOMRIGHT", 2, -2) this.highlight.tex:SetVertexColor(1,.5,.5) - this.highlight:SetScript("OnUpdate", function() - if not this.count then this.count = 0 end - if not this.modifier then this.modifier = 1 end - if this.count >= 10 then this:Hide() end - - this:SetAlpha(this:GetAlpha() + this.modifier) - - if this:GetAlpha() <= 0.1 then - this.modifier = 0.05 - this.count = this.count + 1 - elseif this:GetAlpha() >= 0.9 then - this.modifier = -0.05 - end - end) + -- 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:SetDuration(.3) + down:SetOrder(i * 2 - 1) + local up = highlight.blink:CreateAnimation("Alpha") + up:SetChange(.8) + up:SetDuration(.3) + up:SetOrder(i * 2) + end + highlight.blink:SetScript("OnFinished", function() highlight:Hide() end) end - this.highlight.count = 0 this.highlight:Show() + this.highlight.blink:Stop() + this.highlight.blink:Play() end) -- Create coordinates text frame with location configurable diff --git a/modules/tracking.lua b/modules/tracking.lua index b339c10b..ed5649aa 100644 --- a/modules/tracking.lua +++ b/modules/tracking.lua @@ -34,6 +34,14 @@ pfUI:RegisterModule("tracking", function () pfUI.tracking.icon:SetTexCoord(.08, .92, .08, .92) pfUI.tracking.icon:SetAllPoints(pfUI.tracking) + -- Pulses the icon while no tracking spell is active + pfUI.tracking.pulse = pfUI.tracking.icon:CreateAnimationGroup() + pfUI.tracking.pulse:SetLooping("BOUNCE") + local fade = pfUI.tracking.pulse:CreateAnimation("Alpha") + fade:SetChange(-.5) + fade:SetDuration(.5) + fade:SetSmoothing("IN_OUT") + pfUI.tracking.menu = CreateFrame("Frame", "pfUIDropDownMenuTracking", nil, "UIDropDownMenuTemplate") pfUI.tracking:RegisterEvent("PLAYER_ENTERING_WORLD") @@ -48,19 +56,6 @@ pfUI:RegisterModule("tracking", function () this:RefreshMenu() end) - pfUI.tracking:SetScript("OnUpdate", function() - if this.pulse then - local _,_,_,alpha = this.icon:GetVertexColor() - local fpsmod = GetFramerate() / 30 - if not alpha or alpha >= 0.9 then - this.modifier = -0.03 / fpsmod - elseif alpha <= .5 then - this.modifier = 0.03 / fpsmod - end - this.icon:SetVertexColor(1,1,1,alpha + this.modifier) - end - end) - pfUI.tracking:RegisterForClicks("LeftButtonUp", "RightButtonUp") pfUI.tracking:SetScript("OnClick", function() if arg1 == "RightButton" then @@ -113,20 +108,18 @@ pfUI:RegisterModule("tracking", function () local texture = GetTrackingTexture() if texture and texture ~= state.texture then state.texture = texture - pfUI.tracking.pulse = nil + pfUI.tracking.pulse:Stop() pfUI.tracking.icon:SetTexture(texture) - pfUI.tracking.icon:SetVertexColor(1,1,1,1) pfUI.tracking:Show() elseif not texture then state.texture = nil if pulse and next(state.spells) ~= nil then - pfUI.tracking.pulse = true pfUI.tracking.icon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark") - pfUI.tracking.icon:SetVertexColor(1,1,1,1) + if not pfUI.tracking.pulse:IsPlaying() then pfUI.tracking.pulse:Play() end pfUI.tracking:Show() else - pfUI.tracking.pulse = nil + pfUI.tracking.pulse:Stop() pfUI.tracking:Hide() end end diff --git a/modules/unlock.lua b/modules/unlock.lua index ebdc54a0..f89f9b80 100644 --- a/modules/unlock.lua +++ b/modules/unlock.lua @@ -130,15 +130,6 @@ pfUI:RegisterModule("unlock", function () return frames end - local function DraggerOnUpdate() - this.text:SetAlpha(this.text:GetAlpha() -0.05) - if this.text:GetAlpha() < 0.1 then - this.text:SetText(strsub(this:GetParent():GetName(),3)) - this.text:SetAlpha(1) - this:SetScript("OnUpdate", function() return end) - end - end - local function SaveScale(frame, scale) frame:SetScale(scale) @@ -148,9 +139,8 @@ pfUI:RegisterModule("unlock", function () C.position[frame:GetName()]["scale"] = scale frame.drag.text:SetText(T["Scale"] .. ": " .. scale) - frame.drag.text:SetAlpha(1) - - frame.drag:SetScript("OnUpdate", DraggerOnUpdate) + frame.drag.fade:Stop() + frame.drag.fade:Play() end local function SavePosition(frame) @@ -455,6 +445,15 @@ pfUI:RegisterModule("unlock", function () d.text:SetPoint("CENTER", 0, 0) d.text:SetFontObject(GameFontWhite) + -- Fades out the scale readout, then puts the frame name back + d.fade = d.text:CreateAnimationGroup() + local fade = d.fade:CreateAnimation("Alpha") + fade:SetChange(-1) + fade:SetDuration(.3) + d.fade:SetScript("OnFinished", function() + d.text:SetText(strsub(f:GetName(),3)) + end) + d.frame = f d.fname = fname d.label = label diff --git a/modules/xpbar.lua b/modules/xpbar.lua index 4e42f8e5..90a78729 100644 --- a/modules/xpbar.lua +++ b/modules/xpbar.lua @@ -63,9 +63,16 @@ pfUI:RegisterModule("xpbar", function () end end) + -- Cancel a running fade-out and show the bar at full alpha + local function Reveal(self) + self.fade:Stop() + self:SetAlpha(1) + end + local function OnLeave(self) local self = self or this + self.hover = nil self.tick = GetTime() + 3.00 GameTooltip:Hide() end @@ -82,7 +89,8 @@ local function OnEnter(self) mode = "REP" end - self:SetAlpha(1) + self.hover = true + Reveal(self) if mode == "XP" then local xp, xpmax, exh = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion() @@ -187,9 +195,11 @@ end end if self.always then return end - if self:GetAlpha() == 0 or MouseIsOver(self) then return end - if ( self.tick or 1) > GetTime() then return else self.tick = GetTime() + .01 end - self:SetAlpha(self:GetAlpha() - .05) + -- Hover comes from OnEnter/OnLeave, the same mouse focus that reveals the + -- bar, so the fade can't restart under the cursor + if self:GetAlpha() == 0 or self.hover or self.fade:IsPlaying() then return end + if ( self.tick or 1) > GetTime() then return end + self.fade:Play() end local function OnEvent(self) @@ -210,7 +220,7 @@ end end if self.always then - self:SetAlpha(1) + Reveal(self) self:Show() end @@ -220,7 +230,7 @@ end if mode == "XP" then self.enabled = true - self:SetAlpha(1) + Reveal(self) self.bar:SetMinMaxValues(0, UnitXPMax("player")) self.bar:SetValue(UnitXP("player")) if GetXPExhaustion() then @@ -246,7 +256,7 @@ end elseif mode == "PETXP" then self.restedbar:Hide() self.enabled = true - self:SetAlpha(1) + Reveal(self) local currXP, nextXP = GetPetExperience() self.bar:SetMinMaxValues(min(0, currXP), nextXP) @@ -264,7 +274,7 @@ end local name, standingID, barMin, barMax, barValue = GetRepDisplay(self.factionID) if name then self.enabled = true - self:SetAlpha(1) + Reveal(self) barMax = barMax - barMin barValue = barValue - barMin @@ -362,6 +372,14 @@ end -- auto hide b:EnableMouse(true) + if not b.fade then + b.fade = b:CreateAnimationGroup() + 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") b:RegisterUnitEvent("UNIT_PET", "player") b:RegisterUnitEvent("UNIT_LEVEL", "player")