forked from Haleth/Aurora
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathaurora.lua
More file actions
308 lines (266 loc) · 10.8 KB
/
aurora.lua
File metadata and controls
308 lines (266 loc) · 10.8 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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
local _, private = ...
-- [[ Lua Globals ]]
-- luacheck: globals next type
local wago = _G.LibStub("WagoAnalytics"):Register("JZKbRK19")
private.wago = wago
-- [[ Core ]]
local Aurora = private.Aurora
local _, C = _G.unpack(Aurora)
local Config = private.Config
local Analytics = private.Analytics
local Compatibility = private.Compatibility
local Integration = private.Integration
-- [[ Constants and settings ]]
local AuroraConfig
C.frames = {}
-- Maintain C.defaults for backward compatibility
C.defaults = Config.defaults
function private.OnLoad()
-- Initialize integration system first
Integration.Initialize()
-- Load and initialize configuration using the Config module with error handling
local configSuccess, configResult = pcall(function()
return Config.load(wago)
end)
if configSuccess then
AuroraConfig = configResult
else
Integration.HandleError("Config", configResult, {phase = "load", recoverable = true})
AuroraConfig = Config.defaults
end
-- Initialize compatibility system with error handling
local compatSuccess, compatErr = pcall(Compatibility.initialize, AuroraConfig)
if not compatSuccess then
Integration.HandleError("Compatibility", compatErr, {phase = "initialize", recoverable = false})
end
-- Initialize analytics system with user consent and error handling
local analyticsSuccess, analyticsErr = pcall(Analytics.initialize, wago, AuroraConfig)
if not analyticsSuccess then
Integration.HandleError("Analytics", analyticsErr, {phase = "initialize", recoverable = false})
end
-- Check if configuration needs recovery
local needsRecovery, reason = Config.needsRecovery(AuroraConfig)
if needsRecovery then
private.debug("Config", "Recovery needed:", reason)
local recoverSuccess, recoverResult = pcall(Config.recover)
if recoverSuccess then
AuroraConfig = recoverResult
else
Integration.HandleError("Config", recoverResult, {phase = "recovery", recoverable = false})
end
end
-- Setup colors
local Color, Util = Aurora.Color, Aurora.Util
local Theme = Aurora.Theme
local customClassColors = AuroraConfig.customClassColors
-- Initialize theme engine
Theme.Initialize()
Theme.InitializeAlpha(AuroraConfig)
function private.updateHighlightColor()
--print("updateHighlightColor override")
-- Use the enhanced color management system with dynamic updates
Color.RefreshHighlightColor(AuroraConfig)
-- Update deprecated references
C.r, C.g, C.b = Color.highlight:GetRGB()
end
_G.CUSTOM_CLASS_COLORS:RegisterCallback(function()
--print("aurora CCC:RegisterCallback")
private.updateHighlightColor()
_G.AuroraOptions.refresh()
end)
private.setColorCache(customClassColors)
-- Apply the saved color mode palette before skin registration
Color.SetMode(AuroraConfig.colorMode)
if AuroraConfig.buttonsHaveGradient then
Color.button:SetRGB(.4, .4, .4)
end
-- Store frame alpha from saved vars
Util.SetFrameAlpha(AuroraConfig.alpha)
-- Create API hooks
local Hook = Aurora.Hook
local Skin = Aurora.Skin
_G.hooksecurefunc(Skin, "FrameTypeButton", function(Button)
if AuroraConfig.buttonsHaveGradient and Button.SetBackdropGradient then
Button:SetBackdropGradient()
end
end)
local characterPanelSkinState = {
CharacterFrame = false,
PaperDollFrame = false,
ReputationFrame = false,
Blizzard_TokenUI = false,
}
-- Only mark as skinned when the relevant global frame actually exists at
-- call time. The initial fileOrder loop may call these skin functions before
-- demand-loaded addons (Blizzard_UIPanels_Game, Blizzard_TokenUI) have
-- created their frames. Without this guard the deferred retry would see the
-- state already set to true and incorrectly skip the real skin pass.
local characterPanelFrameGlobals = {
CharacterFrame = "CharacterFrame",
PaperDollFrame = "PaperDollFrame",
ReputationFrame = "ReputationFrame",
Blizzard_TokenUI = "TokenFrame",
}
local function MarkCharacterPanelSkinned(name)
local globalName = characterPanelFrameGlobals[name]
if globalName and _G[globalName] then
characterPanelSkinState[name] = true
end
end
if type(private.FrameXML.CharacterFrame) == "function" then
_G.hooksecurefunc(private.FrameXML, "CharacterFrame", function()
MarkCharacterPanelSkinned("CharacterFrame")
end)
end
if type(private.FrameXML.PaperDollFrame) == "function" then
_G.hooksecurefunc(private.FrameXML, "PaperDollFrame", function()
MarkCharacterPanelSkinned("PaperDollFrame")
end)
end
if type(private.FrameXML.ReputationFrame) == "function" then
_G.hooksecurefunc(private.FrameXML, "ReputationFrame", function()
MarkCharacterPanelSkinned("ReputationFrame")
end)
end
if type(private.FrameXML.Blizzard_TokenUI) == "function" then
_G.hooksecurefunc(private.FrameXML, "Blizzard_TokenUI", function()
MarkCharacterPanelSkinned("Blizzard_TokenUI")
end)
end
local function SafeApplyCharacterPanelSkin(name)
if characterPanelSkinState[name] then
return
end
local fn = private.FrameXML[name]
if type(fn) ~= "function" then
return
end
local ok, err = pcall(fn)
if not ok then
Integration.HandleError("Skin", err, {phase = "deferred-"..name, recoverable = true})
end
end
local function ApplyCharacterPanelSkins()
if not AuroraConfig.characterSheet then
return
end
if _G.CharacterFrame then
SafeApplyCharacterPanelSkin("CharacterFrame")
end
if _G.PaperDollFrame then
SafeApplyCharacterPanelSkin("PaperDollFrame")
end
if _G.ReputationFrame then
SafeApplyCharacterPanelSkin("ReputationFrame")
end
if _G.TokenFrame then
SafeApplyCharacterPanelSkin("Blizzard_TokenUI")
end
end
local function QueueCharacterPanelSkinApply()
_G.C_Timer.After(0, ApplyCharacterPanelSkins)
end
local panelSkinEventFrame = _G.CreateFrame("Frame")
panelSkinEventFrame:RegisterEvent("ADDON_LOADED")
panelSkinEventFrame:SetScript("OnEvent", function(_, _, addonName)
if addonName == "Blizzard_UIPanels_Game" or addonName == "Blizzard_TokenUI" then
QueueCharacterPanelSkinApply()
end
end)
if _G.C_AddOns.IsAddOnLoaded("Blizzard_UIPanels_Game") then
QueueCharacterPanelSkinApply()
end
if _G.C_AddOns.IsAddOnLoaded("Blizzard_TokenUI") then
QueueCharacterPanelSkinApply()
end
if _G.ToggleCharacter then
_G.hooksecurefunc("ToggleCharacter", function(tabName)
if tabName == "PaperDollFrame" or tabName == "ReputationFrame" or tabName == "TokenFrame" then
QueueCharacterPanelSkinApply()
end
end)
end
-- Skip CharacterFrame modifications if Chonky Character Sheet is loaded
if AuroraConfig.characterSheet and not _G.C_AddOns.IsAddOnLoaded("ChonkyCharacterSheet") then
_G.hooksecurefunc(private.FrameXML, "CharacterFrame", function()
_G.CharacterStatsPane.ItemLevelFrame:SetPoint("TOP", 0, -12)
_G.CharacterStatsPane.ItemLevelFrame.Background:Hide()
_G.CharacterStatsPane.ItemLevelFrame.Value:SetFontObject("SystemFont_Outline_WTF2")
_G.hooksecurefunc("PaperDollFrame_UpdateStats", function()
if ( _G.UnitLevel("player") >= _G.MIN_PLAYER_LEVEL_FOR_ITEM_LEVEL_DISPLAY ) then
_G.CharacterStatsPane.ItemLevelCategory:Hide()
_G.CharacterStatsPane.AttributesCategory:SetPoint("TOP", 0, -40)
end
end)
end)
end
_G.hooksecurefunc(private.FrameXML, "FriendsFrame", function()
local FriendsFrame = _G.FriendsFrame
local titleText = FriendsFrame.TitleText or FriendsFrame:GetTitleText()
local BNetFrame = _G.FriendsFrameBattlenetFrame
BNetFrame.Tag:SetParent(FriendsFrame)
BNetFrame.Tag:SetAllPoints(titleText)
local BroadcastFrame = BNetFrame.BroadcastFrame
local EditBox = BroadcastFrame.EditBox
EditBox:SetParent(FriendsFrame)
EditBox:ClearAllPoints()
EditBox:SetSize(239, 25)
EditBox:SetPoint("TOPLEFT", 57, -28)
EditBox:SetScript("OnEnterPressed", function()
BroadcastFrame:SetBroadcast()
end)
_G.hooksecurefunc("FriendsFrame_Update", function()
local selectedTab = _G.PanelTemplates_GetSelectedTab(FriendsFrame) or _G.FRIEND_TAB_FRIENDS
local isFriendsTab = selectedTab == _G.FRIEND_TAB_FRIENDS
titleText:SetShown(not isFriendsTab)
BNetFrame.Tag:SetShown(isFriendsTab)
EditBox:SetShown(_G.BNConnected() and isFriendsTab)
end)
_G.hooksecurefunc("FriendsFrame_CheckBattlenetStatus", function()
if _G.BNFeaturesEnabled() then
if _G.BNConnected() then
BNetFrame:Hide()
EditBox:Show()
BroadcastFrame:UpdateBroadcast()
else
EditBox:Hide()
end
end
end)
end)
-- Disable skins as per user settings
private.disabled.bags = not AuroraConfig.bags
private.disabled.banks = not AuroraConfig.banks
private.disabled.chat = not AuroraConfig.chat
private.disabled.fonts = not AuroraConfig.fonts
private.disabled.tooltips = not AuroraConfig.tooltips
private.disabled.mainmenubar = not AuroraConfig.mainmenubar
if not AuroraConfig.chatBubbles then
Hook.ChatBubble_OnEvent = private.nop
Hook.ChatBubble_OnUpdate = private.nop
end
if not AuroraConfig.chatBubbleNames then
Hook.ChatBubble_SetName = private.nop
end
if not AuroraConfig.loot then
private.FrameXML.LootFrame = private.nop
end
local function SetupGUI()
if not private.SetupGUI then
return
end
local ok, err = pcall(private.SetupGUI)
if not ok then
Integration.HandleError("GUI", err, {phase = "setup", recoverable = true})
end
end
SetupGUI()
-- Keep backward compatibility for any callers that expect this addon skin hook.
function private.AddOns.Aurora()
SetupGUI()
end
-- Show splash screen for first time users after GUI skinning has been applied.
if not AuroraConfig.acknowledgedSplashScreen and _G.AuroraSplashScreen then
_G.AuroraSplashScreen:Show()
end
end