Skip to content

Commit 6284583

Browse files
committed
Add addon Bartender4 support
1 parent 9c92cf8 commit 6284583

3 files changed

Lines changed: 73 additions & 28 deletions

File tree

changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [1.0.0] - 2025-01-07
8+
## [1.1.0-fondlez] - 2025-03-22
9+
10+
### Added
11+
- addon Bartender4 support
12+
13+
## [1.0.0-fondlez] - 2025-01-07
914

1015
Initial upload.
1116

jButtonFlash.lua

Lines changed: 63 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
-- locals and speed
21
local AddonName, Addon = ...
3-
42
local _G = _G
53

64
--------------------------------------------------------------------------------
@@ -68,9 +66,24 @@ else
6866
end
6967
end
7068
end
69+
70+
local setAlphaDelta
71+
if is_wotlk or is_cata or is_mop then
72+
setAlphaDelta = function(alpha)
73+
alpha:SetChange(1)
74+
end
75+
else
76+
setAlphaDelta = function(alpha)
77+
alpha:SetFromAlpha(0)
78+
alpha:SetToAlpha(1)
79+
end
80+
end
81+
7182
--------------------------------------------------------------------------------
7283

73-
local TEXTURE_OFFSET = 3
84+
local BARTENDER4_NAME = "Bartender4"
85+
local BARTENDER4_BUTTONS_MAX = 120
86+
local BARTENDER4_BUTTONS_PET_MAX = 10
7487

7588
-- main
7689
function Addon:Load()
@@ -96,19 +109,14 @@ function Addon:OnEvent(event, ...)
96109
end
97110

98111
function Addon:PLAYER_LOGIN()
112+
-- Blizzard buttons
99113
self:SetupButtonFlash()
100114
self:HookActionEvents()
101-
end
102-
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)
115+
116+
-- Addon "Bartender4" buttons
117+
local bt4 = IsAddOnLoaded(BARTENDER4_NAME)
118+
if bt4 then
119+
self:HookBartender4Buttons()
112120
end
113121
end
114122

@@ -150,6 +158,7 @@ function Addon:SetupButtonFlash()
150158
end
151159

152160
-- hooks
161+
-- - Blizzard buttons
153162
do
154163
local function Button_ActionButtonDown(id)
155164
Addon:ActionButtonDown(id)
@@ -165,6 +174,33 @@ do
165174
end
166175
end
167176

177+
-- - Bartender4 support
178+
do
179+
local function Button_OnMouseDown(self, _)
180+
Addon:AnimateButton(self)
181+
end
182+
183+
-- Note. using RegisterForClicks and OnClick can result in extra effects
184+
-- such as sounds for each part of the click. So, use OnMouseDown instead
185+
function Addon:HookBartender4Buttons()
186+
-- Player action buttons
187+
for i = 1, BARTENDER4_BUTTONS_MAX do
188+
local button = _G["BT4Button" .. i]
189+
if button then
190+
button:HookScript("OnMouseDown", Button_OnMouseDown)
191+
end
192+
end
193+
194+
-- Pet action buttons
195+
for i = 1, BARTENDER4_BUTTONS_PET_MAX do
196+
local button = _G["BT4PetButton" .. i]
197+
if button then
198+
button:HookScript("OnMouseDown", Button_OnMouseDown)
199+
end
200+
end
201+
end
202+
end
203+
168204
function Addon:ActionButtonDown(id)
169205
if not id then return end
170206

@@ -183,17 +219,21 @@ function Addon:MultiActionButtonDown(bar, id)
183219
end
184220
end
185221

186-
function Addon:AnimateButton(button)
187-
if not button:IsVisible() then return end
222+
do
223+
local TEXTURE_OFFSET = 3
224+
225+
function Addon:AnimateButton(button)
226+
if not button:IsVisible() then return end
188227

189-
self.frame:SetPoint('TOPLEFT', button, 'TOPLEFT', -TEXTURE_OFFSET,
190-
TEXTURE_OFFSET)
191-
self.frame:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', TEXTURE_OFFSET,
192-
-TEXTURE_OFFSET)
228+
self.frame:SetPoint('TOPLEFT', button, 'TOPLEFT', -TEXTURE_OFFSET,
229+
TEXTURE_OFFSET)
230+
self.frame:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', TEXTURE_OFFSET,
231+
-TEXTURE_OFFSET)
193232

194-
self.animationGroup:Stop()
195-
self.animationGroup:Play()
233+
self.animationGroup:Stop()
234+
self.animationGroup:Play()
235+
end
196236
end
197237

198-
-- call
238+
-- begin
199239
Addon:Load()

jButtonFlash.toc

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

1313
jButtonFlash.lua

0 commit comments

Comments
 (0)