-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMasqueBlizzBars.lua
203 lines (177 loc) · 6.46 KB
/
MasqueBlizzBars.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
--
-- Masque Blizzard Bars
-- Enables Masque to skin the built-in WoW action bars
--
-- Copyright 2022 - 2024 SimGuy
--
-- Use of this source code is governed by an MIT-style
-- license that can be found in the LICENSE file or at
-- https://opensource.org/licenses/MIT.
--
local _, Shared = ...
-- From Locales/Locales.lua
-- Not used yet
--local L = Shared.Locale
-- From Metadata.lua
local Metadata = Shared.Metadata
local Groups = Metadata.Groups
-- Not used yet
--local Callbacks = Metadata.OptionCallbacks
-- From Core.lua
local Core = Shared.Core
-- Push us into shared object
local Addon = {}
Shared.Addon = Addon
-- Handle events for buttons that get created dynamically by Blizzard
function Addon:HandleEvent(event)
-- Handle ExtraActionButton on Extra ActionBar updates
--
-- We don't handle the ZAB here because if EAB and ZAB are both
-- active, the ZAB will get added after the event fires and get
-- missed.
if event == "UPDATE_EXTRA_ACTIONBAR" then
local bar = Groups.ExtraAbilityContainer
local eab = ExtraActionButton1
-- Make sure the EAB exists and hasn't already been added
if not bar.State.ExtraActionButton and eab and
eab:GetObjectType() == "CheckButton" then
-- TODO: Update this to use Core:Skin()
bar.Group:AddButton(eab)
bar.State.ExtraActionButton = true
end
-- Handle Pet Battle Buttons on Pet Battle start
elseif event == "PET_BATTLE_OPENING_START" then
local bar = Groups.PetBattleFrame
local pbf = _G["PetBattleFrame"]["BottomFrame"]
-- Find the Pet Battle Frame children that are buttons
-- but only skin the ones that haven't already been seen
for i = 1, select("#", pbf:GetChildren()) do
local pbb = select(i, pbf:GetChildren())
if type(pbb) == "table" and pbb.GetObjectType then
local name = pbb:GetDebugName()
local obj = pbb:GetObjectType()
if bar.State.PetBattleButton[name] ~= pbb and
(obj == "CheckButton" or obj == "Button") then
-- TODO: Update this to use Core:Skin()
-- Define the regions for this weird button
local pbbRegions = {
Icon = pbb.Icon,
Count = pbb.Count,
Cooldown = nil, -- These buttons have no cooldown frame
Normal = pbb.NormalTexture,
Highlight = pbb:GetHighlightTexture()
}
bar.Group:AddButton(pbb, pbbRegions)
bar.State.PetBattleButton[name] = pbb
end
end
end
end
end
-- ReSkin any action bars that are defined if needed
function Addon:ReSkinBars()
for _, bar in ipairs({ "ActionBar", "MultiBarBottomLeft", "MultiBarBottomRight", "MultiBarLeft",
"MultiBarRight", "MultiBar5", "MultiBar6", "MultiBar7" }) do
if Groups[bar] and Groups[bar].Group then
Groups[bar].Group:ReSkin()
end
end
end
-- Spell Flyout buttons are created as needed when a flyout is opened, so
-- check for any new buttons any time that happens
function Addon:SpellFlyout_Toggle(flyoutID)
local _, _, numSlots, _ = GetFlyoutInfo(flyoutID)
local activeSlots = 0
for slot = 1, numSlots do
local _, _, isKnown, _, _ = GetFlyoutSlotInfo(flyoutID, slot)
if (isKnown) then
activeSlots = activeSlots + 1
end
end
-- Skin any extra buttons found
local bar = Groups.SpellFlyout
local numButtons = bar.Buttons.SpellFlyoutButton
if (numButtons < activeSlots) then
for i = numButtons + 1, activeSlots do
-- TODO: Update this to use Core:Skin()
bar.Group:AddButton(_G["SpellFlyoutButton"..i])
end
bar.Buttons.SpellFlyoutButton = activeSlots
end
end
-- Attempt to adopt the ZoneAbilityButton, which has no name, when Blizzard
-- tries to update the displayed buttons. We do this here because when
-- UPDATE_EXTRA_ACTIONBAR is fired and both EAB and ZAB are active, it will
-- fire too early, the ZAB won't exist, and we'll miss it completely.
function Addon:ZoneAbilityFrame_UpdateDisplayedZoneAbilities()
local zac = ZoneAbilityFrame.SpellButtonContainer
local bar = Groups.ExtraAbilityContainer
for i = 1, select("#", zac:GetChildren()) do
local zab = select(i, zac:GetChildren())
-- Try not to add buttons that are already added
--
-- I'm not sure if the Frame created for the ZAB is used for
-- the whole life of the UI so if the frame changes, we'll
-- skin whatever replaced it.
if zab and zab:GetObjectType() == "Button" then
local name = zab:GetDebugName()
if bar.State.ZoneAbilityButton[name] ~= zab then
-- TODO: Update this to use Core:Skin()
-- Define the regions for this weird button
local zabRegions = {
Icon = zab.Icon,
Count = zab.Count,
Cooldown = zab.Cooldown,
Normal = zab.NormalTexture,
Highlight = zab:GetHighlightTexture()
}
bar.Group:AddButton(zab, zabRegions, "Action")
bar.State.ZoneAbilityButton[name] = zab
end
end
end
end
-- These are init steps specific to this addon
-- This should be run before Core:Init()
function Addon:Init()
-- Spell Flyout
if Core:CheckVersion({ 70003, nil }) then
hooksecurefunc(SpellFlyout, "Toggle",
Addon.SpellFlyout_Toggle)
end
-- Check if MoveAny is installed and handle the bar modifications it makes
if UpdateActionBarBackground then
hooksecurefunc("UpdateActionBarBackground", Addon.ReSkinBars)
end
-- Zone Ability Buttons
-- This may be DraenorZoneAbilityFrame_Update if Classic reaches WoD
-- This may be ZoneAbilityFrame_Update if Classic reaches Legion
if Core:CheckVersion({ 90001, nil }) then
hooksecurefunc(ZoneAbilityFrame, "UpdateDisplayedZoneAbilities",
Addon.ZoneAbilityFrame_UpdateDisplayedZoneAbilities)
end
Addon.Events = CreateFrame("Frame")
-- Extra Action Button
--
-- This was added in 40300, but in Cata Classic it's not in 40400.
-- It'll probably be added when Dragon Soul is released since it's needed
-- for Ultraxion but I have no way to know what version that will be yet.
--
if Core:CheckVersion({ 50004, nil }) then
Addon.Events:RegisterEvent("UPDATE_EXTRA_ACTIONBAR")
end
-- Pet Battles
if Core:CheckVersion({ 50004, nil }) then
Addon.Events:RegisterEvent("PET_BATTLE_OPENING_START")
end
Addon.Events:SetScript("OnEvent", Addon.HandleEvent)
if Core:CheckVersion({ 100000, nil }) then
-- Empty the whole options table because we have no options yet
Metadata.Options = nil
else
-- Empty the whole options table because we don't support it on Classic
Metadata.Options = nil
end
end
Addon:Init()
Core:Init()