/trunk
local MIN_ALPHA = 0.4 |
local MAX_ALPHA = 1 |
local FADE_IN_ALPHA = 1 |
local FADE_IN_DELAY = 0.1 |
local FADE_IN_DURATION = 0.2 |
local hasMouseFocus = false |
local FADE_OUT_ALPHA = 0.4 |
local FADE_OUT_DELAY = 0.2 |
local FADE_OUT_DURATION = 0.4 |
local GetMouseFocus = GetMouseFocus |
local WorldFrame = WorldFrame |
WatchFrame:SetAlpha(MIN_ALPHA) |
local fadeGroup = WatchFrame:CreateAnimationGroup() |
local fadeAnim = fadeGroup:CreateAnimation("Alpha") |
fadeGroup:SetLooping("NONE") |
fadeGroup:SetScript("OnFinished", function(self) WatchFrame:SetAlpha(self.targetAlpha) end) |
WatchFrame:SetAlpha(FADE_OUT_ALPHA) |
local fadeIn = WatchFrame:CreateAnimationGroup() |
fadeIn:SetScript("OnFinished", function(self) WatchFrame:SetAlpha(MAX_ALPHA) end) |
fadeIn.anim = fadeIn:CreateAnimation("Alpha") |
fadeIn.anim:SetChange(MAX_ALPHA - MIN_ALPHA) |
fadeIn.anim:SetDuration(0.2) |
fadeIn.anim:SetStartDelay(0.1) |
fadeIn.anim:SetSmoothing("OUT") |
WatchFrame.FadeInAnimation = fadeIn |
local fadeOut = WatchFrame:CreateAnimationGroup() |
fadeOut:SetScript("OnFinished", function(self) WatchFrame:SetAlpha(MIN_ALPHA) end) |
fadeOut.anim = fadeOut:CreateAnimation("Alpha") |
fadeOut.anim:SetChange(MIN_ALPHA - MAX_ALPHA) |
fadeOut.anim:SetDuration(0.4) |
fadeOut.anim:SetStartDelay(0.2) |
fadeOut.anim:SetSmoothing("IN") |
WatchFrame.FadeOutAnimation = fadeOut |
local descendants = setmetatable({}, { __index = function(t, f) |
local parent = f:GetParent() |
while parent do |
return false |
end }) |
local hasMouseFocus = false |
WatchFrame:HookScript("OnUpdate", function(self, elapsed) |
local mouseFocus = GetMouseFocus() |
if not mouseFocus then |
return |
end |
hasMouseFocus = gotMouseFocus |
fadeOut:Stop() |
fadeIn:Stop() |
fadeGroup:Stop() |
if gotMouseFocus then |
fadeIn:Play() |
-- Fade in |
local a = floor(self:GetAlpha() * 100 + 0.5) / 100 |
local d = FADE_IN_ALPHA - a |
local t = (FADE_IN_DURATION * d) / (FADE_IN_ALPHA - FADE_OUT_ALPHA) |
if d < 0.05 or t < 0.05 then |
-- Don't bother animating |
return self:SetAlpha(FADE_IN_ALPHA) |
end |
fadeAnim:SetChange(d) |
fadeAnim:SetStartDelay(a == FADE_OUT_ALPHA and FADE_IN_DELAY or 0) |
fadeAnim:SetDuration(t) |
fadeGroup.targetAlpha = FADE_IN_ALPHA |
fadeGroup:Play() |
else |
fadeOut:Play() |
-- Fade out |
local a = floor(self:GetAlpha() * 100 + 0.5) / 100 |
local d = a - FADE_OUT_ALPHA |
local t = (FADE_OUT_DURATION * d) / (FADE_IN_ALPHA - FADE_OUT_ALPHA) |
if d < 0.05 or t < 0.05 then |
-- Don't bother animating |
return self:SetAlpha(FADE_OUT_ALPHA) |
end |
fadeAnim:SetChange(-d) |
fadeAnim:SetStartDelay(a == FADE_IN_ALPHA and FADE_OUT_DELAY or 0) |
fadeAnim:SetDuration(t) |
fadeGroup.targetAlpha = FADE_OUT_ALPHA |
fadeGroup:Play() |
end |
end) |
hooksecurefunc("QuestLogTitleButton_OnClick", function(self) |
if IsModifiedClick() and self.isHeader then |
local index = self:GetID() |
local _, _, _, _, _, isCollapsed = GetQuestLogTitle(index) |
if isCollapsed then |
ExpandQuestHeader(index) |
end |
local tracked = IsQuestWatched(index + 1) |
for i = index + 1, GetNumQuestLogEntries() do |
local _, _, _, _, isHeader = GetQuestLogTitle(i) |
if isHeader then |
break |
elseif tracked then |
RemoveQuestWatch(i) |
else |
AddQuestWatch(i) |
end |
end |
QuestLog_Update() |
WatchFrame_Update() |
end |
end) |
## X-License: See the accompanying LICENSE file for details. |
Addon.lua |
Animations.lua |