Repository navigation
Expand file tree
/
Copy pathMechanicIntegration.lua
More file actions
797 lines (739 loc) · 23.1 KB
/
Copy pathMechanicIntegration.lua
File metadata and controls
797 lines (739 loc) · 23.1 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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
--------------------------------------------------------------------------------
-- Weekly Addon - MechanicLib Integration
-- Registers with Mechanic ecosystem for dashboard, testing, and debugging
--------------------------------------------------------------------------------
local ADDON_NAME, ns = ...
-- Attempt to load MechanicLib (optional dependency)
local MechanicLib = LibStub("MechanicLib-1.0", true)
if not MechanicLib then
return -- Mechanic not installed, skip integration
end
--------------------------------------------------------------------------------
-- Debug Buffer for Console Integration
--------------------------------------------------------------------------------
local debugBuffer = {}
local MAX_BUFFER_SIZE = 500
--------------------------------------------------------------------------------
-- Performance Tracking
--------------------------------------------------------------------------------
local perfBlocks = {
uiRefresh = 0, -- Row rendering
dataQuery = 0, -- Currency/Quest API polling
vaultLookup = 0, -- Vault activities API
journalTrack = 0, -- Loot message processing
}
-- Cumulative milliseconds; consumers sample deltas over a shared interval.
ns.PerfBlocks = perfBlocks
local lastPerfSample
local previousPerfBlocks = {}
local perfRates = {}
local function GetPerformanceRates()
local now = GetTime()
local elapsed = lastPerfSample and (now - lastPerfSample)
if not elapsed or elapsed < 0 then
for key, total in pairs(perfBlocks) do
previousPerfBlocks[key] = total
perfRates[key] = 0
end
lastPerfSample = now
elseif elapsed >= 1 then
for key, total in pairs(perfBlocks) do
perfRates[key] = math.max(0, total - previousPerfBlocks[key]) / elapsed
previousPerfBlocks[key] = total
end
lastPerfSample = now
end
return perfRates
end
local function AddToDebugBuffer(message, category)
table.insert(debugBuffer, {
timestamp = time(),
message = message,
category = category or "INFO",
})
-- Trim buffer if too large
while #debugBuffer > MAX_BUFFER_SIZE do
table.remove(debugBuffer, 1)
end
end
local function SetDebugEnabled(enabled)
if ns.Weekly and ns.Weekly.SetDebugEnabled then
ns.Weekly:SetDebugEnabled(enabled)
end
end
-- Hook into Weekly's print function to capture debug output
local originalPrintf = ns.Weekly and ns.Weekly.Printf
if originalPrintf then
ns.Weekly.Printf = function(self, ...)
local message = string.format(...)
AddToDebugBuffer(message, "OUTPUT")
return originalPrintf(self, ...)
end
end
--------------------------------------------------------------------------------
-- Test Definitions
--------------------------------------------------------------------------------
local testDefinitions = {
-- Core Action Tests
{
id = "core.currency.capped",
name = "Currency Status - Capped Detection",
category = "Core Actions",
description = "Verifies that currencies at weekly cap are correctly identified as capped",
run = function()
local startTime = debugprofilestop()
local context = {
quantity = 500,
maxWeeklyQuantity = 500,
quantityEarnedThisWeek = 500,
}
local result = ns.Actions.Tracker.GetCurrencyStatus(context)
local duration = (debugprofilestop() - startTime) / 1000
local passed = result.success and result.data.isCapped
return passed,
{
duration = duration,
message = passed and "Currency correctly identified as capped"
or "Failed to detect capped currency",
details = {
{
label = "success",
value = tostring(result.success),
status = result.success and "pass" or "fail",
},
{
label = "isCapped",
value = tostring(result.data and result.data.isCapped),
status = (result.data and result.data.isCapped) and "pass" or "fail",
},
{
label = "amount",
value = result.data and tostring(result.data.amount) or "nil",
status = "pass",
},
{ label = "max", value = result.data and tostring(result.data.max) or "nil", status = "pass" },
},
}
end,
},
{
id = "core.currency.uncapped",
name = "Currency Status - Uncapped Handling",
category = "Core Actions",
description = "Verifies that uncapped currencies (max=0) are handled correctly",
run = function()
local startTime = debugprofilestop()
local context = {
quantity = 12345,
maxWeeklyQuantity = 0,
maxQuantity = 0,
}
local result = ns.Actions.Tracker.GetCurrencyStatus(context)
local duration = (debugprofilestop() - startTime) / 1000
local passed = result.success and not result.data.isCapped
return passed,
{
duration = duration,
message = passed and "Uncapped currency handled correctly" or "Failed uncapped currency handling",
details = {
{
label = "success",
value = tostring(result.success),
status = result.success and "pass" or "fail",
},
{
label = "isCapped",
value = tostring(result.data and result.data.isCapped),
status = (result.data and not result.data.isCapped) and "pass" or "fail",
},
{
label = "amount",
value = result.data and tostring(result.data.amount) or "nil",
status = "pass",
},
},
}
end,
},
{
id = "core.quest.completed",
name = "Quest Status - Completed Detection",
category = "Core Actions",
description = "Verifies that completed quests are correctly detected",
run = function()
local startTime = debugprofilestop()
local context = {
ids = { 12345 },
isCompleted = function()
return true
end,
isOnQuest = function()
return false
end,
getObjectives = function()
return {}
end,
}
local result = ns.Actions.Tracker.GetQuestStatus(context)
local duration = (debugprofilestop() - startTime) / 1000
local passed = result.success and result.data.isCompleted
return passed,
{
duration = duration,
message = passed and "Quest completion detected" or "Failed to detect quest completion",
details = {
{
label = "success",
value = tostring(result.success),
status = result.success and "pass" or "fail",
},
{
label = "isCompleted",
value = tostring(result.data and result.data.isCompleted),
status = (result.data and result.data.isCompleted) and "pass" or "fail",
},
{
label = "resolvedId",
value = result.data and tostring(result.data.resolvedId) or "nil",
status = "pass",
},
},
}
end,
},
{
id = "core.quest.multiid",
name = "Quest Status - Multi-ID Resolution",
category = "Core Actions",
description = "Verifies that rotating quests (multiple IDs) resolve to the active variant",
run = function()
local startTime = debugprofilestop()
local context = {
ids = { 111, 222, 333 },
isCompleted = function()
return false
end,
isOnQuest = function(id)
return id == 222
end,
getObjectives = function()
return { { numFulfilled = 3, numRequired = 5 } }
end,
}
local result = ns.Actions.Tracker.GetQuestStatus(context)
local duration = (debugprofilestop() - startTime) / 1000
local passed = result.success and result.data.resolvedId == 222 and result.data.progress == 3
return passed,
{
duration = duration,
message = passed and "Multi-ID quest resolved correctly" or "Failed multi-ID resolution",
details = {
{
label = "success",
value = tostring(result.success),
status = result.success and "pass" or "fail",
},
{
label = "resolvedId",
value = result.data and tostring(result.data.resolvedId) or "nil",
status = (result.data and result.data.resolvedId == 222) and "pass" or "fail",
},
{
label = "progress",
value = result.data and tostring(result.data.progress) or "nil",
status = (result.data and result.data.progress == 3) and "pass" or "fail",
},
{ label = "max", value = result.data and tostring(result.data.max) or "nil", status = "pass" },
},
}
end,
},
{
id = "core.vault.slots",
name = "Vault Status - Slot Counting",
category = "Core Actions",
description = "Verifies vault slot completion counting (1 of 3 slots unlocked)",
run = function()
local startTime = debugprofilestop()
local context = {
activities = {
{ threshold = 1, progress = 1, level = 450 },
{ threshold = 4, progress = 2, level = 0 },
{ threshold = 8, progress = 0, level = 0 },
},
}
local result = ns.Actions.Tracker.GetVaultStatus(context)
local duration = (debugprofilestop() - startTime) / 1000
local passed = result.success and result.data.completed == 1 and result.data.max == 3
return passed,
{
duration = duration,
message = passed and "Vault slots counted correctly" or "Failed vault slot counting",
details = {
{
label = "success",
value = tostring(result.success),
status = result.success and "pass" or "fail",
},
{
label = "completed",
value = result.data and tostring(result.data.completed) or "nil",
status = (result.data and result.data.completed == 1) and "pass" or "fail",
},
{
label = "max",
value = result.data and tostring(result.data.max) or "nil",
status = (result.data and result.data.max == 3) and "pass" or "fail",
},
},
}
end,
},
-- Journal Tests
{
id = "journal.loot.parse",
name = "Journal - Loot Message Parsing",
category = "Journal",
description = "Parses item link and quantity from loot chat messages",
run = function()
local startTime = debugprofilestop()
local result = ns.Actions.Journal.ParseLootMessage({
message = "You receive loot: |cff1eff00|Hitem:12345:0:0:0:0:0:0:0:0|h[Test Item]|h|r x5.",
})
local duration = (debugprofilestop() - startTime) / 1000
local passed = result.success and result.data.itemID == 12345 and result.data.quantity == 5
return passed,
{
duration = duration,
message = passed and "Loot message parsed successfully" or "Failed to parse loot message",
details = {
{
label = "success",
value = tostring(result.success),
status = result.success and "pass" or "fail",
},
{
label = "itemID",
value = result.data and tostring(result.data.itemID) or "nil",
status = (result.data and result.data.itemID == 12345) and "pass" or "fail",
},
{
label = "quantity",
value = result.data and tostring(result.data.quantity) or "nil",
status = (result.data and result.data.quantity == 5) and "pass" or "fail",
},
},
}
end,
},
{
id = "journal.classify.herbs",
name = "Journal - Classify Gathering Material",
category = "Journal",
description = "Classifies trade goods by subclass (herbs, ore, leather, etc.)",
run = function()
local startTime = debugprofilestop()
local result = ns.Actions.Journal.ClassifyLootItem({
itemClassID = 7, -- Trade Goods
itemSubClassID = 9, -- Herb
expansionID = 10,
})
local duration = (debugprofilestop() - startTime) / 1000
local passed = result.success and result.data.isGathering and result.data.category == "Herb"
return passed,
{
duration = duration,
message = passed and "Herb correctly classified as gathering material"
or "Failed gathering classification",
details = {
{
label = "success",
value = tostring(result.success),
status = result.success and "pass" or "fail",
},
{
label = "isGathering",
value = tostring(result.data and result.data.isGathering),
status = (result.data and result.data.isGathering) and "pass" or "fail",
},
{
label = "category",
value = result.data and tostring(result.data.category) or "nil",
status = (result.data and result.data.category == "Herb") and "pass" or "fail",
},
},
}
end,
},
-- Data Layer Tests
{
id = "data.loader.seasons",
name = "Data Loader - Season Registration",
category = "Data",
description = "Verifies The War Within season data is registered and retrievable",
run = function()
local startTime = debugprofilestop()
local seasons = ns.Data and ns.Data:GetSeasons(11) -- The War Within (Exp 11)
local duration = (debugprofilestop() - startTime) / 1000
local passed = seasons and #seasons > 0
local seasonList = {}
if seasons then
for _, s in ipairs(seasons) do
table.insert(seasonList, tostring(s))
end
end
return passed,
{
duration = duration,
message = passed and string.format("Found %d seasons for TWW", seasons and #seasons or 0)
or "No seasons found",
details = {
{
label = "Data module",
value = ns.Data and "loaded" or "missing",
status = ns.Data and "pass" or "fail",
},
{
label = "Season count",
value = seasons and tostring(#seasons) or "0",
status = (seasons and #seasons > 0) and "pass" or "fail",
},
{
label = "Seasons",
value = #seasonList > 0 and table.concat(seasonList, ", ") or "none",
status = #seasonList > 0 and "pass" or "warn",
},
},
}
end,
},
}
local testResults = {}
--------------------------------------------------------------------------------
-- MechanicLib Registration
--------------------------------------------------------------------------------
MechanicLib:Register(ADDON_NAME, {
version = C_AddOns.GetAddOnMetadata(ADDON_NAME, "Version"),
-- Console Integration
getDebugBuffer = function()
return debugBuffer
end,
clearDebugBuffer = function()
wipe(debugBuffer)
end,
-- Testing Integration
tests = {
getAll = function()
local tests = {}
for _, def in ipairs(testDefinitions) do
table.insert(tests, {
id = def.id,
name = def.name,
category = def.category,
})
end
return tests
end,
getCategories = function()
return { "Core Actions", "Journal", "Data" }
end,
run = function(id)
for _, def in ipairs(testDefinitions) do
if def.id == id then
local success, passedOrErr, resultData = pcall(def.run)
if not success then
-- pcall failed, passedOrErr contains error message
testResults[id] = {
passed = false,
error = tostring(passedOrErr),
timestamp = time(),
}
return false
end
-- Test ran successfully, passedOrErr is the boolean result
-- resultData contains { duration, message, details }
local testPassed = passedOrErr == true
testResults[id] = {
passed = testPassed,
duration = resultData and resultData.duration,
message = resultData and resultData.message,
details = resultData and resultData.details,
timestamp = time(),
}
return testPassed
end
end
return false
end,
runAll = function()
local passedCount = 0
local total = 0
for _, def in ipairs(testDefinitions) do
total = total + 1
local success, passedOrErr, resultData = pcall(def.run)
if not success then
testResults[def.id] = {
passed = false,
error = tostring(passedOrErr),
timestamp = time(),
}
else
local testPassed = passedOrErr == true
testResults[def.id] = {
passed = testPassed,
duration = resultData and resultData.duration,
message = resultData and resultData.message,
details = resultData and resultData.details,
timestamp = time(),
}
if testPassed then
passedCount = passedCount + 1
end
end
end
return passedCount, total -- Return two values, not a table
end,
getResult = function(id)
return testResults[id]
end,
},
-- Inspect Integration (Watch List)
inspect = {
getWatchFrames = function()
local frames = {}
-- Main Tracker Window
if ns.UI and ns.UI.frame then
table.insert(frames, {
label = "Weekly Tracker",
frame = ns.UI.frame,
property = "Visibility",
})
end
-- Journal Window
if ns.JournalUI and ns.JournalUI.frame then
table.insert(frames, {
label = "Weekly Journal",
frame = ns.JournalUI.frame,
property = "Visibility",
})
end
return frames
end,
},
-- Performance Integration (Sub-metrics)
performance = {
getSubMetrics = function()
local rates = GetPerformanceRates()
return {
{
name = "UI Refresh",
msPerSec = rates.uiRefresh,
description = "Tracker processing and row updates",
},
{
name = "Data Query",
msPerSec = rates.dataQuery,
description = "Tracker data collection and sorting",
},
{
name = "Vault Lookup",
msPerSec = rates.vaultLookup,
description = "Weekly vault activities API",
},
{
name = "Journal",
msPerSec = rates.journalTrack,
description = "Loot message parsing and tracking",
},
}
end,
},
-- Tools Integration (Custom Panel)
tools = {
createPanel = function(container)
-- Title
local title = container:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 10, -10)
title:SetText("Weekly Tools")
local desc = container:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
desc:SetPoint("TOPLEFT", 10, -35)
desc:SetText("Quick actions for Weekly tracker management.")
-- Helper function to create buttons
local function CreateToolButton(parent, x, y, width, text, onClick)
local btn = CreateFrame("Button", nil, parent, "UIPanelButtonTemplate")
btn:SetPoint("TOPLEFT", parent, "TOPLEFT", x, y)
btn:SetSize(width, 24)
btn:SetText(text)
btn:SetScript("OnClick", onClick)
return btn
end
-- Row 1: Window Controls
local row1Label = container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row1Label:SetPoint("TOPLEFT", 10, -65)
row1Label:SetText("Windows:")
CreateToolButton(container, 80, -60, 100, "Toggle Tracker", function()
if ns.UI and type(ns.UI.Toggle) == "function" then
ns.UI:Toggle()
if ns.UI.frame and ns.UI.frame:IsShown() then
print("|cff00ff00Weekly:|r Tracker shown.")
else
print("|cff00ff00Weekly:|r Tracker hidden.")
end
else
print("|cffff0000Weekly:|r Tracker not available.")
end
end)
CreateToolButton(container, 185, -60, 100, "Toggle Journal", function()
if ns.JournalUI and type(ns.JournalUI.Toggle) == "function" then
ns.JournalUI:Toggle()
if ns.JournalUI.frame and ns.JournalUI.frame:IsShown() then
print("|cff00ff00Weekly:|r Journal shown.")
else
print("|cff00ff00Weekly:|r Journal hidden.")
end
else
print("|cffff0000Weekly:|r Journal not available.")
end
end)
-- Row 2: Data Controls
local row2Label = container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row2Label:SetPoint("TOPLEFT", 10, -100)
row2Label:SetText("Data:")
CreateToolButton(container, 80, -95, 100, "Refresh Now", function()
if ns.UI and ns.UI.RefreshRows then
ns.UI:RefreshRows()
print("|cff00ff00Weekly:|r Tracker refreshed.")
else
print("|cffff0000Weekly:|r RefreshRows not available.")
end
end)
CreateToolButton(container, 185, -95, 120, "Reset Position", function()
if ns.UI and ns.UI.frame then
ns.UI.frame:ClearAllPoints()
ns.UI.frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
if type(ns.UI.SavePosition) == "function" then
ns.UI:SavePosition()
end
print("|cff00ff00Weekly:|r Position reset to center.")
end
end)
-- Row 3: Sort Options
local row3Label = container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row3Label:SetPoint("TOPLEFT", 10, -135)
row3Label:SetText("Sorting:")
CreateToolButton(container, 80, -130, 150, "Toggle Complete Sort", function()
if ns.Config then
ns.Config.sortCompletedBottom = not ns.Config.sortCompletedBottom
local state = ns.Config.sortCompletedBottom and "ON" or "OFF"
print("|cff00ff00Weekly:|r Sort completed to bottom: " .. state)
if ns.UI and ns.UI.RefreshRows then
ns.UI:RefreshRows()
end
end
end)
-- Row 4: Discovery Tool (Dev)
local row4Label = container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row4Label:SetPoint("TOPLEFT", 10, -170)
row4Label:SetText("Discovery:")
-- Discovery info text
local discoveryInfo = container:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
discoveryInfo:SetPoint("TOPLEFT", 10, -195)
discoveryInfo:SetWidth(280)
discoveryInfo:SetJustifyH("LEFT")
-- Update discovery info
local function UpdateDiscoveryInfo()
if ns.Discovery and ns.Discovery.tracker then
local tracker = ns.Discovery.tracker
local currCount = 0
local questCount = 0
if tracker.items then
for _id in pairs(tracker.items.currency or {}) do
currCount = currCount + 1
end
for _id in pairs(tracker.items.quest or {}) do
questCount = questCount + 1
end
end
local lastSaved = ""
if WeeklyDB and WeeklyDB.dev and WeeklyDB.dev.discovery then
lastSaved = WeeklyDB.dev.discovery.lastSavedFormatted or ""
end
local text = string.format("Logged: %d currencies, %d quests", currCount, questCount)
if lastSaved ~= "" then
text = text .. "\nLast saved: " .. lastSaved
end
discoveryInfo:SetText(text)
discoveryInfo:SetTextColor(1, 1, 1)
elseif ns.Discovery then
discoveryInfo:SetText("Discovery not initialized yet")
discoveryInfo:SetTextColor(0.7, 0.7, 0.7)
else
discoveryInfo:SetText("Discovery not available (dev build only)")
discoveryInfo:SetTextColor(0.5, 0.5, 0.5)
end
end
UpdateDiscoveryInfo()
CreateToolButton(container, 80, -165, 130, "Open Discovery...", function()
if ns.Discovery then
if not ns.Discovery.tracker and ns.TrackerCore then
ns.Discovery:Initialize()
end
ns.Discovery:Toggle()
UpdateDiscoveryInfo()
else
print("|cffff0000Weekly:|r Discovery not available (dev build only).")
end
end)
CreateToolButton(container, 215, -165, 100, "Clear Logged", function()
if ns.Discovery and ns.Discovery.tracker then
ns.Discovery.tracker:Clear()
ns.Discovery:Save()
print("|cff00ff00Weekly:|r Discovery log cleared.")
UpdateDiscoveryInfo()
else
print("|cffff0000Weekly:|r Discovery not available.")
end
end)
-- Footer
local footer = container:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
footer:SetPoint("BOTTOM", 0, 10)
footer:SetText("Use /weekly for more options. Tests available in Tests tab.")
end,
},
-- Settings exposed in Mechanic
settings = {
debugMode = {
type = "toggle",
name = "Debug Mode",
get = function()
if not ns.Config then
return false
end
if type(ns.Config.debug) == "table" then
return ns.Config.debug.enabled == true
end
return ns.Config.debug == true
end,
set = function(v)
SetDebugEnabled(v)
end,
},
sortCompletedBottom = {
type = "toggle",
name = "Sort Completed to Bottom",
get = function()
return ns.Config and ns.Config.sortCompletedBottom or false
end,
set = function(v)
if ns.Config then
ns.Config.sortCompletedBottom = v
if ns.UI then
ns.UI:RefreshRows()
end
end
end,
},
},
})
-- Log successful registration
AddToDebugBuffer("MechanicLib integration loaded", "LOAD")