forked from wind-addons/ElvUI_WindTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Initialize.lua
125 lines (102 loc) · 3.42 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
116
117
118
119
120
121
122
123
124
125
local E, _, V, P, G = unpack(ElvUI)
local addonName, addon = ...
local EP = E.Libs.EP
local AceAddon = E.Libs.AceAddon
local L = E.Libs.ACL:GetLocale("ElvUI", E.global.general.locale)
local _G = _G
local collectgarbage = collectgarbage
local format = format
local hooksecurefunc = hooksecurefunc
local next = next
local print = print
local tonumber = tonumber
local GetAddOnMetadata = GetAddOnMetadata
local W = AceAddon:NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0", "AceHook-3.0")
V.WT = {} -- profile database defaults
P.WT = {} -- private database defaults
G.WT = {} -- global database defaults
addon[1] = W
addon[2] = {} -- Functions
addon[3] = E
addon[4] = L
addon[5] = V.WT
addon[6] = P.WT
addon[7] = G.WT
_G["WindTools"] = addon
W.Version = GetAddOnMetadata(addonName, "Version")
-- Pre-register some WindTools modules
W.Modules = {}
W.Modules.Misc = W:NewModule("Misc", "AceHook-3.0", "AceEvent-3.0")
W.Modules.Skins = W:NewModule("Skins", "AceHook-3.0", "AceEvent-3.0", "AceTimer-3.0")
W.Modules.Tooltips = W:NewModule("Tooltips", "AceHook-3.0", "AceEvent-3.0")
W.Modules.MoveFrames = W:NewModule("MoveFrames", "AceEvent-3.0", "AceHook-3.0")
-- Utilities namespace
W.Utilities = {}
_G.WindTools_OnAddonCompartmentClick = function()
E:ToggleOptions("WindTools")
end
function W:Initialize()
-- ElvUI -> WindTools -> WindTools Modules
if not self:CheckElvUIVersion() then
return
end
for name, module in self:IterateModules() do
addon[2].Developer.InjectLogger(module)
end
hooksecurefunc(
W,
"NewModule",
function(_, name)
addon[2].Developer.InjectLogger(name)
end
)
self.initialized = true
self:UpdateScripts() -- Database need update first
self:InitializeModules()
EP:RegisterPlugin(addonName, W.OptionsCallback)
self:SecureHook(E, "UpdateAll", "UpdateModules")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
end
do
local checked = false
function W:PLAYER_ENTERING_WORLD(_, isInitialLogin, isReloadingUi)
E:Delay(7, self.CheckInstalledVersion, self)
if isInitialLogin then
if E.global.WT.core.loginMessage then
local icon = addon[2].GetIconString(self.Media.Textures.smallLogo, 14)
print(
format(
icon ..
" " ..
L["%s %s Loaded."] ..
" " ..
L["You can send your suggestions or bugs via %s, %s, %s and the thread in %s."],
self.Title,
self.Version,
L["QQ Group"],
L["Discord"],
L["GitHub"],
L["NGA.cn"]
)
)
end
end
if not (checked or _G.ElvUIInstallFrame) then
self:CheckCompatibility()
checked = true
end
if _G.ElvDB then
if isInitialLogin or not _G.ElvDB.WT then
_G.ElvDB.WT = {
DisabledAddOns = {}
}
end
if next(_G.ElvDB.WT.DisabledAddOns) then
E:Delay(4, self.PrintDebugEnviromentTip)
end
end
self:GameFixing()
E:Delay(1, collectgarbage, "collect")
end
end
EP:HookInitialize(W, W.Initialize)