-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvents.lua
More file actions
40 lines (35 loc) · 1.33 KB
/
Copy pathEvents.lua
File metadata and controls
40 lines (35 loc) · 1.33 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
local ADDON_NAME, Addon = ...
local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("ADDON_LOADED")
eventFrame:RegisterEvent("PLAYER_LOGIN")
eventFrame:SetScript("OnEvent", function(self, event, addonName)
if event == "ADDON_LOADED" then
if addonName ~= ADDON_NAME then
return
end
Addon.DB.Initialize()
Addon.SettingsUI.Register()
self:UnregisterEvent("ADDON_LOADED")
return
end
if event == "PLAYER_LOGIN" then
local settings = Addon.DB.GetSettings() or Addon.DB.Initialize().settings
if settings.setupOnLogin then
local capabilities = Addon.GetCapabilities()
if capabilities.hasTimer then
C_Timer.After(1, function()
local _, applied = Addon.InitializePresetIfNeeded({ successMessage = false })
if applied then
Addon.Print("Applied chat setup for this character on login.")
end
end)
else
local _, applied = Addon.InitializePresetIfNeeded({ successMessage = false })
if applied then
Addon.Print("Applied chat setup for this character on login.")
end
end
end
self:UnregisterEvent("PLAYER_LOGIN")
end
end)