@@ -3,7 +3,72 @@ local AddonName, Addon = ...
33
44local _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
873local TEXTURE_OFFSET = 3
974
2590function Addon :OnEvent (event , ...)
2691 local action = self [event ]
2792
28- if ( action ) then
93+ if action then
2994 action (self , ... )
3095 end
3196end
@@ -35,6 +100,18 @@ function Addon:PLAYER_LOGIN()
35100 self :HookActionEvents ()
36101end
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+
38115function 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
90166end
91167
92168function 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
97175end
98176
99177function 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
104184end
105185
106186function 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 ()
0 commit comments