-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommands.lua
More file actions
415 lines (379 loc) · 11.9 KB
/
Commands.lua
File metadata and controls
415 lines (379 loc) · 11.9 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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
local AceAddon = LibStub("AceAddon-3.0")
local addon = AceAddon and AceAddon:GetAddon("SimpleUnitFrames", true)
if not addon then
return
end
local core = addon._core or {}
local defaults = core.defaults or {}
local addonName = core.addonName or "SimpleUnitFrames"
local CopyTableDeep = core.CopyTableDeep
function addon:TogglePerformanceDashboard()
if self.SyncThemeFromOptionsV2 then
self:SyncThemeFromOptionsV2()
end
if self.performanceLib then
if self.performanceLib.ToggleDashboard then
self.performanceLib:ToggleDashboard()
if self.ApplyThemeToPerformanceWindows then
self:ApplyThemeToPerformanceWindows()
end
return
end
if self.performanceLib.ShowDashboard then
self.performanceLib:ShowDashboard()
if self.ApplyThemeToPerformanceWindows then
self:ApplyThemeToPerformanceWindows()
end
return
end
end
self:Print(addonName .. ": PerformanceLib dashboard is unavailable.")
end
function addon:ShowLauncherHelp()
self:Print(addonName .. ": /suf (open options)")
self:Print(addonName .. ": /suf ui v2|legacy|toggle|status")
self:Print(addonName .. ": /suf minimap show|hide|toggle|reset")
self:Print(addonName .. ": /suf perflib")
self:Print(addonName .. ": /sufperf (performance dashboard)")
self:Print(addonName .. ": /sufprofile <start|stop|sample|analyze> (alias -> /perflib profile ...)")
self:Print(addonName .. ": /libperf (alias -> /sufperf)")
self:Print(addonName .. ": /suf test (interactive test panel)")
self:Print(addonName .. ": /suf debug")
self:Print(addonName .. ": /suf status")
self:Print(addonName .. ": /suf protected (see also: /SUFprotected help)")
self:Print(addonName .. ": /suf absorbdebug on|off|toggle|status")
self:Print(addonName .. ": /sufabsorbdebug on|off|toggle|status")
self:Print(addonName .. ": /suf coalescer [reset]")
self:Print(addonName .. ": /suf skinreport (Blizzard skin coverage report)")
self:Print(addonName .. ": /suf install")
self:Print(addonName .. ": /suf tutorial")
self:Print(addonName .. ": /sufskinreport (direct alias)")
self:Print(addonName .. ": /suf reload [now]")
self:Print(addonName .. ": /suf resources")
self:Print(addonName .. ": /suf help")
end
function addon:StartInstallFlow()
self:ShowOptions()
if self.optionsV2Frame and self.optionsV2Frame.SetPage then
self.optionsV2Frame:SetPage("importexport")
end
if self.optionsFrame and self.optionsFrame.BuildTab then
self.optionsFrame:BuildTab("importexport")
end
self.db.profile.optionsUI = self.db.profile.optionsUI or CopyTableDeep(defaults.profile.optionsUI)
self.db.profile.optionsUI.installFlowSeen = true
end
function addon:ShowTutorialOverview(forceShow)
self.db.profile.optionsUI = self.db.profile.optionsUI or CopyTableDeep(defaults.profile.optionsUI)
if not forceShow and self.db.profile.optionsUI.tutorialSeen == true then
return
end
self.db.profile.optionsUI.tutorialSeen = true
self:EnsurePopupDialog("SUF_TUTORIAL_OVERVIEW", {
text = "SimpleUnitFrames Quick Start\n\n1) /suf to open options\n2) Use Import / Export tab for installer + profile import\n3) /suf status for runtime snapshot\n4) /suf debug for diagnostics",
button1 = "Open Options",
button2 = "Later",
OnAccept = function()
if addon then
addon:ShowOptions()
end
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3,
})
self:ShowPopup("SUF_TUTORIAL_OVERVIEW")
end
function addon:HandleProtectedOpsSlash(msg)
local input = (msg or ""):match("^%s*(.-)%s*$")
if input == "" or input == "stats" then
if self.ProtectedOperations then
self:Print(self.ProtectedOperations:ExportStatsForChat())
else
self:Print(addonName .. ": ProtectedOperations system not available.")
end
return
end
local command = input:lower()
if command == "reset" then
if self.ProtectedOperations then
self.ProtectedOperations:ResetStats()
self:Print(addonName .. ": Protected operations statistics reset.")
end
return
end
if command == "queue" then
if self.ProtectedOperations then
local queue = self.ProtectedOperations._queue
self:Print(string.format("|cffFFD700Queue Contents (%d items):|r", #queue))
if #queue == 0 then
self:Print(" (empty)")
else
for i, op in ipairs(queue) do
self:Print(string.format(" [%d] type=%s priority=%s key=%s",
i,
op.type or "unnamed",
op.priority or "NORMAL",
op.key or "none"))
end
end
end
return
end
if command == "help" then
if self.ProtectedOperations then
self:Print(self.ProtectedOperations:GetHelpText())
end
return
end
-- Default: show stats
if self.ProtectedOperations then
self:Print(self.ProtectedOperations:ExportStatsForChat())
end
end
function addon:HandleAbsorbDebugSlash(msg)
local mode = (msg or ""):match("^%s*(.-)%s*$")
mode = mode and mode:lower() or ""
mode = mode:match("^(%S+)") or mode
self:EnsureDebugConfig()
local dbg = self.db.profile.debug
dbg.systems = dbg.systems or {}
local function PrintStatus()
local enabled = dbg.systems.AbsorbEvents == true
local tagsEnabled = dbg.absorbTags == true
self:Print(addonName .. ": AbsorbEvents debug is " .. (enabled and "ON" or "OFF") .. ".")
self:Print(addonName .. ": AbsorbTags debug is " .. (tagsEnabled and "ON" or "OFF") .. ".")
-- Print call counts if available
if self._absorbTagCallCount and next(self._absorbTagCallCount) then
self:Print(addonName .. ": Tag call counts:")
for k, v in pairs(self._absorbTagCallCount) do
self:Print((" %s: %d"):format(tostring(k), tonumber(v) or 0))
end
else
self:Print(addonName .. ": No tag calls recorded yet.")
end
end
if mode == "" or mode == "status" or mode == "stats" then
PrintStatus()
return
end
if mode == "on" or mode == "enable" or mode == "1" then
dbg.enabled = true
dbg.systems.AbsorbEvents = true
dbg.absorbTags = true
self:Print(addonName .. ": AbsorbEvents and AbsorbTags debug enabled.")
return
end
if mode == "off" or mode == "disable" or mode == "0" then
dbg.systems.AbsorbEvents = false
dbg.absorbTags = false
self:Print(addonName .. ": AbsorbEvents and AbsorbTags debug disabled.")
return
end
if mode == "toggle" then
dbg.enabled = true
local newState = not (dbg.systems.AbsorbEvents == true)
dbg.systems.AbsorbEvents = newState
dbg.absorbTags = newState
PrintStatus()
return
end
if mode == "help" then
self:Print(addonName .. ": /suf absorbdebug on|off|toggle|status")
self:Print(addonName .. ": /sufabsorbdebug on|off|toggle|status")
return
end
self:Print(addonName .. ": Unknown absorbdebug command. Use /suf absorbdebug help")
end
function addon:HandleSUFSlash(msg)
local input = (msg or ""):match("^%s*(.-)%s*$")
if input == "" then
self:ShowOptions()
return
end
local command, rest = input:match("^(%S+)%s*(.-)$")
command = command and command:lower() or ""
rest = rest and rest:lower() or ""
if command == "help" then
self:ShowLauncherHelp()
return
end
if command == "debug" then
self:ToggleDebugPanel()
return
end
if command == "test" then
self:ShowTestPanel()
return
end
if command == "reload" or command == "rl" then
if rest == "now" then
-- Force immediate reload without prompt
if addon.SafeReload then
addon:SafeReload()
else
ReloadUI()
end
else
-- Show confirmation dialog
self:PromptReloadUI("Reload SUF/UI now?")
end
return
end
if command == "status" or command == "report" then
self:PrintStatusReport()
return
end
if command == "install" or command == "installer" then
self:StartInstallFlow()
return
end
if command == "tutorial" or command == "tips" then
self:ShowTutorialOverview(true)
return
end
if command == "resources" or command == "resource" or command == "classpower" then
self:PrintClassResourceAudit()
return
end
if command == "perflib" or command == "perf" then
self:TogglePerformanceDashboard()
return
end
if command == "protected" then
self:HandleProtectedOpsSlash(rest)
return
end
if command == "absorbdebug" or command == "absdebug" then
self:HandleAbsorbDebugSlash(rest)
return
end
if command == "coalescer" or command == "coalescers" then
local mode = (rest:match("^(%S+)") or ""):lower()
if mode == "reset" then
if self.ResetLowRiskCoalescerStats then
self:ResetLowRiskCoalescerStats()
self:Print(addonName .. ": Low-risk coalescer counters reset.")
else
self:Print(addonName .. ": Coalescer counters are unavailable.")
end
return
end
if self.PrintLowRiskCoalescerStats then
self:PrintLowRiskCoalescerStats()
else
self:Print(addonName .. ": Coalescer counters are unavailable.")
end
return
end
if command == "poolstats" or command == "indicatorpool" or command == "pool" then
if self.IndicatorPoolManager then
local subcommand = (rest:match("^(%S+)") or ""):lower()
if subcommand == "reset" then
-- In-game command to verify pooling functionality
self:Print(addonName .. ": Indicator pool reset command (for testing)")
self.IndicatorPoolManager:ReleaseAll("threat_glow")
self.IndicatorPoolManager:ReleaseAll("highlight_overlay")
self.IndicatorPoolManager:ReleaseAll("dispel_border")
self.IndicatorPoolManager:ReleaseAll("range_fade")
self.IndicatorPoolManager:ReleaseAll("custom_glow")
return
end
self.IndicatorPoolManager:PrintStats()
else
self:Print(addonName .. ": IndicatorPoolManager unavailable.")
end
return
end
if command == "skinreport" or command == "skincoverage" or command == "blizzskin" then
if self.PrintBlizzardSkinCoverageReport then
self:PrintBlizzardSkinCoverageReport()
elseif self.PrintBlizzardSkinReport then
self:PrintBlizzardSkinReport()
else
self:Print(addonName .. ": Blizzard skin report is unavailable.")
end
return
end
if command == "ui" then
local mode = (rest:match("^(%S+)") or ""):lower()
if mode == "" or mode == "help" then
self:Print(addonName .. ": /suf ui v2|legacy|toggle|status")
return
end
if mode == "v2" then
if self.SetOptionsV2Enabled then
self:SetOptionsV2Enabled(true, true)
end
if self.ShowOptionsV2 then
self:ShowOptionsV2()
else
self:Print(addonName .. ": OptionsV2 is unavailable in this build.")
end
return
end
if mode == "legacy" then
if self.SetOptionsV2Enabled then
self:SetOptionsV2Enabled(false, true)
end
self:ShowOptions()
return
end
if mode == "toggle" then
local enabled = false
if self.IsOptionsV2Enabled then
enabled = self:IsOptionsV2Enabled() and true or false
end
if self.SetOptionsV2Enabled then
self:SetOptionsV2Enabled(not enabled, true)
end
if not enabled then
if self.ShowOptionsV2 then
self:ShowOptionsV2()
else
self:ShowOptions()
end
else
self:ShowOptions()
end
return
end
if mode == "status" then
local enabled = self.IsOptionsV2Enabled and self:IsOptionsV2Enabled()
self:Print(addonName .. ": Options UI mode is " .. (enabled and "V2" or "legacy") .. ".")
return
end
self:Print(addonName .. ": /suf ui v2|legacy|toggle|status")
return
end
if command == "minimap" or command == "icon" then
self.db.profile.minimap = self.db.profile.minimap or CopyTableDeep(defaults.profile.minimap)
if rest == "show" then
self.db.profile.minimap.hide = false
self:InitializeLauncher()
self:Print(addonName .. ": Minimap icon shown.")
return
elseif rest == "hide" then
self.db.profile.minimap.hide = true
self:ApplyLauncherVisibility()
self:Print(addonName .. ": Minimap icon hidden.")
return
elseif rest == "toggle" then
self.db.profile.minimap.hide = not self.db.profile.minimap.hide
self:ApplyLauncherVisibility()
self:Print(addonName .. ": Minimap icon " .. (self.db.profile.minimap.hide and "hidden." or "shown."))
return
elseif rest == "reset" then
self.db.profile.minimap.hide = false
self.db.profile.minimap.minimapPos = defaults.profile.minimap.minimapPos
self:InitializeLauncher()
self:Print(addonName .. ": Minimap icon reset.")
return
else
self:Print(addonName .. ": /suf minimap show|hide|toggle|reset")
return
end
end
self:ShowOptions()
end