-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
37 lines (31 loc) · 1.03 KB
/
init.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
local addonName, Roth_UI = ...
local LSM = LibStub("LibSharedMedia-3.0")
local mediaCallbacks = {}
local loadedCallbacks = {}
local configLoaded = false
local LoadedHandler = CreateFrame("Frame")
LoadedHandler:RegisterEvent("ADDON_LOADED")
LoadedHandler:SetScript("OnEvent", function(self, event, name)
if name == "Roth_UI" then
Roth_UI:LoadConfig()
configLoaded = true
for index, callback in pairs(loadedCallbacks) do
callback()
end
end
end)
--- Callback to get notifications when addons loaded later than us have added shared media.
LSM.RegisterCallback(Roth_UI, "LibSharedMedia_Registered", function(name, mediaType, key)
if configLoaded then
for index, callback in pairs(mediaCallbacks) do
callback(name, mediaType, key)
end
end
end)
--- Allows a callback to be registered for when LibSharedMedia registers new content
function Roth_UI:ListenForMediaChange(callback)
table.insert(mediaCallbacks, callback)
end
function Roth_UI:ListenForLoaded(callback)
table.insert(loadedCallbacks, callback)
end