forked from ArtOfShred/LuiExtended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInitialize.lua
115 lines (94 loc) · 3.75 KB
/
Initialize.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
--[[
LuiExtended
License: The MIT License (MIT)
--]]
local strformat = zo_strformat
local eventManager = EVENT_MANAGER
-- Load saved settings
local function LoadSavedVars()
-- Addon options
LUIE.SV = ZO_SavedVars:NewAccountWide(LUIE.SVName, LUIE.SVVer, nil, LUIE.D)
if LUIE.SV.CharacterSpecificSV then
LUIE.SV = ZO_SavedVars:New(LUIE.SVName, LUIE.SVVer, nil, LUIE.D)
end
end
-- Load additional fonts and status bar textures from LMP
local function LoadMedia()
local LMP = LibStub("LibMediaProvider-1.0")
-- Update Fonts
for _, f in pairs(LMP:List(LMP.MediaType.FONT)) do
if not LUIE.Fonts[f] then
LUIE.Fonts[f] = LMP:Fetch(LMP.MediaType.FONT, f)
end
end
-- Update StatusBar textures
for _, s in pairs(LMP:List(LMP.MediaType.STATUSBAR)) do
if not LUIE.StatusbarTextures[s] then
LUIE.StatusbarTextures[s] = LMP:Fetch(LMP.MediaType.STATUSBAR, s)
end
end
for _, a in pairs(LMP:List(LMP.MediaType.SOUND)) do
if not LUIE.StatusbarTextures[a] then
LUIE.Sounds[a] = LMP:Fetch(LMP.MediaType.SOUND, a)
end
end
end
-- Startup Info string
local function LoadScreen()
eventManager:UnregisterForEvent(LUIE.name, EVENT_PLAYER_ACTIVATED)
if not LUIE.SV.StartupInfo then
LUIE.PrintToChat(strformat("|cFEFEFE<<1>> by|r |c00C000<<2>>|r |cFEFEFEv<<3>>|r", LUIE.name, LUIE.author, LUIE.version), true)
end
end
local function RegisterEvents()
eventManager:RegisterForEvent(LUIE.name, EVENT_PLAYER_ACTIVATED, LoadScreen)
-- Keep track of guilds for the /ginvite commands & Chat Announcement EVENT_GUILD_SELF_LEFT_GUILD handler
if LUIE.SV.SlashCommands_Enable or LUIE.SV.ChatAnnouncements_Enable then
LUIE.UpdateGuildData()
eventManager:RegisterForEvent(moduleName, EVENT_GUILD_SELF_JOINED_GUILD, LUIE.UpdateGuildData)
eventManager:RegisterForEvent(moduleName, EVENT_GUILD_SELF_LEFT_GUILD, LUIE.UpdateGuildData)
end
end
-- LuiExtended Initialization
local function OnAddonOnLoaded(eventCode, addonName)
-- Only initialize our own addon
if LUIE.name ~= addonName then
return
end
-- Once we know it's ours, lets unregister the event listener
eventManager:UnregisterForEvent(addonName, eventCode)
-- Load additional media from LMP and other addons
LoadMedia()
-- Load saved variables
LoadSavedVars()
-- Initialize Hooks
LUIE.InitializeHooks()
LUIE.PlayerNameRaw = GetRawUnitName("player")
LUIE.PlayerNameFormatted = strformat(SI_UNIT_NAME, GetUnitName("player"))
LUIE.PlayerDisplayName = strformat(SI_UNIT_NAME, GetUnitDisplayName("player"))
-- Initialize this addon modules according to user preferences
LUIE.ChatAnnouncements.Initialize(LUIE.SV.ChatAnnouncements_Enable)
LUIE.CombatInfo.Initialize(LUIE.SV.CombatInfo_Enabled)
LUIE.CombatText.Initialize(LUIE.SV.CombatText_Enabled)
LUIE.InfoPanel.Initialize(LUIE.SV.InfoPanel_Enabled)
LUIE.UnitFrames.Initialize(LUIE.SV.UnitFrames_Enabled)
LUIE.SpellCastBuffs.Initialize(LUIE.SV.SpellCastBuff_Enable)
LUIE.SlashCommands.Initialize(LUIE.SV.SlashCommands_Enable)
-- Load Timetamp Color
LUIE.UpdateTimeStampColor()
-- Create settings menus for our addon
LUIE.CreateSettings()
LUIE.ChatAnnouncements.CreateSettings()
LUIE.CombatInfo.CreateSettings()
LUIE.CombatText.CreateSettings()
LUIE.InfoPanel.CreateSettings()
LUIE.UnitFrames.CreateSettings()
LUIE.SpellCastBuffs.CreateSettings()
LUIE.SlashCommands.CreateSettings()
-- Display changelog screen
LUIE.ChangelogScreen()
-- Register global event listeners
RegisterEvents()
end
-- Hook initialization
eventManager:RegisterForEvent(LUIE.name, EVENT_ADD_ON_LOADED, OnAddonOnLoaded)