Basically this script makes your buttons light up with an animation when you press them. It was called SnowfallKeypress but it seems nobody is really keeping it up to date anymore. I have used this script forever, and I recently made some small changes to it for it to work in Legion.
However, it does not work properly for buttons which are on any of the MultiBars.
On all the buttons at the MultiBars (MultiBarBottomLeftButton11 is one of them, for example), the animation from this script is not shown at the highest layer (even though it looks to be). Since the animation is a bit larger than the actionbar buttons you can see the outer part of it when you press a button.
I have tried to change the strata of the frame where the animation is played, and it's level. I have also looked at it with /fstack and came to the conclusion that clicks on ActionButtons 1-12 behave the same way as clicks on the MultiBars. The difference would be a layer called *buttonName*FloatingBG, which appears on buttons at the MultiBars. However, when I tried hiding it, it made no difference.
Pictures of snowfall working on Frostbolt (ActionButton1), and then not working properly on Ice Nova (MultiBarBottomLeftButton5).
Not working vs working example
I think the problem is in the animate function. I would be happy if you could help me figure out what is causing this problem. I have tried lot of different functions to try to solve this issue, but nothing really seems to work.
Here's the code:
Code:
local animationsCount, animations = 5, {}
local animationNum = 1
local replace = string.gsub
local frame, texture, animationGroup, alpha1, scale1, scale2, rotation2
for i = 1, animationsCount do
frame = CreateFrame("Frame")
texture = frame:CreateTexture()
texture:SetTexture([[Interface\Cooldown\star4]])
texture:SetAlpha(0)
texture:SetAllPoints()
texture:SetBlendMode("ADD")
-- no difference
--texture:SetDrawLayer("ARTWORK", 7)
--print(texture:GetDrawLayer())
animationGroup = texture:CreateAnimationGroup()
alpha1 = animationGroup:CreateAnimation("Alpha")
alpha1:SetFromAlpha(0)
alpha1:SetToAlpha(1)
alpha1:SetDuration(0)
alpha1:SetOrder(1)
scale1 = animationGroup:CreateAnimation("Scale")
scale1:SetFromScale(1.0, 1.0) -- looks better/is bigger this way
scale1:SetToScale(1.5, 1.5)
--scale1:SetScale(1.5, 1.5) -- original
scale1:SetDuration(0)
scale1:SetOrder(1)
scale2 = animationGroup:CreateAnimation("Scale")
--scale2:SetScale(0, 0) -- original
scale2:SetFromScale(1.5, 1.5)
scale2:SetToScale(0,0)
scale2:SetDuration(0.3)
scale2:SetOrder(2)
rotation2 = animationGroup:CreateAnimation("Rotation")
rotation2:SetDegrees(90)
rotation2:SetDuration(0.3)
rotation2:SetOrder(2)
animations[i] = {frame = frame, animationGroup = animationGroup}
end
local animate = function(button)
if not button:IsVisible() then
return true
end
local animation = animations[animationNum]
local frame = animation.frame
local animationGroup = animation.animationGroup
--[[
local FloatingBG = _G[button:GetName() .. 'FloatingBG']
if FloatingBG then
FloatingBG:Hide()
end
-- on multibars there was a weird layer called barname+FloatingBG
-- this didn't make a difference though
]]
frame:SetFrameStrata(button:GetFrameStrata())
frame:SetFrameLevel(button:GetFrameLevel() + 10)
frame:SetAllPoints(button)
animationGroup:Stop()
animationGroup:Play()
animationNum = (animationNum % animationsCount) + 1
return true
end
-- didn't run on PLAYER_ENTERING_WORLD
--hooksecurefunc('ActionButton_UpdateHotkeys', function(button, buttonType)
hooksecurefunc('ActionButton_Update', function(button, actionbuttonType)
if InCombatLockdown() then return end -- no animation while in CC
if not button.hooked then
local id, actionButtonType, key
if not actionButtonType then
actionButtonType = button:GetAttribute('binding') or string.upper(button:GetName())
-- here the button names are translated to work with the GetBindingKey function
-- no problems here
actionButtonType = replace(actionButtonType, 'BOTTOMLEFT', '1')
actionButtonType = replace(actionButtonType, 'BOTTOMRIGHT', '2')
actionButtonType = replace(actionButtonType, 'RIGHT', '3')
actionButtonType = replace(actionButtonType, 'LEFT', '4')
actionButtonType = replace(actionButtonType, 'MULTIBAR', 'MULTIACTIONBAR')
end
local key = GetBindingKey(actionButtonType)
if key then
button:RegisterForClicks("AnyDown")
SetOverrideBinding(button, true, key, 'CLICK '..button:GetName()..':LeftButton')
-- SetOverrideBindingClick(button, true, key, button:GetName(), "LeftButton") -- same thing...
end
button.AnimateThis = animate
SecureHandlerWrapScript(button, "OnClick", button, [[ control:CallMethod("AnimateThis", self) ]])
button.hooked = true
end
-- this whole segment seems to work, the problem lies in the animate function most likely
end)