mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-24 13:00:50 +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.parent = frame
|
||||||
frame.hover:Show()
|
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
|
if combat then
|
||||||
frame.hover:RegisterEvent("PLAYER_REGEN_ENABLED")
|
frame.hover:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||||
frame.hover:RegisterEvent("PLAYER_REGEN_DISABLED")
|
frame.hover:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||||
frame.hover:SetScript("OnEvent", function()
|
frame.hover:SetScript("OnEvent", function()
|
||||||
if event == "PLAYER_REGEN_DISABLED" then
|
if event == "PLAYER_REGEN_DISABLED" then
|
||||||
|
this.fade:Stop()
|
||||||
this.parent:SetAlpha(1)
|
this.parent:SetAlpha(1)
|
||||||
this.activeTo = "keep"
|
this.activeTo = "keep"
|
||||||
elseif event == "PLAYER_REGEN_ENABLED" then
|
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
|
if MouseIsOver(this, 10, -10, -10, 10) then
|
||||||
this.activeTo = GetTime() + timeout
|
this.activeTo = GetTime() + timeout
|
||||||
|
this.fade:Stop()
|
||||||
this.parent:SetAlpha(1)
|
this.parent:SetAlpha(1)
|
||||||
elseif this.activeTo then
|
elseif this.activeTo then
|
||||||
if this.activeTo < GetTime() and this.parent:GetAlpha() > 0 then
|
if this.activeTo < GetTime() and this.parent:GetAlpha() > 0 and not this.fade:IsPlaying() then
|
||||||
local fps = (60 / math.max(GetFramerate(), 1))
|
this.fade:Play()
|
||||||
this.parent:SetAlpha(this.parent:GetAlpha() - 0.05*fps)
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
this.activeTo = GetTime() + timeout
|
this.activeTo = GetTime() + timeout
|
||||||
@@ -1598,6 +1607,7 @@ function pfUI.api.DisableAutohide(frame)
|
|||||||
frame.hover:SetScript("OnEvent", nil)
|
frame.hover:SetScript("OnEvent", nil)
|
||||||
frame.hover:SetScript("OnUpdate", nil)
|
frame.hover:SetScript("OnUpdate", nil)
|
||||||
frame.hover:Hide()
|
frame.hover:Hide()
|
||||||
|
frame.hover.fade:Stop()
|
||||||
frame:SetAlpha(1)
|
frame:SetAlpha(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+11
-6
@@ -1160,17 +1160,21 @@ function pfUI.api.CreateInfoBox(text, time, parent, height)
|
|||||||
infobox = CreateFrame("Button", "pfInfoBox", UIParent)
|
infobox = CreateFrame("Button", "pfInfoBox", UIParent)
|
||||||
infobox:Hide()
|
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()
|
infobox:SetScript("OnUpdate", function()
|
||||||
local time = infobox.lastshow + infobox.duration - GetTime()
|
local time = infobox.lastshow + infobox.duration - GetTime()
|
||||||
infobox.timeout:SetValue(time)
|
infobox.timeout:SetValue(time)
|
||||||
|
|
||||||
if GetTime() > infobox.lastshow + infobox.duration then
|
if GetTime() > infobox.lastshow + infobox.duration then
|
||||||
infobox:SetAlpha(infobox:GetAlpha()-0.05)
|
if not infobox.fade:IsPlaying() then infobox.fade:Play() end
|
||||||
|
|
||||||
if infobox:GetAlpha() <= 0.1 then
|
|
||||||
infobox:Hide()
|
|
||||||
infobox:SetAlpha(1)
|
|
||||||
end
|
|
||||||
elseif MouseIsOver(this) then
|
elseif MouseIsOver(this) then
|
||||||
this:SetAlpha(max(0.4, this:GetAlpha() - .1))
|
this:SetAlpha(max(0.4, this:GetAlpha() - .1))
|
||||||
else
|
else
|
||||||
@@ -1214,6 +1218,7 @@ function pfUI.api.CreateInfoBox(text, time, parent, height)
|
|||||||
infobox:SetParent(parent)
|
infobox:SetParent(parent)
|
||||||
|
|
||||||
infobox:SetFrameStrata("FULLSCREEN_DIALOG")
|
infobox:SetFrameStrata("FULLSCREEN_DIALOG")
|
||||||
|
infobox.fade:Stop()
|
||||||
infobox:Show()
|
infobox:Show()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+12
-23
@@ -219,27 +219,6 @@ function pfUI.api.UnitHasAggro(unit)
|
|||||||
return data.state
|
return data.state
|
||||||
end
|
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()
|
function pfUI.uf:UpdateVisibility()
|
||||||
local self = self or this
|
local self = self or this
|
||||||
|
|
||||||
@@ -451,7 +430,6 @@ function pfUI.uf:UpdateConfig()
|
|||||||
f.glow:SetBackdrop(glow2)
|
f.glow:SetBackdrop(glow2)
|
||||||
f.glow:SetPoint("TOPLEFT", f, "TOPLEFT", -6 - default_border,6 + default_border)
|
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:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 6 + default_border,-6 - default_border)
|
||||||
f.glow:SetScript("OnUpdate", pfUI.uf.glow.UpdateGlowAnimation)
|
|
||||||
f.glow:Hide()
|
f.glow:Hide()
|
||||||
|
|
||||||
f.combat:SetSize(tonumber(f.config.squaresize), tonumber(f.config.squaresize))
|
f.combat:SetSize(tonumber(f.config.squaresize), tonumber(f.config.squaresize))
|
||||||
@@ -1482,7 +1460,18 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick)
|
|||||||
end
|
end
|
||||||
|
|
||||||
f.glow = CreateFrame("Frame", nil, f)
|
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 = f.combat:CreateTexture(nil, "OVERLAY")
|
||||||
f.combat.tex:SetAllPoints()
|
f.combat.tex:SetAllPoints()
|
||||||
|
|
||||||
|
|||||||
+12
-9
@@ -36,7 +36,7 @@ pfUI:RegisterModule("castbar", function ()
|
|||||||
cb.bar:SetValue(1)
|
cb.bar:SetValue(1)
|
||||||
end
|
end
|
||||||
if cb.bar.spark then cb.bar.spark:Hide() 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
|
end
|
||||||
|
|
||||||
-- "Spellname (N)" label for an active tradeskill merge — N is the number
|
-- "Spellname (N)" label for an active tradeskill merge — N is the number
|
||||||
@@ -94,8 +94,8 @@ pfUI:RegisterModule("castbar", function ()
|
|||||||
cb.activeName = name
|
cb.activeName = name
|
||||||
cb.isTradeskill = isTradeskill
|
cb.isTradeskill = isTradeskill
|
||||||
cb.delay = (delayMs or 0) / 1000
|
cb.delay = (delayMs or 0) / 1000
|
||||||
|
cb.fade:Stop()
|
||||||
cb:SetAlpha(1)
|
cb:SetAlpha(1)
|
||||||
cb.fadeout = nil
|
|
||||||
|
|
||||||
-- Shield an uninterruptible cast. Not on the player's own bar: the flag is
|
-- 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
|
-- 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:SetPoint("BOTTOM", cb.bar, "BOTTOMLEFT", 0, 0)
|
||||||
cb.bar.spark:Hide()
|
cb.bar.spark:Hide()
|
||||||
|
|
||||||
-- OnUpdate animates the bar fill and fades it out on completion. All
|
-- Fade-out after a cast ends. The bar stays at alpha 0 while idle.
|
||||||
-- state transitions (cast start/stop/interrupt, channel start/stop,
|
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
|
-- pushback) come from the event handler below — we never poll C_Spell
|
||||||
-- here.
|
-- here.
|
||||||
cb:SetScript("OnUpdate", function()
|
cb:SetScript("OnUpdate", function()
|
||||||
@@ -257,15 +263,12 @@ pfUI:RegisterModule("castbar", function ()
|
|||||||
this.tick = GetTime() + 0.020 -- ~50 FPS
|
this.tick = GetTime() + 0.020 -- ~50 FPS
|
||||||
|
|
||||||
if this.drag and this.drag:IsShown() then
|
if this.drag and this.drag:IsShown() then
|
||||||
|
this.fade:Stop()
|
||||||
this:SetAlpha(1)
|
this:SetAlpha(1)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if this.fadeout and this:GetAlpha() > 0 then
|
if this.fade:IsPlaying() then return end
|
||||||
this:SetAlpha(this:GetAlpha() - 0.05)
|
|
||||||
if this:GetAlpha() <= 0 then this.fadeout = nil end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if not this.endTime then
|
if not this.endTime then
|
||||||
if this:GetAlpha() ~= 0 then this:SetAlpha(0) end
|
if this:GetAlpha() ~= 0 then this:SetAlpha(0) end
|
||||||
|
|||||||
+17
-15
@@ -109,24 +109,26 @@ pfUI:RegisterModule("minimap", function ()
|
|||||||
this.highlight.tex:SetPoint("BOTTOMRIGHT", MiniMapMailIcon, "BOTTOMRIGHT", 2, -2)
|
this.highlight.tex:SetPoint("BOTTOMRIGHT", MiniMapMailIcon, "BOTTOMRIGHT", 2, -2)
|
||||||
this.highlight.tex:SetVertexColor(1,.5,.5)
|
this.highlight.tex:SetVertexColor(1,.5,.5)
|
||||||
|
|
||||||
this.highlight:SetScript("OnUpdate", function()
|
-- Blink ten times between .9 and .1, then hide
|
||||||
if not this.count then this.count = 0 end
|
local highlight = this.highlight
|
||||||
if not this.modifier then this.modifier = 1 end
|
highlight:SetAlpha(.9)
|
||||||
if this.count >= 10 then this:Hide() end
|
highlight.blink = highlight:CreateAnimationGroup()
|
||||||
|
for i = 1, 10 do
|
||||||
this:SetAlpha(this:GetAlpha() + this.modifier)
|
local down = highlight.blink:CreateAnimation("Alpha")
|
||||||
|
down:SetChange(-.8)
|
||||||
if this:GetAlpha() <= 0.1 then
|
down:SetDuration(.3)
|
||||||
this.modifier = 0.05
|
down:SetOrder(i * 2 - 1)
|
||||||
this.count = this.count + 1
|
local up = highlight.blink:CreateAnimation("Alpha")
|
||||||
elseif this:GetAlpha() >= 0.9 then
|
up:SetChange(.8)
|
||||||
this.modifier = -0.05
|
up:SetDuration(.3)
|
||||||
end
|
up:SetOrder(i * 2)
|
||||||
end)
|
end
|
||||||
|
highlight.blink:SetScript("OnFinished", function() highlight:Hide() end)
|
||||||
end
|
end
|
||||||
|
|
||||||
this.highlight.count = 0
|
|
||||||
this.highlight:Show()
|
this.highlight:Show()
|
||||||
|
this.highlight.blink:Stop()
|
||||||
|
this.highlight.blink:Play()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Create coordinates text frame with location configurable
|
-- Create coordinates text frame with location configurable
|
||||||
|
|||||||
+11
-18
@@ -34,6 +34,14 @@ pfUI:RegisterModule("tracking", function ()
|
|||||||
pfUI.tracking.icon:SetTexCoord(.08, .92, .08, .92)
|
pfUI.tracking.icon:SetTexCoord(.08, .92, .08, .92)
|
||||||
pfUI.tracking.icon:SetAllPoints(pfUI.tracking)
|
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.menu = CreateFrame("Frame", "pfUIDropDownMenuTracking", nil, "UIDropDownMenuTemplate")
|
||||||
|
|
||||||
pfUI.tracking:RegisterEvent("PLAYER_ENTERING_WORLD")
|
pfUI.tracking:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
@@ -48,19 +56,6 @@ pfUI:RegisterModule("tracking", function ()
|
|||||||
this:RefreshMenu()
|
this:RefreshMenu()
|
||||||
end)
|
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:RegisterForClicks("LeftButtonUp", "RightButtonUp")
|
||||||
pfUI.tracking:SetScript("OnClick", function()
|
pfUI.tracking:SetScript("OnClick", function()
|
||||||
if arg1 == "RightButton" then
|
if arg1 == "RightButton" then
|
||||||
@@ -113,20 +108,18 @@ pfUI:RegisterModule("tracking", function ()
|
|||||||
local texture = GetTrackingTexture()
|
local texture = GetTrackingTexture()
|
||||||
if texture and texture ~= state.texture then
|
if texture and texture ~= state.texture then
|
||||||
state.texture = texture
|
state.texture = texture
|
||||||
pfUI.tracking.pulse = nil
|
pfUI.tracking.pulse:Stop()
|
||||||
pfUI.tracking.icon:SetTexture(texture)
|
pfUI.tracking.icon:SetTexture(texture)
|
||||||
pfUI.tracking.icon:SetVertexColor(1,1,1,1)
|
|
||||||
pfUI.tracking:Show()
|
pfUI.tracking:Show()
|
||||||
elseif not texture then
|
elseif not texture then
|
||||||
state.texture = nil
|
state.texture = nil
|
||||||
|
|
||||||
if pulse and next(state.spells) ~= nil then
|
if pulse and next(state.spells) ~= nil then
|
||||||
pfUI.tracking.pulse = true
|
|
||||||
pfUI.tracking.icon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark")
|
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()
|
pfUI.tracking:Show()
|
||||||
else
|
else
|
||||||
pfUI.tracking.pulse = nil
|
pfUI.tracking.pulse:Stop()
|
||||||
pfUI.tracking:Hide()
|
pfUI.tracking:Hide()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+11
-12
@@ -130,15 +130,6 @@ pfUI:RegisterModule("unlock", function ()
|
|||||||
return frames
|
return frames
|
||||||
end
|
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)
|
local function SaveScale(frame, scale)
|
||||||
frame:SetScale(scale)
|
frame:SetScale(scale)
|
||||||
|
|
||||||
@@ -148,9 +139,8 @@ pfUI:RegisterModule("unlock", function ()
|
|||||||
C.position[frame:GetName()]["scale"] = scale
|
C.position[frame:GetName()]["scale"] = scale
|
||||||
|
|
||||||
frame.drag.text:SetText(T["Scale"] .. ": " .. scale)
|
frame.drag.text:SetText(T["Scale"] .. ": " .. scale)
|
||||||
frame.drag.text:SetAlpha(1)
|
frame.drag.fade:Stop()
|
||||||
|
frame.drag.fade:Play()
|
||||||
frame.drag:SetScript("OnUpdate", DraggerOnUpdate)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function SavePosition(frame)
|
local function SavePosition(frame)
|
||||||
@@ -455,6 +445,15 @@ pfUI:RegisterModule("unlock", function ()
|
|||||||
d.text:SetPoint("CENTER", 0, 0)
|
d.text:SetPoint("CENTER", 0, 0)
|
||||||
d.text:SetFontObject(GameFontWhite)
|
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.frame = f
|
||||||
d.fname = fname
|
d.fname = fname
|
||||||
d.label = label
|
d.label = label
|
||||||
|
|||||||
+26
-8
@@ -63,9 +63,16 @@ pfUI:RegisterModule("xpbar", function ()
|
|||||||
end
|
end
|
||||||
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 function OnLeave(self)
|
||||||
local self = self or this
|
local self = self or this
|
||||||
|
|
||||||
|
self.hover = nil
|
||||||
self.tick = GetTime() + 3.00
|
self.tick = GetTime() + 3.00
|
||||||
GameTooltip:Hide()
|
GameTooltip:Hide()
|
||||||
end
|
end
|
||||||
@@ -82,7 +89,8 @@ local function OnEnter(self)
|
|||||||
mode = "REP"
|
mode = "REP"
|
||||||
end
|
end
|
||||||
|
|
||||||
self:SetAlpha(1)
|
self.hover = true
|
||||||
|
Reveal(self)
|
||||||
|
|
||||||
if mode == "XP" then
|
if mode == "XP" then
|
||||||
local xp, xpmax, exh = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion()
|
local xp, xpmax, exh = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion()
|
||||||
@@ -187,9 +195,11 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.always then return end
|
if self.always then return end
|
||||||
if self:GetAlpha() == 0 or MouseIsOver(self) then return end
|
-- Hover comes from OnEnter/OnLeave, the same mouse focus that reveals the
|
||||||
if ( self.tick or 1) > GetTime() then return else self.tick = GetTime() + .01 end
|
-- bar, so the fade can't restart under the cursor
|
||||||
self:SetAlpha(self:GetAlpha() - .05)
|
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
|
end
|
||||||
|
|
||||||
local function OnEvent(self)
|
local function OnEvent(self)
|
||||||
@@ -210,7 +220,7 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.always then
|
if self.always then
|
||||||
self:SetAlpha(1)
|
Reveal(self)
|
||||||
self:Show()
|
self:Show()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -220,7 +230,7 @@ end
|
|||||||
|
|
||||||
if mode == "XP" then
|
if mode == "XP" then
|
||||||
self.enabled = true
|
self.enabled = true
|
||||||
self:SetAlpha(1)
|
Reveal(self)
|
||||||
self.bar:SetMinMaxValues(0, UnitXPMax("player"))
|
self.bar:SetMinMaxValues(0, UnitXPMax("player"))
|
||||||
self.bar:SetValue(UnitXP("player"))
|
self.bar:SetValue(UnitXP("player"))
|
||||||
if GetXPExhaustion() then
|
if GetXPExhaustion() then
|
||||||
@@ -246,7 +256,7 @@ end
|
|||||||
elseif mode == "PETXP" then
|
elseif mode == "PETXP" then
|
||||||
self.restedbar:Hide()
|
self.restedbar:Hide()
|
||||||
self.enabled = true
|
self.enabled = true
|
||||||
self:SetAlpha(1)
|
Reveal(self)
|
||||||
|
|
||||||
local currXP, nextXP = GetPetExperience()
|
local currXP, nextXP = GetPetExperience()
|
||||||
self.bar:SetMinMaxValues(min(0, currXP), nextXP)
|
self.bar:SetMinMaxValues(min(0, currXP), nextXP)
|
||||||
@@ -264,7 +274,7 @@ end
|
|||||||
local name, standingID, barMin, barMax, barValue = GetRepDisplay(self.factionID)
|
local name, standingID, barMin, barMax, barValue = GetRepDisplay(self.factionID)
|
||||||
if name then
|
if name then
|
||||||
self.enabled = true
|
self.enabled = true
|
||||||
self:SetAlpha(1)
|
Reveal(self)
|
||||||
|
|
||||||
barMax = barMax - barMin
|
barMax = barMax - barMin
|
||||||
barValue = barValue - barMin
|
barValue = barValue - barMin
|
||||||
@@ -362,6 +372,14 @@ end
|
|||||||
-- auto hide
|
-- auto hide
|
||||||
b:EnableMouse(true)
|
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:RegisterEvent("FACTION_STANDING_CHANGED")
|
||||||
b:RegisterUnitEvent("UNIT_PET", "player")
|
b:RegisterUnitEvent("UNIT_PET", "player")
|
||||||
b:RegisterUnitEvent("UNIT_LEVEL", "player")
|
b:RegisterUnitEvent("UNIT_LEVEL", "player")
|
||||||
|
|||||||
Reference in New Issue
Block a user