@@ -5,20 +5,25 @@ local _G = _G
5
5
local pairs = pairs
6
6
local unpack = unpack
7
7
local tinsert = tinsert
8
+
8
9
local CreateFrame = CreateFrame
9
10
local GetBindingKey = GetBindingKey
10
- local hooksecurefunc = hooksecurefunc
11
11
local InCombatLockdown = InCombatLockdown
12
+ local hooksecurefunc = hooksecurefunc
13
+
12
14
local ActionButton_UpdateCooldown = ActionButton_UpdateCooldown
13
15
14
- local ExtraActionBarHolder , ZoneAbilityHolder
15
- local ExtraButtons = {}
16
+ local extraBtns , extraHooked , ExtraActionBarHolder , ZoneAbilityHolder = {}, {}
16
17
17
18
function AB :ExtraButtons_BossStyle (frame )
18
19
local button = frame .button
19
20
if button and not button .IsSkinned then
20
21
AB :StyleButton (button , true ) -- registers cooldown too
21
- ActionButton_UpdateCooldown (button ) -- the cooldown is already fired sometimes?
22
+
23
+ -- the cooldown is already fired sometimes?
24
+ if ActionButton_UpdateCooldown then
25
+ ActionButton_UpdateCooldown (button )
26
+ end
22
27
23
28
button .icon :SetDrawLayer (' ARTWORK' , - 1 )
24
29
button :SetTemplate ()
@@ -28,12 +33,13 @@ function AB:ExtraButtons_BossStyle(frame)
28
33
button :HookScript (' OnLeave' , AB .ExtraButtons_OnLeave )
29
34
30
35
button .HotKey :SetText (GetBindingKey (button .commandName ))
36
+
31
37
AB :FixKeybindText (button )
32
38
AB :FixKeybindColor (button )
33
39
34
40
AB :ExtraButtons_BossAlpha (button )
35
41
36
- tinsert (ExtraButtons , button )
42
+ tinsert (extraBtns , button )
37
43
38
44
button .IsSkinned = true
39
45
end
71
77
72
78
function AB :ExtraButtons_BossAlpha (button )
73
79
local bossAlpha = E .db .actionbar .extraActionButton .alpha
74
- button :SetAlpha (bossAlpha )
80
+ button :SetAlpha (bossAlpha or 1 )
75
81
76
82
if button .style then
77
83
button .style :SetAlpha (not E .db .actionbar .extraActionButton .clean and bossAlpha or 0 )
78
84
end
79
85
end
80
86
87
+ function AB :ExtraButtons_BossParent (parent )
88
+ if parent ~= ExtraActionBarHolder and not AB .NeedsReparentExtraButtons then
89
+ AB :ExtraButtons_Reparent ()
90
+ end
91
+ end
92
+
81
93
function AB :ExtraButtons_ZoneAlpha ()
82
94
local zoneAlpha = E .db .actionbar .zoneActionButton .alpha
83
95
_G .ZoneAbilityFrame .Style :SetAlpha (not E .db .actionbar .zoneActionButton .clean and zoneAlpha or 0 )
@@ -102,114 +114,165 @@ function AB:ExtraButtons_OnLeave()
102
114
end
103
115
104
116
function AB :ExtraButtons_GlobalFade ()
105
- ExtraActionBarHolder :SetParent (E .db .actionbar .extraActionButton .inheritGlobalFade and AB .fadeParent or E .UIParent )
106
- ZoneAbilityHolder :SetParent (E .db .actionbar .zoneActionButton .inheritGlobalFade and AB .fadeParent or E .UIParent )
117
+ if ExtraActionBarHolder then
118
+ ExtraActionBarHolder :SetParent (E .db .actionbar .extraActionButton .inheritGlobalFade and AB .fadeParent or E .UIParent )
119
+ end
120
+
121
+ if ZoneAbilityHolder then
122
+ ZoneAbilityHolder :SetParent (E .db .actionbar .zoneActionButton .inheritGlobalFade and AB .fadeParent or E .UIParent )
123
+ end
107
124
end
108
125
109
126
function AB :ExtraButtons_UpdateAlpha ()
110
127
if not E .private .actionbar .enable then return end
111
128
112
- for _ , button in pairs (ExtraButtons ) do
129
+ for _ , button in pairs (extraBtns ) do
113
130
AB :ExtraButtons_BossAlpha (button )
114
131
end
115
132
116
- local zoneAlpha = AB :ExtraButtons_ZoneAlpha ()
117
- for button in _G .ZoneAbilityFrame .SpellButtonContainer :EnumerateActive () do
118
- button :SetAlpha (zoneAlpha )
133
+ if _G .ZoneAbilityFrame then
134
+ local zoneAlpha = AB :ExtraButtons_ZoneAlpha ()
135
+ for button in _G .ZoneAbilityFrame .SpellButtonContainer :EnumerateActive () do
136
+ button :SetAlpha (zoneAlpha )
137
+ end
119
138
end
120
139
end
121
140
122
141
function AB :ExtraButtons_UpdateScale ()
123
142
if not E .private .actionbar .enable then return end
124
143
125
- AB :ExtraButtons_ZoneScale ()
144
+ if _G .ZoneAbilityFrame then
145
+ AB :ExtraButtons_ZoneScale ()
146
+ end
126
147
127
- local scale = E .db .actionbar .extraActionButton .scale
128
- _G .ExtraActionBarFrame :SetScale (scale * E .uiscale )
129
- _G .ExtraActionBarFrame :SetIgnoreParentScale (true )
148
+ if _G .ExtraActionBarFrame then
149
+ local scale = E .db .actionbar .extraActionButton .scale
150
+ _G .ExtraActionBarFrame :SetScale (scale * E .uiscale )
151
+ _G .ExtraActionBarFrame :SetIgnoreParentScale (true )
130
152
131
- local width , height = _G .ExtraActionBarFrame .button :GetSize ()
132
- ExtraActionBarHolder :SetSize (width * scale , height * scale )
153
+ local width , height = _G .ExtraActionBarFrame .button :GetSize ()
154
+ ExtraActionBarHolder :SetSize (width * scale , height * scale )
155
+ end
133
156
end
134
157
135
158
function AB :ExtraButtons_ZoneScale ()
136
159
if not E .private .actionbar .enable then return end
137
160
138
- local scale = E .db .actionbar .zoneActionButton .scale
139
- _G .ZoneAbilityFrame .Style :SetScale (scale )
140
- _G .ZoneAbilityFrame .SpellButtonContainer :SetScale (scale )
161
+ if _G .ZoneAbilityFrame then
162
+ local scale = E .db .actionbar .zoneActionButton .scale
163
+ _G .ZoneAbilityFrame .Style :SetScale (scale )
164
+ _G .ZoneAbilityFrame .SpellButtonContainer :SetScale (scale )
165
+
166
+ local width , height = _G .ZoneAbilityFrame .SpellButtonContainer :GetSize ()
167
+ ZoneAbilityHolder :SetSize (width * scale , height * scale )
168
+ end
169
+ end
141
170
142
- local width , height = _G .ZoneAbilityFrame .SpellButtonContainer :GetSize ()
143
- ZoneAbilityHolder :SetSize (width * scale , height * scale )
171
+ function AB :ExtraButtons_ZoneParent (parent )
172
+ if parent ~= ZoneAbilityHolder and not AB .NeedsReparentExtraButtons then
173
+ AB :ExtraButtons_Reparent ()
174
+ end
144
175
end
145
176
146
177
function AB :ExtraButtons_Reparent ()
147
178
if InCombatLockdown () then
148
179
AB .NeedsReparentExtraButtons = true
180
+
149
181
AB :RegisterEvent (' PLAYER_REGEN_ENABLED' )
182
+
150
183
return
151
184
end
152
185
153
- _G .ZoneAbilityFrame :SetParent (ZoneAbilityHolder )
154
- _G .ExtraActionBarFrame :SetParent (ExtraActionBarHolder )
186
+ if _G .ZoneAbilityFrame then
187
+ _G .ZoneAbilityFrame :SetParent (ZoneAbilityHolder )
188
+ end
189
+
190
+ if _G .ExtraActionBarFrame then
191
+ _G .ExtraActionBarFrame :SetParent (ExtraActionBarHolder )
192
+ end
155
193
end
156
194
157
- function AB :SetupExtraButton ()
158
- local ExtraAbilityContainer = _G .ExtraAbilityContainer
195
+ function AB :HandleExtraButton ()
159
196
local ExtraActionBarFrame = _G .ExtraActionBarFrame
197
+ if not ExtraActionBarFrame then return end
198
+
199
+ if not extraHooked [ExtraActionBarFrame ] then
200
+ hooksecurefunc (ExtraActionBarFrame , ' SetParent' , AB .ExtraButtons_BossParent )
201
+
202
+ extraHooked [ExtraActionBarFrame ] = true
203
+ end
204
+
205
+ ExtraActionBarFrame :ClearAllPoints ()
206
+ ExtraActionBarFrame :SetAllPoints ()
207
+ ExtraActionBarFrame .ignoreInLayout = true
208
+ end
209
+
210
+ function AB :HandleZoneAbility ()
160
211
local ZoneAbilityFrame = _G .ZoneAbilityFrame
212
+ if not ZoneAbilityFrame then return end
161
213
162
- ExtraActionBarHolder = CreateFrame (' Frame' , nil , E .UIParent )
163
- ExtraActionBarHolder :Point (' BOTTOM' , E .UIParent , ' BOTTOM' , - 150 , 300 )
164
- E .FrameLocks [ExtraActionBarHolder ] = true
214
+ if not extraHooked [ZoneAbilityFrame ] then
215
+ ZoneAbilityHolder = CreateFrame (' Frame' , nil , E .UIParent )
216
+ ZoneAbilityHolder :Point (' BOTTOM' , E .UIParent , ' BOTTOM' , 150 , 300 )
217
+ E .FrameLocks [ZoneAbilityHolder ] = true
165
218
166
- ZoneAbilityHolder = CreateFrame (' Frame' , nil , E .UIParent )
167
- ZoneAbilityHolder :Point (' BOTTOM' , E .UIParent , ' BOTTOM' , 150 , 300 )
168
- E .FrameLocks [ZoneAbilityHolder ] = true
219
+ E :CreateMover (ZoneAbilityHolder , ' ZoneAbility' , L [" Zone Ability" ], nil , nil , nil , ' ALL,ACTIONBARS' , nil , ' actionbar,extraButtons,extraActionButton' )
169
220
170
- ZoneAbilityFrame .SpellButtonContainer .holder = ZoneAbilityHolder
171
- ZoneAbilityFrame .SpellButtonContainer :HookScript (' OnEnter' , AB .ExtraButtons_OnEnter )
172
- ZoneAbilityFrame .SpellButtonContainer :HookScript (' OnLeave' , AB .ExtraButtons_OnLeave )
221
+ ZoneAbilityFrame .SpellButtonContainer .holder = ZoneAbilityHolder
222
+ ZoneAbilityFrame .SpellButtonContainer :HookScript (' OnEnter' , AB .ExtraButtons_OnEnter )
223
+ ZoneAbilityFrame .SpellButtonContainer :HookScript (' OnLeave' , AB .ExtraButtons_OnLeave )
173
224
174
- AB :ExtraButtons_Reparent ()
225
+ hooksecurefunc (ZoneAbilityFrame .SpellButtonContainer , ' SetSize' , AB .ExtraButtons_ZoneScale )
226
+ hooksecurefunc (ZoneAbilityFrame , ' UpdateDisplayedZoneAbilities' , AB .ExtraButtons_ZoneStyle )
227
+ hooksecurefunc (ZoneAbilityFrame , ' SetParent' , AB .ExtraButtons_ZoneParent )
228
+
229
+ extraHooked [ZoneAbilityFrame ] = true
230
+ end
175
231
176
232
ZoneAbilityFrame :ClearAllPoints ()
177
233
ZoneAbilityFrame :SetAllPoints ()
178
234
ZoneAbilityFrame .ignoreInLayout = true
179
235
180
- ExtraActionBarFrame : ClearAllPoints ()
181
- ExtraActionBarFrame : SetAllPoints ( )
182
- ExtraActionBarFrame . ignoreInLayout = true
236
+ -- Spawn the mover before its available.
237
+ ZoneAbilityHolder : Size ( 52 * E . db . actionbar . zoneActionButton . scale )
238
+ end
183
239
184
- -- try to shutdown the container movement and taints
185
- ExtraAbilityContainer :KillEditMode ()
186
- ExtraAbilityContainer :SetScript (' OnShow' , nil )
187
- ExtraAbilityContainer :SetScript (' OnUpdate' , nil )
188
- ExtraAbilityContainer .OnUpdate = nil -- remove BaseLayoutMixin.OnUpdate
189
- ExtraAbilityContainer .IsLayoutFrame = nil -- dont let it get readded
240
+ function AB :HandleExtraAbility ()
241
+ local ExtraAbilityContainer = _G .ExtraAbilityContainer
242
+ if not ExtraAbilityContainer then return end
190
243
191
- hooksecurefunc (ZoneAbilityFrame .SpellButtonContainer , ' SetSize' , AB .ExtraButtons_ZoneScale )
192
- hooksecurefunc (ZoneAbilityFrame , ' UpdateDisplayedZoneAbilities' , AB .ExtraButtons_ZoneStyle )
193
- hooksecurefunc (ExtraAbilityContainer , ' AddFrame' , AB .ExtraButtons_BossStyle )
244
+ if not extraHooked [ExtraAbilityContainer ] then
245
+ ExtraActionBarHolder = CreateFrame (' Frame' , nil , E .UIParent )
246
+ ExtraActionBarHolder :Point (' BOTTOM' , E .UIParent , ' BOTTOM' , - 150 , 300 )
247
+ E .FrameLocks [ExtraActionBarHolder ] = true
194
248
195
- hooksecurefunc (ZoneAbilityFrame , ' SetParent' , function (_ , parent )
196
- if parent ~= ZoneAbilityHolder and not AB .NeedsReparentExtraButtons then
197
- AB :ExtraButtons_Reparent ()
198
- end
199
- end )
200
- hooksecurefunc (ExtraActionBarFrame , ' SetParent' , function (_ , parent )
201
- if parent ~= ExtraActionBarHolder and not AB .NeedsReparentExtraButtons then
202
- AB :ExtraButtons_Reparent ()
203
- end
204
- end )
249
+ E :CreateMover (ExtraActionBarHolder , ' BossButton' , L [" Boss Button" ], nil , nil , nil , ' ALL,ACTIONBARS' , nil , ' actionbar,extraButtons,extraActionButton' )
205
250
206
- AB :UpdateExtraButtons ()
251
+ -- try to shutdown the container movement and taints
252
+ ExtraAbilityContainer :KillEditMode ()
253
+ ExtraAbilityContainer :SetScript (' OnShow' , nil )
254
+ ExtraAbilityContainer :SetScript (' OnUpdate' , nil )
255
+ ExtraAbilityContainer .OnUpdate = nil -- remove BaseLayoutMixin.OnUpdate
256
+ ExtraAbilityContainer .IsLayoutFrame = nil -- dont let it get readded
207
257
208
- E :CreateMover (ExtraActionBarHolder , ' BossButton' , L [" Boss Button" ], nil , nil , nil , ' ALL,ACTIONBARS' , nil , ' actionbar,extraButtons,extraActionButton' )
209
- E :CreateMover (ZoneAbilityHolder , ' ZoneAbility' , L [" Zone Ability" ], nil , nil , nil , ' ALL,ACTIONBARS' , nil , ' actionbar,extraButtons,extraActionButton' )
258
+ hooksecurefunc (ExtraAbilityContainer , ' AddFrame' , AB .ExtraButtons_BossStyle )
210
259
211
- -- Spawn the mover before its available.
212
- ZoneAbilityHolder :Size (52 * E .db .actionbar .zoneActionButton .scale )
260
+ extraHooked [ExtraAbilityContainer ] = true
261
+ end
262
+ end
263
+
264
+ function AB :SetupExtraButton ()
265
+ if _G .ZoneAbilityFrame then
266
+ AB :HandleZoneAbility ()
267
+ end
268
+
269
+ if _G .ExtraAbilityContainer then
270
+ AB :HandleExtraAbility ()
271
+ end
272
+
273
+ AB :HandleExtraButton ()
274
+ AB :UpdateExtraButtons ()
275
+ AB :ExtraButtons_Reparent ()
213
276
end
214
277
215
278
function AB :UpdateExtraButtons ()
221
284
function AB :UpdateExtraBindings ()
222
285
_G .ExtraActionBarFrame .db = E .db .actionbar .extraActionButton
223
286
224
- for _ , button in pairs (ExtraButtons ) do
287
+ for _ , button in pairs (extraBtns ) do
225
288
button .HotKey :SetText (GetBindingKey (button .commandName ))
226
289
AB :FixKeybindText (button )
227
290
AB :FixKeybindColor (button )
0 commit comments