-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
162 lines (137 loc) · 4.84 KB
/
init.lua
File metadata and controls
162 lines (137 loc) · 4.84 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
--[[
MondoUI - Initialization
Entry point - AceAddon-based initialization with AceDB and CallbackHandler
]]
-- Get Ace3 libraries
local AceAddon = LibStub("AceAddon-3.0")
local AceDB = LibStub("AceDB-3.0")
local CallbackHandler = LibStub("CallbackHandler-1.0") -- Required, not optional
-- Create addon using AceAddon
-- Use M as primary reference (like ElvUI uses E)
M = AceAddon:NewAddon("MondoUI",
"AceConsole-3.0",
"AceEvent-3.0"
)
-- Set up CallbackHandler system (replaces M:Watch for module communication)
-- CallbackHandler:New() embeds RegisterCallback/UnregisterCallback on M directly
-- and returns a registry object with Fire method
M.callbacks = CallbackHandler:New(M)
-- Fire convenience method (callbacks object has Fire, but we expose it on M for convenience)
function M:FireCallback(event, ...)
if not self.callbacks then
return
end
return self.callbacks:Fire(event, ...)
end
-- Short alias
M.Fire = M.FireCallback
-- Utilities are attached to M directly by their files (M.Helpers, M.Component, etc.)
-- These are loaded via load.xml before init.lua
function M:OnInitialize()
-- Set up AceDB with minimal structure
-- Modules will handle their own defaults in their OnInitialize()
local defaults = {
profile = {
-- Modules will populate their own sections
},
global = {
debugVerbose = false,
}
}
-- Use AceDB via LibStub (not embedded)
-- Pass 'true' for character-specific profiles (uses character name)
self.db = AceDB:New("MondoUI_DB", defaults, true)
-- Register AceDB callbacks
self.db.RegisterCallback(self, "OnProfileChanged", "OnProfileChanged")
self.db.RegisterCallback(self, "OnProfileCopied", "OnProfileChanged")
self.db.RegisterCallback(self, "OnProfileReset", "OnProfileChanged")
-- Initialize minimap button (if available)
if M.MinimapButton then
M.MinimapButton:Initialize(self.db)
end
-- Register slash command
self:RegisterChatCommand("muf", "SlashCommand")
-- Register convenience slash command
self:RegisterChatCommand("rl", function()
ReloadUI()
end)
end
function M:OnEnable()
-- Post-initialization setup
-- Modules are already enabled by AceAddon
end
function M:OnProfileChanged()
-- Fire callback for modules that need to know
self:Fire("OnProfileChanged")
-- Call ApplyConfig on all modules that have it
for name, module in pairs(self) do
if type(module) == "table" and type(module.ApplyConfig) == "function" then
module:ApplyConfig()
end
end
end
function M:SlashCommand(input)
if not input or input == "" then
if self.Options then
self.Options:Toggle()
end
return
end
-- Parse command
local args = {}
for word in input:gmatch("%S+") do
table.insert(args, word)
end
-- Handle debug command
if args[1] == "debug" then
if M.Debug then
-- If category specified: "debug Config", "debug Options", etc.
if args[2] and args[2] ~= "verbose" then
local category = args[2]
local currentState = M.Debug:IsCategoryEnabled(category)
M.Debug:SetCategory(category, not currentState)
else
-- Toggle main debug mode
local currentState = M.Debug:IsEnabled()
M.Debug:SetMode(not currentState)
-- Also show verbose status
if self.db.global.debugVerbose then
print("|cFF30D1FFMondoUI|r: Verbose logging is enabled (use '/mondo debug verbose' to toggle)")
end
end
else
print("|cFF30D1FFMondoUI|r: Debug system not available")
end
return
end
-- Handle debug verbose command
if args[1] == "debug" and args[2] == "verbose" then
self.db.global.debugVerbose = not self.db.global.debugVerbose
if self.db.global.debugVerbose then
print("|cFF30D1FFMondoUI|r: Verbose logging enabled")
else
print("|cFF30D1FFMondoUI|r: Verbose logging disabled")
end
return
end
-- Fallback to options system
if self.Options then
self.Options:Open(input)
end
end
-- Addon Compartment Functions
-- These are called by WoW's addon compartment system (icon in the minimap area)
function MondoUI_CompartmentClick()
if M and M.ToggleOptions then
M.ToggleOptions()
end
end
function MondoUI_CompartmentOnEnter()
GameTooltip:SetOwner(UIParent, "ANCHOR_LEFT")
GameTooltip:SetText("MondoUI", 0.188, 0.647, 0.980) -- Using MondoUI accent color
GameTooltip:AddLine("Click to open options", 1, 1, 1)
GameTooltip:Show()
end
function MondoUI_CompartmentOnLeave()
GameTooltip:Hide()
end