Skip to content

Commit c527982

Browse files
committed
Initial commit
0 parents  commit c527982

2 files changed

Lines changed: 124 additions & 0 deletions

File tree

jButtonFlash.lua

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
-- locals and speed
2+
local AddonName, Addon = ...
3+
4+
local _G = _G
5+
6+
local GetActionButtonForID = GetActionButtonForID
7+
8+
local TEXTURE_OFFSET = 3
9+
10+
-- main
11+
function Addon:Load()
12+
do
13+
local eventHandler = CreateFrame('Frame', nil)
14+
15+
-- set OnEvent handler
16+
eventHandler:SetScript('OnEvent', function(handler, ...)
17+
self:OnEvent(...)
18+
end)
19+
20+
eventHandler:RegisterEvent('PLAYER_LOGIN')
21+
end
22+
end
23+
24+
-- frame events
25+
function Addon:OnEvent(event, ...)
26+
local action = self[event]
27+
28+
if (action) then
29+
action(self, ...)
30+
end
31+
end
32+
33+
function Addon:PLAYER_LOGIN()
34+
self:SetupButtonFlash()
35+
self:HookActionEvents()
36+
end
37+
38+
function Addon:SetupButtonFlash()
39+
local frame = CreateFrame('Frame', nil)
40+
frame:SetFrameStrata('TOOLTIP')
41+
42+
local texture = frame:CreateTexture()
43+
texture:SetTexture([[Interface\Cooldown\star4]])
44+
texture:SetAlpha(0)
45+
texture:SetAllPoints(frame)
46+
texture:SetBlendMode('ADD')
47+
texture:SetDrawLayer('OVERLAY', 7)
48+
49+
local animationGroup = texture:CreateAnimationGroup()
50+
51+
local alpha = animationGroup:CreateAnimation('Alpha')
52+
alpha:SetFromAlpha(0)
53+
alpha:SetToAlpha(1)
54+
alpha:SetDuration(0)
55+
alpha:SetOrder(1)
56+
57+
local scale1 = animationGroup:CreateAnimation('Scale')
58+
scale1:SetScale(1.5, 1.5)
59+
scale1:SetDuration(0)
60+
scale1:SetOrder(1)
61+
62+
local scale2 = animationGroup:CreateAnimation('Scale')
63+
scale2:SetScale(0, 0)
64+
scale2:SetDuration(.3)
65+
scale2:SetOrder(2)
66+
67+
local rotation2 = animationGroup:CreateAnimation('Rotation')
68+
rotation2:SetDegrees(90)
69+
rotation2:SetDuration(.3)
70+
rotation2:SetOrder(2)
71+
72+
self.frame = frame
73+
self.animationGroup = animationGroup
74+
end
75+
76+
-- hooks
77+
do
78+
local function Button_ActionButtonDown(id)
79+
Addon:ActionButtonDown(id)
80+
end
81+
82+
local function Button_MultiActionButtonDown(bar, id)
83+
Addon:MultiActionButtonDown(bar, id)
84+
end
85+
86+
function Addon:HookActionEvents()
87+
hooksecurefunc('ActionButtonDown', Button_ActionButtonDown)
88+
hooksecurefunc('MultiActionButtonDown', Button_MultiActionButtonDown)
89+
end
90+
end
91+
92+
function Addon:ActionButtonDown(id)
93+
local button = GetActionButtonForID(id)
94+
if (button) then
95+
self:AnimateButton(button)
96+
end
97+
end
98+
99+
function Addon:MultiActionButtonDown(bar, id)
100+
local button = _G[bar..'Button'..id]
101+
if (button) then
102+
self:AnimateButton(button)
103+
end
104+
end
105+
106+
function Addon:AnimateButton(button)
107+
if (not button:IsVisible()) then return end
108+
109+
self.frame:SetPoint('TOPLEFT', button, 'TOPLEFT', -TEXTURE_OFFSET, TEXTURE_OFFSET)
110+
self.frame:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', TEXTURE_OFFSET, -TEXTURE_OFFSET)
111+
112+
self.animationGroup:Stop()
113+
self.animationGroup:Play()
114+
end
115+
116+
-- call
117+
Addon:Load()

jButtonFlash.toc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Interface: 80100
2+
## Title: jButtonFlash
3+
## Notes: Add flash animation to pressed action button
4+
## Version: 1.5
5+
## Author: jwldnr
6+
7+
jButtonFlash.lua

0 commit comments

Comments
 (0)