Skip to content

Commit 8724a8e

Browse files
committed
Backport to WoD, MoP, Cata and WotLK game clients.
1 parent c527982 commit 8724a8e

2 files changed

Lines changed: 100 additions & 12 deletions

File tree

jButtonFlash.lua

Lines changed: 92 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,72 @@ local AddonName, Addon = ...
33

44
local _G = _G
55

6-
local GetActionButtonForID = GetActionButtonForID
6+
--------------------------------------------------------------------------------
7+
-- client compatibility
8+
--------------------------------------------------------------------------------
9+
local display_version, build_number, build_date, ui_version = GetBuildInfo()
10+
11+
-- AnimationGroup subfeatures not supported earlier than 3.1.0 client.
12+
if not ui_version or ui_version < 30100 then return end
13+
14+
local is_wotlk, is_cata, is_wod, is_legion_or_later
15+
if ui_version >= 30100 and ui_version <= 30300 then
16+
is_wotlk = true
17+
elseif ui_version >= 40000 and ui_version <= 40300 then
18+
is_cata = true
19+
elseif ui_version >= 50001 and ui_version <= 50400 then
20+
is_mop = true
21+
elseif ui_version >= 60000 and ui_version <= 60200 then
22+
is_wod = true
23+
else
24+
is_legion_or_later = true
25+
end
26+
27+
local GetActionButtonForID
28+
if is_wotlk or is_cata then
29+
local VEHICLE_MAX_ACTIONBUTTONS = _G.VEHICLE_MAX_ACTIONBUTTONS --6
30+
31+
GetActionButtonForID = function(id)
32+
if VehicleMenuBar:IsShown() and id <= VEHICLE_MAX_ACTIONBUTTONS then
33+
return _G["VehicleMenuBarActionButton"..id]
34+
elseif BonusActionBarFrame:IsShown() then
35+
return _G["BonusActionButton"..id]
36+
else
37+
return _G["ActionButton"..id]
38+
end
39+
end
40+
else
41+
local NUM_OVERRIDE_BUTTONS = _G.NUM_OVERRIDE_BUTTONS --6
42+
local isInPetBattle = _G.C_PetBattles.IsInBattle
43+
local function isPetBattle()
44+
if isInPetBattle() and PetBattleFrame then
45+
return true
46+
end
47+
48+
return false
49+
end
50+
51+
if is_mop or is_wod then
52+
GetActionButtonForID = function(id)
53+
if isPetBattle() then return end
54+
55+
if OverrideActionBar and OverrideActionBar:IsShown() then
56+
if id > NUM_OVERRIDE_BUTTONS then return end
57+
return _G["OverrideActionBarButton"..id]
58+
else
59+
return _G["ActionButton"..id]
60+
end
61+
end
62+
-- Legion or later.
63+
else
64+
local original = _G.GetActionButtonForID
65+
GetActionButtonForID = function(id)
66+
if isPetBattle() then return end
67+
return original(id)
68+
end
69+
end
70+
end
71+
--------------------------------------------------------------------------------
772

873
local TEXTURE_OFFSET = 3
974

@@ -25,7 +90,7 @@ end
2590
function Addon:OnEvent(event, ...)
2691
local action = self[event]
2792

28-
if (action) then
93+
if action then
2994
action(self, ...)
3095
end
3196
end
@@ -35,6 +100,18 @@ function Addon:PLAYER_LOGIN()
35100
self:HookActionEvents()
36101
end
37102

103+
local setAlphaDelta
104+
if is_wotlk or is_cata or is_mop then
105+
setAlphaDelta = function(alpha)
106+
alpha:SetChange(1)
107+
end
108+
else
109+
setAlphaDelta = function(alpha)
110+
alpha:SetFromAlpha(0)
111+
alpha:SetToAlpha(1)
112+
end
113+
end
114+
38115
function Addon:SetupButtonFlash()
39116
local frame = CreateFrame('Frame', nil)
40117
frame:SetFrameStrata('TOOLTIP')
@@ -49,8 +126,7 @@ function Addon:SetupButtonFlash()
49126
local animationGroup = texture:CreateAnimationGroup()
50127

51128
local alpha = animationGroup:CreateAnimation('Alpha')
52-
alpha:SetFromAlpha(0)
53-
alpha:SetToAlpha(1)
129+
setAlphaDelta(alpha)
54130
alpha:SetDuration(0)
55131
alpha:SetOrder(1)
56132

@@ -90,24 +166,30 @@ do
90166
end
91167

92168
function Addon:ActionButtonDown(id)
169+
if not id then return end
170+
93171
local button = GetActionButtonForID(id)
94-
if (button) then
172+
if button then
95173
self:AnimateButton(button)
96174
end
97175
end
98176

99177
function Addon:MultiActionButtonDown(bar, id)
100-
local button = _G[bar..'Button'..id]
101-
if (button) then
178+
if not bar or not id then return end
179+
180+
local button = _G[bar.."Button"..id]
181+
if button then
102182
self:AnimateButton(button)
103183
end
104184
end
105185

106186
function Addon:AnimateButton(button)
107-
if (not button:IsVisible()) then return end
187+
if not button:IsVisible() then return end
108188

109-
self.frame:SetPoint('TOPLEFT', button, 'TOPLEFT', -TEXTURE_OFFSET, TEXTURE_OFFSET)
110-
self.frame:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', TEXTURE_OFFSET, -TEXTURE_OFFSET)
189+
self.frame:SetPoint('TOPLEFT', button, 'TOPLEFT', -TEXTURE_OFFSET,
190+
TEXTURE_OFFSET)
191+
self.frame:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', TEXTURE_OFFSET,
192+
-TEXTURE_OFFSET)
111193

112194
self.animationGroup:Stop()
113195
self.animationGroup:Play()

jButtonFlash.toc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
## Interface: 80100
22
## Title: jButtonFlash
33
## Notes: Add flash animation to pressed action button
4-
## Version: 1.5
5-
## Author: jwldnr
4+
## Version: 1.0.0-fondlez
5+
## Author: fondlez
6+
## X-Website: http://github.com/fondlez/jButtonFlash
7+
## X-Category: Action Bars
8+
## OG-Author: Jean Alexander Woldner aka. jwldnr
9+
## OG-Repo: https://github.com/woldner/jButtonFlash
10+
## OG-Git-Tag: 8ea733548c6032eba253078de70ac564cd10e7a8
11+
## DefaultState: enabled
612

713
jButtonFlash.lua

0 commit comments

Comments
 (0)