-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
116 lines (102 loc) · 3.63 KB
/
main.lua
File metadata and controls
116 lines (102 loc) · 3.63 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
-- Erzbarone main file
ErzbaroneUI = ErzbaroneUI or {}
ErzbaroneUI.Static = {
OpenSoundID = 850,
CloseSoundID = 851,
LightClickSoundID = 856,
}
ErzbaroneUI.isClassic = false
-- Main event handling
local eventHooks = {
"ADDON_LOADED",
"PLAYER_ENTERING_WORLD",
"PLAYER_TARGET_CHANGED",
"UNIT_HEALTH",
"UNIT_HEALTH_FREQUENT",
"UNIT_MAXHEALTH",
"PLAYER_REGEN_DISABLED",
"PLAYER_REGEN_ENABLED",
"UNIT_EXITED_VEHICLE",
"UNIT_ENTERED_VEHICLE",
"DISPLAY_SIZE_CHANGED",
"MERCHANT_SHOW",
"CINEMATIC_STOP",
"UNIT_FACTION"
}
local frame = CreateFrame("Frame")
for _, event in ipairs(eventHooks) do
frame:RegisterEvent(event)
end
frame:SetScript("OnEvent", function(self, event, name)
if event == "ADDON_LOADED" and name == "ErzbaroneUI" then
local _, _, _, tocversion = GetBuildInfo()
if tocversion < 20000 then -- TOC versions for Classic Era are in the 1xxxx range
ErzbaroneUI.isClassic = true
end
ErzbaroneUI.Config:SetDamageFont()
SLASH_ERZBARONEUI1 = "/eui"
SlashCmdList["ERZBARONEUI"] = function(msg)
ErzbaroneUI.Config:ToggleFrame()
end
end
-- Handle one time setup for the addon
if event == "PLAYER_ENTERING_WORLD" then
ErzbaroneUI.Castbar:Initialize()
ErzbaroneUI.Config:Initialize()
ErzbaroneUI.Chat:Initialize()
ErzbaroneUI.WorldMap:Initialize()
ErzbaroneUI.Bags:Initialize()
ErzbaroneUI.UnitFrames:Initialize()
ErzbaroneUI.Bars:Initialize()
ErzbaroneUI.Minimap:Initialize()
ErzbaroneUI.Flag:Initialize()
ErzbaroneUI.Effects:ActivateVignette()
end
-- Handle exiting vehicle
if event == "UNIT_EXITED_VEHICLE" then
if name == "player" then
C_Timer.After(0.5, function() -- Delay to ensure the player frame is restored after exiting vehicle
print("Exiting vehicle, restoring player frame")
ErzbaroneUI.UnitFrames:CenterFrames()
ErzbaroneUI.UnitFrames:ReplacePlayerFrame()
ErzbaroneUI.Bars:ReplaceMicroButtonBar()
end)
end
end
-- Handle entering vehicle to reset the healthbar size
if event == "UNIT_ENTERED_VEHICLE" then
if name == "player" then
ErzbaroneUI.UnitFrames:RestorePlayerFrame()
ErzbaroneUI.Bars:ResetMicroButtonBar()
end
end
-- Handle player target changes or faction changes to update the target frame
if event == "PLAYER_TARGET_CHANGED" or event == "UNIT_FACTION" then
if UnitExists("target") and ErzbaroneUISettings.improvedUnitFrames then
ErzbaroneUI.UnitFrames:ReplaceTargetFrame()
end
end
-- Handle Player health changes, to keep the health bar color updated
if event == "UNIT_HEALTH" or event == "UNIT_HEALTH_FREQUENT" or event == "UNIT_MAXHEALTH" and ErzbaroneUISettings.improvedUnitFrames then
local unit = name or "player"
if unit == "player" then
ErzbaroneUI.UnitFrames:UpdatePlayerHealthColor()
end
if unit == "target" then
ErzbaroneUI.UnitFrames:UpdateTargetHealthColor()
end
end
-- Handle display size changes for the vignette effect
if event == "DISPLAY_SIZE_CHANGED" then
ErzbaroneUI.Effects:UpdateVignette()
end
-- Handle merchant show event to auto-sell grey items
if event == "MERCHANT_SHOW" then
ErzbaroneUI.Utils:AutoSellGreyItems()
ErzbaroneUI.Utils:AutoRepair()
end
-- Handle cutscene end
if event == "CINEMATIC_STOP" then
ErzbaroneUI.Bars:ReplaceMicroButtonBar()
end
end)