forked from ElvUI-WotLK/ElvUI
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathInit.lua
More file actions
288 lines (245 loc) · 9.99 KB
/
Copy pathInit.lua
File metadata and controls
288 lines (245 loc) · 9.99 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
--[[
~AddOn Engine~
To load the AddOn engine add this to the top of your file:
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
]]
--
--Lua functions
local _G, pairs, type, tcopy = _G, pairs, type, table.copy
--WoW API / Variables
local CreateFrame = CreateFrame
local GetAddOnMetadata = GetAddOnMetadata
local GetTime = GetTime
local HideUIPanel = HideUIPanel
local IsAddOnLoaded = IsAddOnLoaded
local ReloadUI = ReloadUI
local ERR_NOT_IN_COMBAT = ERR_NOT_IN_COMBAT
local GameMenuButtonLogout = GameMenuButtonLogout
local GameMenuFrame = GameMenuFrame
BINDING_HEADER_ELVUI = GetAddOnMetadata(..., "Title")
local AceAddon, AceAddonMinor = LibStub("AceAddon-3.0")
local CallbackHandler = LibStub("CallbackHandler-1.0")
local AddOnName, Engine = ...
local AddOn = AceAddon:NewAddon(AddOnName, "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0", "AceHook-3.0")
AddOn.callbacks = AddOn.callbacks or CallbackHandler:New(AddOn)
AddOn.DF = {profile = {}, global = {}}; AddOn.privateVars = {profile = {}} -- Defaults
AddOn.Options = {type = "group", name = AddOnName, args = {}, childGroups = 'ElvUI_HiddenTree'}
Engine[1] = AddOn
Engine[2] = {}
Engine[3] = AddOn.privateVars.profile
Engine[4] = AddOn.DF.profile
Engine[5] = AddOn.DF.global
_G[AddOnName] = Engine
do
AddOn.Libs = {}
AddOn.LibsMinor = {}
function AddOn:AddLib(name, major, minor)
if not name then return end
-- in this case: `major` is the lib table and `minor` is the minor version
if type(major) == "table" and type(minor) == "number" then
self.Libs[name], self.LibsMinor[name] = major, minor
else -- in this case: `major` is the lib name and `minor` is the silent switch
self.Libs[name], self.LibsMinor[name] = LibStub(major, minor)
end
end
AddOn:AddLib("AceAddon", AceAddon, AceAddonMinor)
AddOn:AddLib("AceDB", "AceDB-3.0")
AddOn:AddLib("EP", "LibElvUIPlugin-1.0")
AddOn:AddLib("LSM", "LibSharedMedia-3.0")
AddOn:AddLib("ACL", "AceLocale-3.0-ElvUI")
AddOn:AddLib('ACH', 'LibAceConfigHelper')
AddOn:AddLib("LAB", "LibActionButton-1.0-ElvUI")
AddOn:AddLib("LAI", "LibAuraInfo-1.0-ElvUI", true)
AddOn:AddLib("LBF", "LibButtonFacade", true)
AddOn:AddLib("LDB", "LibDataBroker-1.1")
AddOn:AddLib("DualSpec", "LibDualSpec-1.0")
AddOn:AddLib("SimpleSticky", "LibSimpleSticky-1.0")
AddOn:AddLib("SpellRange", "SpellRange-1.0")
AddOn:AddLib("ItemSearch", "LibItemSearch-1.2-ElvUI")
AddOn:AddLib("Compress", "LibCompress")
AddOn:AddLib('Deflate', 'LibDeflate')
AddOn:AddLib("Base64", "LibBase64-1.0-ElvUI")
AddOn:AddLib("Translit", "LibTranslit-1.0")
AddOn:AddLib("CustomGlow", "LibCustomGlow-1.0-ElvUI", true)
AddOn:AddLib("Dispel", "LibDispel-1.0", true)
-- added on ElvUI_OptionsUI load: AceGUI, AceConfig, AceConfigDialog, AceConfigRegistry, AceDBOptions
-- backwards compatible for plugins
AddOn.LSM = AddOn.Libs.LSM
AddOn.Masque = AddOn.Libs.Masque
end
AddOn.oUF = Engine.oUF
AddOn.ActionBars = AddOn:NewModule("ActionBars","AceHook-3.0","AceEvent-3.0")
AddOn.AFK = AddOn:NewModule("AFK","AceEvent-3.0","AceTimer-3.0")
AddOn.Auras = AddOn:NewModule("Auras","AceHook-3.0","AceEvent-3.0")
AddOn.Bags = AddOn:NewModule("Bags","AceHook-3.0","AceEvent-3.0","AceTimer-3.0")
AddOn.Blizzard = AddOn:NewModule("Blizzard","AceEvent-3.0","AceHook-3.0")
AddOn.Chat = AddOn:NewModule("Chat","AceTimer-3.0","AceHook-3.0","AceEvent-3.0")
AddOn.DataBars = AddOn:NewModule("DataBars","AceEvent-3.0")
AddOn.DataTexts = AddOn:NewModule("DataTexts","AceTimer-3.0","AceHook-3.0","AceEvent-3.0")
AddOn.DebugTools = AddOn:NewModule("DebugTools","AceEvent-3.0","AceHook-3.0")
AddOn.Distributor = AddOn:NewModule("Distributor","AceEvent-3.0","AceTimer-3.0","AceComm-3.0","AceSerializer-3.0")
AddOn.Layout = AddOn:NewModule("Layout","AceEvent-3.0")
AddOn.Minimap = AddOn:NewModule("Minimap","AceEvent-3.0")
AddOn.Misc = AddOn:NewModule("Misc","AceEvent-3.0","AceTimer-3.0")
AddOn.ModuleCopy = AddOn:NewModule("ModuleCopy","AceEvent-3.0","AceTimer-3.0","AceComm-3.0","AceSerializer-3.0")
AddOn.NamePlates = AddOn:NewModule("NamePlates","AceHook-3.0","AceEvent-3.0","AceTimer-3.0")
AddOn.PluginInstaller = AddOn:NewModule("PluginInstaller")
AddOn.RaidUtility = AddOn:NewModule("RaidUtility","AceEvent-3.0")
AddOn.ReminderBuffs = AddOn:NewModule("ReminderBuffs", "AceEvent-3.0")
AddOn.Skins = AddOn:NewModule("Skins","AceTimer-3.0","AceHook-3.0","AceEvent-3.0")
AddOn.Threat = AddOn:NewModule("Threat","AceEvent-3.0")
AddOn.Tooltip = AddOn:NewModule("Tooltip","AceTimer-3.0","AceHook-3.0","AceEvent-3.0")
AddOn.TotemBar = AddOn:NewModule("Totems","AceEvent-3.0")
AddOn.UnitFrames = AddOn:NewModule("UnitFrames","AceTimer-3.0","AceEvent-3.0","AceHook-3.0")
AddOn.WorldMap = AddOn:NewModule("WorldMap","AceHook-3.0","AceEvent-3.0","AceTimer-3.0")
AddOn.InstanceMap = AddOn:NewModule("InstanceMap","AceHook-3.0","AceEvent-3.0","AceTimer-3.0")
AddOn.MapMarkers = AddOn:NewModule("MapMarkers","AceHook-3.0","AceComm-3.0","AceSerializer-3.0")
-- AddOn.TotemTracker = AddOn:NewModule('TotemTracker','AceEvent-3.0')
AddOn.Sirus = AddOn:NewModule("Sirus","AceHook-3.0","AceEvent-3.0","AceTimer-3.0","AceComm-3.0","AceSerializer-3.0")
-- AddOn.SirusCase = AddOn:NewModule("SirusCase","AceEvent-3.0")
-- do
-- local arg2, arg3 = "([%(%)%.%%%+%-%*%?%[%^%$])", "%%%1"
-- function AddOn:EscapeString(str)
-- return gsub(str, arg2, arg3)
-- end
-- end
do
DisableAddOn("ElvUI_EverySecondCounts")
DisableAddOn("ElvUI_FogOfWar")
DisableAddOn("ElvUI_VisualAuraTimers")
DisableAddOn("ElvUI_MinimapButtons")
DisableAddOn("ElvUI_ChannelAlerts")
end
do
local a,b,c = '','([%(%)%.%%%+%-%*%?%[%^%$])','%%%1'
function AddOn:EscapeString(s) return gsub(s,b,c) end
local d = {'|[TA].-|[ta]','|c[fF][fF]%x%x%x%x%x%x','|r','^%s+','%s+$'}
function AddOn:StripString(s, ignoreTextures)
for i = ignoreTextures and 2 or 1, #d do s = gsub(s,d[i],a) end
return s
end
end
function AddOn:OnInitialize()
if not ElvCharacterDB then
ElvCharacterDB = {}
end
self.db = tcopy(self.DF.profile, true)
self.global = tcopy(self.DF.global, true)
if ElvDB then
if ElvDB.global then
self:CopyTable(self.global, ElvDB.global)
end
local profileKey
if ElvDB.profileKeys then
profileKey = ElvDB.profileKeys[self.myname.." - "..self.myrealm]
end
if profileKey and ElvDB.profiles and ElvDB.profiles[profileKey] then
self:CopyTable(self.db, ElvDB.profiles[profileKey])
end
end
self.private = tcopy(self.privateVars.profile, true)
if ElvPrivateDB then
local profileKey
if ElvPrivateDB.profileKeys then
profileKey = ElvPrivateDB.profileKeys[self.myname.." - "..self.myrealm]
end
if profileKey and ElvPrivateDB.profiles and ElvPrivateDB.profiles[profileKey] then
self:CopyTable(self.private, ElvPrivateDB.profiles[profileKey])
end
end
self.twoPixelsPlease = false
self.ScanTooltip = CreateFrame("GameTooltip", "ElvUI_ScanTooltip", _G.UIParent, "GameTooltipTemplate")
self.PixelMode = self.twoPixelsPlease or self.private.general.pixelPerfect -- keep this over `UIScale`
self:UIScale(true)
self:UpdateMedia()
self:CheckRole()
self:RegisterEvent("UPDATE_FLOATING_CHAT_WINDOWS", "PixelScaleChanged")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:Contruct_StaticPopups()
self:InitializeInitialModules()
if IsAddOnLoaded("Tukui") then
C_Timer:After(5,function() self:StaticPopup_Show("TUKUI_ELVUI_INCOMPATIBLE") end)
end
if IsAddOnLoaded("Cell") and not self.global.ignoreCellWarning then
C_Timer:After(4,function() self:StaticPopup_Show("CELL_ELVUI_INCOMPATIBLE") end)
end
if self:IsAddOnEnabled("ElvUI_Sirus") then
C_Timer:After(3,function() self:StaticPopup_Show("ELVUI_SIRUS_ENABLE") end)
end
local GameMenuButton = CreateFrame("Button", "ElvUI_MenuButton", GameMenuFrame, "GameMenuButtonTemplate")
GameMenuButton:SetText(self.title)
GameMenuButton:SetScript("OnClick", function()
AddOn:ToggleOptionsUI()
HideUIPanel(GameMenuFrame)
end)
GameMenuFrame[AddOnName] = GameMenuButton
GameMenuButton:Size(GameMenuButtonLogout:GetWidth(), GameMenuButtonLogout:GetHeight())
GameMenuButtonRatings:HookScript("OnShow", function(self)
GameMenuFrame:SetHeight(GameMenuFrame:GetHeight() + self:GetHeight())
end)
GameMenuButtonRatings:HookScript("OnHide", function(self)
GameMenuFrame:SetHeight(GameMenuFrame:GetHeight() - self:GetHeight())
end)
GameMenuFrame:HookScript("OnShow", function()
if not GameMenuFrame.isElvUI then
GameMenuFrame:SetHeight(GameMenuFrame:GetHeight() + GameMenuButtonLogout:GetHeight() + 1)
GameMenuFrame.isElvUI = true
end
local _, relTo = GameMenuButtonLogout:GetPoint()
if relTo ~= GameMenuFrame[AddOnName] then
GameMenuFrame[AddOnName]:ClearAllPoints()
GameMenuFrame[AddOnName]:Point("TOPLEFT", relTo, "BOTTOMLEFT", 0, -1)
GameMenuButtonLogout:ClearAllPoints()
GameMenuButtonLogout:Point("TOPLEFT", GameMenuFrame[AddOnName], "BOTTOMLEFT", 0, -16)
end
end)
self.loadedtime = GetTime()
end
local LoadUI = CreateFrame("Frame")
LoadUI:RegisterEvent("PLAYER_LOGIN")
LoadUI:SetScript("OnEvent", function()
AddOn.Masque = AddOn.Masque or LibStub("Masque", true)
AddOn:Initialize()
end)
function AddOn:PLAYER_REGEN_ENABLED()
self:ToggleOptionsUI()
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
end
function AddOn:PLAYER_REGEN_DISABLED()
local err
if IsAddOnLoaded("ElvUI_OptionsUI") then
local ACD = self.Libs.AceConfigDialog
if ACD and ACD.OpenFrames and ACD.OpenFrames[AddOnName] then
self:RegisterEvent("PLAYER_REGEN_ENABLED")
ACD:Close(AddOnName)
err = true
end
end
if self.CreatedMovers then
for name in pairs(self.CreatedMovers) do
local mover = _G[name]
if mover and mover:IsShown() then
mover:Hide()
err = true
end
end
end
if err then
self:Print(ERR_NOT_IN_COMBAT)
end
end
function AddOn:ResetProfile()
local profileKey
if ElvPrivateDB.profileKeys then
profileKey = ElvPrivateDB.profileKeys[self.myname.." - "..self.myrealm]
if profileKey and ElvPrivateDB.profiles and ElvPrivateDB.profiles[profileKey] then
ElvPrivateDB.profiles[profileKey] = nil
end
end
ElvCharacterDB = nil
self.data:_ResetProfile()
ReloadUI()
end
function AddOn:OnProfileReset()
AddOn:StaticPopup_Show("RESET_PROFILE_PROMPT")
end