Skip to content

Commit af22ffc

Browse files
committed
cata boss button
1 parent acde592 commit af22ffc

File tree

3 files changed

+133
-70
lines changed

3 files changed

+133
-70
lines changed

ElvUI/Core/General/Core.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ function E:UpdateActionBars(skipCallback)
15381538
ActionBars:UpdateMicroButtons()
15391539
ActionBars:UpdatePetCooldownSettings()
15401540

1541-
if E.Retail then
1541+
if E.Retail or E.Cata then
15421542
ActionBars:UpdateExtraButtons()
15431543
end
15441544

ElvUI/Core/Modules/ActionBars/ActionBars.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,9 @@ function AB:Initialize()
17731773
AB.fadeParent:RegisterEvent('UPDATE_OVERRIDE_ACTIONBAR')
17741774
AB.fadeParent:RegisterEvent('UPDATE_POSSESS_BAR')
17751775
AB.fadeParent:RegisterEvent('PLAYER_CAN_GLIDE_CHANGED')
1776+
1777+
AB:RegisterEvent('PET_BATTLE_CLOSE', 'ReassignBindings')
1778+
AB:RegisterEvent('PET_BATTLE_OPENING_DONE', 'RemoveBindings')
17761779
end
17771780

17781781
if E.Retail or E.Cata then
@@ -1809,11 +1812,8 @@ function AB:Initialize()
18091812

18101813
AB:SetAuraCooldownDuration(E.db.cooldown.targetAuraDuration)
18111814

1812-
if E.Retail then
1815+
if E.Retail or E.Cata then
18131816
AB:SetupExtraButton()
1814-
1815-
AB:RegisterEvent('PET_BATTLE_CLOSE', 'ReassignBindings')
1816-
AB:RegisterEvent('PET_BATTLE_OPENING_DONE', 'RemoveBindings')
18171817
end
18181818

18191819
if (E.Cata and E.myclass == 'SHAMAN') and AB.db.totemBar.enable then

ElvUI/Core/Modules/ActionBars/ExtraAB.lua

+128-65
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,25 @@ local _G = _G
55
local pairs = pairs
66
local unpack = unpack
77
local tinsert = tinsert
8+
89
local CreateFrame = CreateFrame
910
local GetBindingKey = GetBindingKey
10-
local hooksecurefunc = hooksecurefunc
1111
local InCombatLockdown = InCombatLockdown
12+
local hooksecurefunc = hooksecurefunc
13+
1214
local ActionButton_UpdateCooldown = ActionButton_UpdateCooldown
1315

14-
local ExtraActionBarHolder, ZoneAbilityHolder
15-
local ExtraButtons = {}
16+
local extraBtns, extraHooked, ExtraActionBarHolder, ZoneAbilityHolder = {}, {}
1617

1718
function AB:ExtraButtons_BossStyle(frame)
1819
local button = frame.button
1920
if button and not button.IsSkinned then
2021
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
2227

2328
button.icon:SetDrawLayer('ARTWORK', -1)
2429
button:SetTemplate()
@@ -28,12 +33,13 @@ function AB:ExtraButtons_BossStyle(frame)
2833
button:HookScript('OnLeave', AB.ExtraButtons_OnLeave)
2934

3035
button.HotKey:SetText(GetBindingKey(button.commandName))
36+
3137
AB:FixKeybindText(button)
3238
AB:FixKeybindColor(button)
3339

3440
AB:ExtraButtons_BossAlpha(button)
3541

36-
tinsert(ExtraButtons, button)
42+
tinsert(extraBtns, button)
3743

3844
button.IsSkinned = true
3945
end
@@ -71,13 +77,19 @@ end
7177

7278
function AB:ExtraButtons_BossAlpha(button)
7379
local bossAlpha = E.db.actionbar.extraActionButton.alpha
74-
button:SetAlpha(bossAlpha)
80+
button:SetAlpha(bossAlpha or 1)
7581

7682
if button.style then
7783
button.style:SetAlpha(not E.db.actionbar.extraActionButton.clean and bossAlpha or 0)
7884
end
7985
end
8086

87+
function AB:ExtraButtons_BossParent(parent)
88+
if parent ~= ExtraActionBarHolder and not AB.NeedsReparentExtraButtons then
89+
AB:ExtraButtons_Reparent()
90+
end
91+
end
92+
8193
function AB:ExtraButtons_ZoneAlpha()
8294
local zoneAlpha = E.db.actionbar.zoneActionButton.alpha
8395
_G.ZoneAbilityFrame.Style:SetAlpha(not E.db.actionbar.zoneActionButton.clean and zoneAlpha or 0)
@@ -102,114 +114,165 @@ function AB:ExtraButtons_OnLeave()
102114
end
103115

104116
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
107124
end
108125

109126
function AB:ExtraButtons_UpdateAlpha()
110127
if not E.private.actionbar.enable then return end
111128

112-
for _, button in pairs(ExtraButtons) do
129+
for _, button in pairs(extraBtns) do
113130
AB:ExtraButtons_BossAlpha(button)
114131
end
115132

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
119138
end
120139
end
121140

122141
function AB:ExtraButtons_UpdateScale()
123142
if not E.private.actionbar.enable then return end
124143

125-
AB:ExtraButtons_ZoneScale()
144+
if _G.ZoneAbilityFrame then
145+
AB:ExtraButtons_ZoneScale()
146+
end
126147

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)
130152

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
133156
end
134157

135158
function AB:ExtraButtons_ZoneScale()
136159
if not E.private.actionbar.enable then return end
137160

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
141170

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
144175
end
145176

146177
function AB:ExtraButtons_Reparent()
147178
if InCombatLockdown() then
148179
AB.NeedsReparentExtraButtons = true
180+
149181
AB:RegisterEvent('PLAYER_REGEN_ENABLED')
182+
150183
return
151184
end
152185

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
155193
end
156194

157-
function AB:SetupExtraButton()
158-
local ExtraAbilityContainer = _G.ExtraAbilityContainer
195+
function AB:HandleExtraButton()
159196
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()
160211
local ZoneAbilityFrame = _G.ZoneAbilityFrame
212+
if not ZoneAbilityFrame then return end
161213

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
165218

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')
169220

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)
173224

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
175231

176232
ZoneAbilityFrame:ClearAllPoints()
177233
ZoneAbilityFrame:SetAllPoints()
178234
ZoneAbilityFrame.ignoreInLayout = true
179235

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
183239

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
190243

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
194248

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')
205250

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
207257

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)
210259

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()
213276
end
214277

215278
function AB:UpdateExtraButtons()
@@ -221,7 +284,7 @@ end
221284
function AB:UpdateExtraBindings()
222285
_G.ExtraActionBarFrame.db = E.db.actionbar.extraActionButton
223286

224-
for _, button in pairs(ExtraButtons) do
287+
for _, button in pairs(extraBtns) do
225288
button.HotKey:SetText(GetBindingKey(button.commandName))
226289
AB:FixKeybindText(button)
227290
AB:FixKeybindColor(button)

0 commit comments

Comments
 (0)