-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.lua
More file actions
55 lines (50 loc) · 1.9 KB
/
Copy pathMain.lua
File metadata and controls
55 lines (50 loc) · 1.9 KB
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
local addonName, addon = ...
-- Globals
local _G = _G
---@class Button
local ClickCastingToggleButton = _G.ClickCastingToggleButton -- our frame name, see ClickCastingTab.xml
local spellBookAddonName = 'Blizzard_PlayerSpells'
--- Disable the tab while the click binding frame is open
local function OnClickBindingLoaded()
local ClickBindingFrame = _G.ClickBindingFrame
if not ClickBindingFrame then return end
ClickBindingFrame:HookScript("OnShow", function()
ClickCastingToggleButton:SetEnabled(false)
ClickCastingToggleButton:SetTabSelected(true)
end)
ClickBindingFrame:HookScript("OnHide", function()
ClickCastingToggleButton:SetEnabled(true)
ClickCastingToggleButton:SetTabSelected(false)
end)
end
-- Addon Core
addon.eventFrame = CreateFrame("Frame", addonName .. "EventFrame", UIParent)
addon.eventFrame:RegisterEvent("ADDON_LOADED")
addon.eventFrame:SetScript("OnEvent", function(_, event, ...)
if event == "ADDON_LOADED" then
local name = ...
if name == spellBookAddonName then
addon.eventFrame:UnregisterEvent("ADDON_LOADED")
local PlayerSpellsFrame = _G.PlayerSpellsFrame
-- Position as a bottom tab next to the existing tabs
local tabSystem = PlayerSpellsFrame.TabSystem
local lastTab = tabSystem.tabs[#tabSystem.tabs]
ClickCastingToggleButton:ClearAllPoints()
ClickCastingToggleButton:SetParent(PlayerSpellsFrame)
ClickCastingToggleButton:SetPoint("LEFT", lastTab, "RIGHT", 1, 0)
ClickCastingToggleButton:Show()
-- ClickBindingFrame is load-on-demand, hook when it becomes available
if _G.ClickBindingFrame then
OnClickBindingLoaded()
else
addon.eventFrame:RegisterEvent("ADDON_LOADED")
addon.eventFrame:HookScript("OnEvent", function(_, ev, loadedName)
if ev == "ADDON_LOADED" and loadedName == "Blizzard_ClickBindingUI" then
addon.eventFrame:UnregisterEvent("ADDON_LOADED")
OnClickBindingLoaded()
end
end)
end
end
end
end)