Repository navigation
Expand file tree
/
Copy pathOptions.lua
More file actions
3790 lines (3714 loc) · 159 KB
/
Copy pathOptions.lua
File metadata and controls
3790 lines (3714 loc) · 159 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
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local addonName, addonTable = ...
setfenv(1, _G.SlackHacks)
local ADDON_DISPLAY_NAME = "SlackHacks v" .. getAddonVersion()
dbDefaults = {
global = {
configVersion = CONFIG_VERSION,
addonVersion = nil,
logs = {
debug = {},
error = {},
isDebugging = false,
errorLoggingEnabled = true,
logPurgeEnabled = true,
logPurgeHours = 48,
},
},
char = {
cache = {
lastKnownGildedStashesRemaining = nil,
lastKnownGildedStashesResetAt = nil
},
reminders = {
talents = {
-- Keyed by specialization ID. Loadouts are trait config IDs; nil means "Off" (contexts) or "Use Default"
-- (mythics, keyed by Mythic+ challenge map ID; raidBosses, keyed by encounter ID).
specs = {
["*"] = {
contexts = {},
perMythicEnabled = false,
mythics = {},
-- Additive defaults: existing character/spec choices are unchanged; boss-room reminders are opt-in.
perRaidBossEnabled = false,
raidBosses = {}
}
}
}
}
},
profile = {
minimapIcon = {
enabled = true,
minimapPos = 220,
},
inventory = {
autoSellGreyItems = false,
autoRepair = false,
autoRepairMode = "personal",
hideBagsFrame = false
},
listviewBag = {
enabled = false,
showListviewBag = false,
trackCrestCurrencies = true,
columnOrder = { "quantity", "name", "ilvl", "armorType", "armorSlot", "bind" },
protectedItems = {},
trashItems = {},
autoSellMarkedItems = false,
point = nil
},
controls = {
maximumCameraZoom = false,
enableDynamicCamera = false
},
-- Additive, opt-in defaults preserve existing profiles without a data migration.
utilities = {
tomtomWayCommand = false
},
graphics = {
enabled = false,
enableGroundEffectDensity = false,
groundEffectDensity = 16,
enableGroundEffectFade = false,
groundEffectFade = 70,
enableGroundEffectDist = false,
groundEffectDist = 70,
enableLodObjectFadeScale = false,
lodObjectFadeScale = 100,
enableLodObjectCullSize = false,
lodObjectCullSize = 15,
enableTerrainLodDist = false,
terrainLodDist = 400,
resampleAlwaysSharpen = false,
enableReflectionMode = false,
reflectionMode = 0,
enableWeatherDensity = false,
weatherDensity = 2
},
mouseRing = {
enabled = false,
showOutOfCombat = false,
scale = 50,
opacity = 100,
color = { r = 1, g = 1, b = 1 }
},
quest = {
enabled = false,
autoAccept = false,
autoComplete = false,
autoClickFirstOption = false,
autoClickFirstOptionMythicOnly = false,
numberKeys = false,
spacebar = false,
questItemButton = false
},
combat = {
raiseCastingNameplates = false,
paladin = {
trackHolyShockCharges = false,
onlyInCombat = false,
point = "CENTER",
relativePoint = "CENTER",
x = 0,
y = 0
}
},
windows = {
enabled = false, -- overall switch for the whole Windows module
movableToasts = false, -- adds Blizzard's toast popups (loot, mounts, achievements, etc.) as a draggable box in the real Edit Mode
scalingZoneMap = false, -- adds a "Change Scale" slider to the Zone Map tab's menu and applies its saved scale
movable = {
enabled = false, -- drag registered Blizzard windows by their title bar
modifierKey = "NONE", -- "NONE" | "SHIFT" | "CTRL" | "ALT" -- held to drag a registered frame
savePositionStrategy = "permanent", -- "off" | "session" | "permanent"
points = {}
},
scaling = {
enabled = false, -- modifierKey + mouse wheel over a title bar resizes a registered frame
modifierKey = "NONE", -- "NONE" | "SHIFT" | "CTRL" | "ALT" -- held to scale a registered frame
saveStrategy = "permanent", -- "off" | "session" | "permanent"
scales = {}
}
},
minimap = {
enabled = false,
shape = "circle",
showIconsOnHover = false,
showAddonIconsOnHover = false,
hideDiel = false,
showAllMinimapTracking = false,
alpha = 100,
fadeEnabled = false,
combatAlpha = 100,
movingAlpha = 100,
showZoneText = true,
showClock = true,
showTracking = true,
showCalendar = true,
showInstanceDifficulty = true,
showExpansionLandingPage = true,
showAddonCompartment = true,
addonsInCompartment = false
},
reminders = {
enabled = true,
buffs = {
enabled = false,
point = "TOP",
relativePoint = "TOP",
x = 0,
y = -130,
iconSize = 150,
iconGap = 6,
showGlow = true,
showIfExpiring = true,
durationPosition = "below",
lastUsedItems = {},
contentTypes = {
mythicDungeons = true,
nonLfrRaids = true
},
categories = {
food = true,
flask = true,
oil = true,
rune = false
}
},
talents = {
enabled = false,
-- Position of the switch-talents prompt.
prompt = {
point = "TOP",
relativePoint = "TOP",
x = 0,
y = -60
}
}
},
selfVendor = {
enabled = false,
source = "icyveins",
requirePrefix = false,
chatPrefix = "!",
guildOnly = false,
autoTradeMode = 0,
autoTradeOffAfterGroup = false,
modes = {
[Enum.SelfVendorMode.CONSUMABLES] = { enabled = false },
[Enum.SelfVendorMode.FLASK] = { enabled = false },
[Enum.SelfVendorMode.OIL] = { enabled = false },
[Enum.SelfVendorMode.AUGMENT_RUNES] = { enabled = false, runeQuantity = 5 },
[Enum.SelfVendorMode.AUGMENTS] = { enabled = false },
[Enum.SelfVendorMode.VANTUS_RUNE] = { enabled = false },
}
},
infoDisplay = {
enabled = true,
weeklies = {
enabled = false,
trackDelves = false
},
charSheet = {
enabled = true,
gearStats = true,
itemLevel = true,
upgradeTrack = true,
maxUpgradeStar = false,
slotWatermark = true,
secondaryStats = true,
tertiaryStats = false,
itemStats = true,
highWatermarkColoring = true,
enchants = true,
gemSockets = true,
},
guildieList = {
enabled = false,
lockPosition = false,
nonInteractive = false,
minimized = false,
fitToContent = true,
opacity = 0.5, -- Edit Mode's default DamageMeter "Background Transparency" (50 -> 0.5 alpha).
sortBy = "name", -- "name" or "zone"
showInstanceIcons = true,
showRankIcons = true,
showFactionIcons = true,
factionIconsOppositeOnly = true,
showGroupIcons = true,
point = "CENTER",
relativePoint = "CENTER",
x = 0,
y = 0,
width = 260,
height = 200,
},
friendsList = {
enabled = false,
lockPosition = false,
nonInteractive = false,
minimized = false,
fitToContent = true,
opacity = 0.5, -- Edit Mode's default DamageMeter "Background Transparency" (50 -> 0.5 alpha).
sortBy = "name", -- "name" (the friends list's order) or "zone"
onlyFavorites = false,
onlyWoW = true,
onlySameWoWVersion = false, -- Only applies while onlyWoW is on.
showInstanceIcons = true,
showGameIcons = true,
showFactionIcons = true,
factionIconsOppositeOnly = true,
showGroupIcons = true,
point = "CENTER",
relativePoint = "CENTER",
x = 280, -- Beside the Guildie List's default spot rather than on top of it.
y = 0,
width = 300,
height = 200,
},
-- The Players Online window that stacks the Friends and Guildie lists (InfoDisplay.lua).
playersOnline = {
stacked = false,
lockPosition = false,
nonInteractive = false,
stackOrder = "friends", -- "friends" (Friends, Guildies) or "guildies" (Guildies, Friends)
minimized = false,
opacity = 0.5, -- Edit Mode's default DamageMeter "Background Transparency".
fitToContent = true,
collapsed = { friends = false, guildies = false }, -- Per-list section collapse state.
point = "CENTER",
relativePoint = "CENTER",
x = 0,
y = 0,
width = 300,
height = 300,
}
}
}
}
-- Documentation for AceConfig "Options" tables: https://www.wowace.com/projects/ace3/pages/ace-config-3-0-options-tables
WIP_MODULES = {
{
key = { "reminders", "buffs" },
name = "Consumable Buff Reminders",
enableOptions = { { "enabled" } },
disable = function()
if Self.db and Self.db.profile and Self.db.profile.reminders then
Self.db.profile.reminders.buffs.enabled = false
end
if Self.Buffs and Self.Buffs.Refresh then
Self.Buffs:Refresh()
end
end
},
{
key = "combat",
name = "Combat",
enableOptions = { { "raiseCastingNameplates" }, { "paladin", "trackHolyShockCharges" } },
disable = function()
if Self.db and Self.db.profile and Self.db.profile.combat then
Self.db.profile.combat.raiseCastingNameplates = false
if Self.db.profile.combat.paladin then
Self.db.profile.combat.paladin.trackHolyShockCharges = false
end
end
resetNameplateCastLift()
if Self.ChargeTracking and Self.ChargeTracking.Refresh then
Self.ChargeTracking:Refresh()
end
end
},
}
RETAIL_MODULES = {
{ key = "reminders", name = "Reminders" },
{ key = { "combat", "paladin" }, name = "Paladin" },
{ key = "vendor", name = "Self Vendor" },
{ key = { "infoDisplay", "weeklies" }, name = "Weeklies" },
}
-- Modules that need Retail's modern UI, which WoW Forever shares since it's built on the Retail client.
RETAIL_OR_FOREVER_MODULES = {
{ key = { "infoDisplay", "guildieList" }, name = "Guildie List" },
{ key = { "infoDisplay", "friendsList" }, name = "Friends List" },
}
-- mod.key is a plain string for a top-level options.args entry, or a table of keys to walk through
-- nested .args groups (e.g. {"inventory", "listviewBag"} ).
local function resolveOptionGroup(key)
if type(key) == "string" then
return options and options.args and options.args[key]
end
local group = options and options.args and options.args[key[1]]
for i = 2, #key do
group = group and group.args and group.args[key[i]]
end
return group
end
--- Ask for confirmation before turning on an experimental feature, but never when disabling it.
---@param _ table AceConfig option info.
---@param value boolean Requested enabled state.
---@return string|nil Warning text when enabling, or nil to skip confirmation.
local function confirmWIPEnable(_, value)
if value then
return "This is a Work In Progress (WIP) module and may not function correctly currently. Are you sure you want to enable it?"
end
end
--- Decorate WIP groups and require confirmation for their feature-enabling checkboxes.
local function applyWIPOptionsDecoration()
for _, mod in ipairs(WIP_MODULES) do
local group = resolveOptionGroup(mod.key)
if group then
if not group.name:find("%(WIP%)") then
group.name = "(WIP) " .. group.name
end
local originalDesc = group.desc or ""
if not originalDesc:find("%[Work in Progress%]") then
group.desc = "|cffff8000[Work in Progress]|r " .. originalDesc
end
group.icon = 134070
for _, path in ipairs(mod.enableOptions or {}) do
local option = group
for _, key in ipairs(path) do
option = option.args[key]
end
option.confirm = confirmWIPEnable
end
if group.args then
-- In AceConfigDialog, negative orders sort AFTER positive orders (designed for bottom/footer buttons).
-- To put something at the very top, order must be >= 0 and smaller than any positive order.
-- Shift all existing non-negative args up by 1, and set wipWarning order = 0.
for key, arg in pairs(group.args) do
if key ~= "wipWarning" and type(arg) == "table" and type(arg.order) == "number" and arg.order >= 0 then
arg.order = arg.order + 1
end
end
group.args.wipWarning = {
name = "|cffff8000Warning:|r This module is a work in progress and currently experimental. Use |cffffffff/slack wipoff|r to disable all WIP modules.",
type = "description",
order = 0
}
end
end
end
end
--- Ask before enabling Blizzard-frame modifications while EllesmereUI is loaded.
---@param _ table AceConfig option info.
---@param value boolean Requested enabled state.
---@return string|nil Warning text when confirmation is required.
local function confirmEllesmereUIEnable(_, value)
if not value then return end
local isLoaded = (C_AddOns and C_AddOns.IsAddOnLoaded) or _G.IsAddOnLoaded
if isLoaded and isLoaded("EllesmereUI") then
return "EllesmereUI detected. This module modifies the standard Blizzard frames and will likely not work with your interface. Are you sure you want to enable it?"
end
end
--- Require compatibility confirmation on controls that activate Blizzard-frame modifications.
local function applyEllesmereUIConfirmations()
local paths = {
{ "inventory", "hideBagsFrame" },
{ "inventory", "listviewBag", "enabled" },
{ "minimap", "enabled" },
{ "infoDisplay", "weeklies", "enabled" },
{ "infoDisplay", "charSheet", "enabled" },
{ "windows", "enabled" },
{ "windows", "movableToasts" },
{ "windows", "scalingZoneMap" },
{ "windows", "movable", "enabled" },
{ "windows", "scaling", "enabled" },
}
for _, path in ipairs(paths) do
local option = options
for _, key in ipairs(path) do option = option.args[key] end
option.confirm = confirmEllesmereUIEnable
end
--- Preserve the WIP warning and include the compatibility warning when EllesmereUI is loaded.
---@param info table AceConfig option info.
---@param value boolean Requested enabled state.
---@return string|nil Applicable warnings, or nil when disabling.
options.args.combat.args.raiseCastingNameplates.confirm = function(info, value)
local wipWarning = confirmWIPEnable(info, value)
local compatibilityWarning = confirmEllesmereUIEnable(info, value)
if compatibilityWarning then return wipWarning .. "\n\n" .. compatibilityWarning end
return wipWarning
end
-- The parent switch can reactivate these modules without touching their own checkboxes.
--- Warn when enabling Info Display would also activate a potentially conflicting child.
---@param info table AceConfig option info.
---@param value boolean Requested enabled state.
---@return string|nil Compatibility warning, or nil.
options.args.infoDisplay.args.enabled.confirm = function(info, value)
if db.profile.infoDisplay.charSheet.enabled or db.profile.infoDisplay.weeklies.enabled then
return confirmEllesmereUIEnable(info, value)
end
end
end
local function hideNonRetailOptions()
for _, mod in ipairs(RETAIL_MODULES) do
local group = resolveOptionGroup(mod.key)
if group then
group.hidden = function() return not isRetail() end
end
end
for _, mod in ipairs(RETAIL_OR_FOREVER_MODULES) do
local group = resolveOptionGroup(mod.key)
if group then
group.hidden = function() return not isRetailOrForever() end
end
end
end
function openOptions()
-- If Blizzard SettingsPanel is already open, toggle it closed:
if SettingsPanel and SettingsPanel:IsShown() then
HideUIPanel(SettingsPanel)
return
end
local categoryID = Self.configCategoryID or (Self.configDialog and Self.configDialog.name)
if Settings and Settings.OpenToCategory and categoryID and not InCombatLockdown() then
Settings.OpenToCategory(categoryID)
return
end
if InterfaceOptionsFrame_OpenToCategory and Self.configDialog and not InCombatLockdown() then
if InterfaceOptionsFrame and InterfaceOptionsFrame:IsShown() then
InterfaceOptionsFrame:Hide()
return
end
InterfaceOptionsFrame_OpenToCategory(Self.configDialog)
return
end
local acd = LibStub("AceConfigDialog-3.0")
if acd.OpenFrames and acd.OpenFrames["SlackHacks"] and acd.OpenFrames["SlackHacks"]:IsShown() then
acd:Close("SlackHacks")
else
acd:Open("SlackHacks")
end
end
toggleOptions = openOptions
function reportBugs()
if Self.Debug and Self.Debug.ReportErrors then
Self.Debug:ReportErrors()
end
end
-----------------------------------------------------------------------
-- Minimap Addon Icon (LibDBIcon) & Context Menu
-----------------------------------------------------------------------
local MINIMAP_ICON_NAME = "SlackHacksErrorLog"
local minimapLDBObj = nil
local function isListviewBagActive()
local profile = Self.db and Self.db.profile
return profile and profile.listviewBag and profile.listviewBag.enabled
end
local function toggleListviewBag()
local profile = Self.db and Self.db.profile
if not profile then return end
if not profile.listviewBag then profile.listviewBag = {} end
local newState = not profile.listviewBag.enabled
profile.listviewBag.enabled = newState
profile.listviewBag.showListviewBag = newState
if newState then
if Self.ListviewBag then Self.ListviewBag:Enable() end
if Self.ListviewBag and Self.ListviewBag.SetShowListviewBag then Self.ListviewBag:SetShowListviewBag(true) end
else
if Self.ListviewBag and Self.ListviewBag.SetShowListviewBag then Self.ListviewBag:SetShowListviewBag(false) end
if Self.ListviewBag then Self.ListviewBag:Disable() end
end
local acr = LibStub and LibStub("AceConfigRegistry-3.0", true)
if acr then acr:NotifyChange("SlackHacks") end
end
local function isSquareMinimapActive()
local profile = Self.db and Self.db.profile
return profile and profile.minimap and profile.minimap.enabled and profile.minimap.shape == "square"
end
local function toggleSquareMinimap()
local profile = Self.db and Self.db.profile
if not profile then return end
if not profile.minimap then profile.minimap = {} end
local isSquare = profile.minimap.enabled and profile.minimap.shape == "square"
if isSquare then
profile.minimap.shape = "circle"
if Self.Minimap then Self.Minimap:Refresh() end
else
profile.minimap.enabled = true
profile.minimap.shape = "square"
if Self.Minimap then
Self.Minimap:Enable()
Self.Minimap:Refresh()
end
end
local acr = LibStub and LibStub("AceConfigRegistry-3.0", true)
if acr then acr:NotifyChange("SlackHacks") end
end
--- Returns whether Gear Stats overlays are currently showing (the Info Display, Char Sheet and Gear Stats are all on).
---@return boolean active
local function isGearStatsActive()
local infoDisplay = Self.db and Self.db.profile.infoDisplay
return (infoDisplay and infoDisplay.enabled and infoDisplay.charSheet.enabled and infoDisplay.charSheet.gearStats)
and true or false
end
--- Minimap toggle for Gear Stats. Turning it on also turns on whatever it depends on (the Info Display master
--- switch and the Char Sheet module); turning it off only hides Gear Stats so the other Info Display features stay.
local function toggleGearStats()
if not Self.db or not Self.CharSheet or not Self.InfoDisplay then return end
local infoDisplay = Self.db.profile.infoDisplay
if isGearStatsActive() then
Self.CharSheet:SetGearStatsEnabled(false)
return
end
-- Enable the Char Sheet first so the master switch's sub-module Enable() doesn't immediately abort it.
if not infoDisplay.charSheet.enabled then Self.CharSheet:SetCharSheetEnabled(true) end
if not infoDisplay.enabled then Self.InfoDisplay:SetEnabled(true) end
Self.CharSheet:SetGearStatsEnabled(true)
end
local function isMouseRingActive()
local profile = Self.db and Self.db.profile
return profile and profile.mouseRing and profile.mouseRing.enabled
end
local function toggleMouseRing()
local profile = Self.db and Self.db.profile
if not profile then return end
if not profile.mouseRing then profile.mouseRing = {} end
local newState = not profile.mouseRing.enabled
profile.mouseRing.enabled = newState
if Self.MouseRing then Self.MouseRing:SetEnabled(newState) end
local acr = LibStub and LibStub("AceConfigRegistry-3.0", true)
if acr then acr:NotifyChange("SlackHacks") end
end
--- Returns whether the Delves weekly tracker is showing (the Info Display, Weeklies and Track Delves are all on).
---@return boolean active
local function isTrackDelvesActive()
local infoDisplay = Self.db and Self.db.profile.infoDisplay
return (infoDisplay and infoDisplay.enabled and infoDisplay.weeklies.enabled and infoDisplay.weeklies.trackDelves)
and true or false
end
--- Minimap toggle for the Delves tracker. Turning it on also turns on the Info Display master switch and the
--- Weeklies module; turning it off disables Weeklies and Track Delves but leaves the rest of the Info Display alone.
local function toggleTrackDelves()
if not Self.db or not Self.Weeklies or not Self.InfoDisplay then return end
local newState = not isTrackDelvesActive()
-- Save Weeklies' settings before the master switch enables sub-modules, so its Enable() isn't aborted.
Self.Weeklies:SetTrackDelves(newState)
Self.Weeklies:SetEnabled(newState)
if newState and not Self.db.profile.infoDisplay.enabled then Self.InfoDisplay:SetEnabled(true) end
local acr = LibStub and LibStub("AceConfigRegistry-3.0", true)
if acr then acr:NotifyChange("SlackHacks") end
end
--- Returns a minimap checkbox's "is checked" callback for a Players Online list (Friends or Guildie List): checked
--- while both the Info Display master switch and the list are on.
---@param key string The list's `infoDisplay` settings key: "friendsList" or "guildieList".
---@return fun(): boolean isActive
local function listActiveChecker(key)
return function()
local infoDisplay = Self.db and Self.db.profile.infoDisplay
return (infoDisplay and infoDisplay.enabled and infoDisplay[key].enabled) and true or false
end
end
--- Returns a minimap checkbox's toggle callback for a Players Online list. Turning a list on also turns on the Info
--- Display master switch; turning it off only disables that list.
---@param key string The list's `infoDisplay` settings key: "friendsList" or "guildieList".
---@param moduleName string The list's AceModule name on Self: "FriendsList" or "GuildieList".
---@return fun() toggle
local function listToggler(key, moduleName)
local isActive = listActiveChecker(key)
return function()
local listModule = Self[moduleName]
if not Self.db or not listModule or not Self.InfoDisplay then return end
local newState = not isActive()
-- Saved before the master switch enables sub-modules, so the list's Enable() isn't aborted.
listModule:SetEnabled(newState)
if newState and not Self.db.profile.infoDisplay.enabled then Self.InfoDisplay:SetEnabled(true) end
end
end
local isFriendsListActive, toggleFriendsList = listActiveChecker("friendsList"), listToggler("friendsList", "FriendsList")
local isGuildieListActive, toggleGuildieList = listActiveChecker("guildieList"), listToggler("guildieList", "GuildieList")
local function openMinimapContextMenu(anchor)
if InCombatLockdown() then return end
if GameTooltip then GameTooltip:Hide() end
if MenuUtil and MenuUtil.CreateContextMenu then
MenuUtil.CreateContextMenu(anchor, function(owner, rootDescription)
rootDescription:CreateTitle(ADDON_DISPLAY_NAME)
rootDescription:CreateButton("Options", function()
openOptions()
end)
rootDescription:CreateButton("Report Bugs", function()
reportBugs()
end)
rootDescription:CreateCheckbox("Listview Bag", isListviewBagActive, toggleListviewBag)
rootDescription:CreateCheckbox("Square Minimap", isSquareMinimapActive, toggleSquareMinimap)
rootDescription:CreateCheckbox("Display Gear Stats", isGearStatsActive, toggleGearStats)
if isRetailOrForever() then
rootDescription:CreateCheckbox("Friends List", isFriendsListActive, toggleFriendsList)
rootDescription:CreateCheckbox("Guildies List", isGuildieListActive, toggleGuildieList)
end
rootDescription:CreateCheckbox("Mouse Ring", isMouseRingActive, toggleMouseRing)
rootDescription:CreateCheckbox("All NPC Auto-Interacts", isAllQuestAutomationEnabled, toggleAllQuestAutomation)
if isRetail and isRetail() then
rootDescription:CreateCheckbox("Track Delve Weeklies", isTrackDelvesActive, toggleTrackDelves)
end
end)
return
end
local menuList = {
{ text = ADDON_DISPLAY_NAME, isTitle = true, notCheckable = true },
{ text = "Options", func = function() openOptions() end, notCheckable = true },
{ text = "Report Bugs", func = function() reportBugs() end, notCheckable = true },
{ text = "Listview Bag", checked = isListviewBagActive, func = toggleListviewBag, isNotRadio = true, keepShownOnClick = true },
{ text = "Square Minimap", checked = isSquareMinimapActive, func = toggleSquareMinimap, isNotRadio = true, keepShownOnClick = true },
{ text = "Display Gear Stats", checked = isGearStatsActive, func = toggleGearStats, isNotRadio = true, keepShownOnClick = true },
{ text = "Mouse Ring", checked = isMouseRingActive, func = toggleMouseRing, isNotRadio = true, keepShownOnClick = true },
{ text = "All NPC Auto-Interacts", checked = isAllQuestAutomationEnabled, func = toggleAllQuestAutomation, isNotRadio = true, keepShownOnClick = true },
}
if isRetail and isRetail() then
table.insert(menuList, {
text = "Track Delve Weeklies",
checked = isTrackDelvesActive,
func = toggleTrackDelves,
isNotRadio = true,
keepShownOnClick = true,
})
end
local menuFrame = CreateFrame("Frame", "SlackHacksMinimapContextMenu", UIParent, "UIDropDownMenuTemplate")
EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU")
end
local function ensureMinimapBadge(button)
if button.errorBadge then return button.errorBadge end
local badge = CreateFrame("Frame", nil, button)
badge:SetFrameLevel(button:GetFrameLevel() + 5)
badge:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 2, -2)
badge:SetSize(16, 16)
local bg = badge:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints(badge)
bg:SetTexture("Interface\\CHARACTERFRAME\\TempPortraitAlphaMask")
bg:SetVertexColor(0.85, 0.08, 0.08, 0.95)
badge.bg = bg
local countText = badge:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
countText:SetFontObject(NumberFontNormalSmall or GameFontHighlightSmall)
countText:SetPoint("CENTER", badge, "CENTER", 0, 0)
countText:SetTextColor(1, 1, 1, 1)
badge.countText = countText
button.errorBadge = badge
return badge
end
local function initMinimapIcon()
local ldb = LibStub and LibStub("LibDataBroker-1.1", true)
local ldbi = LibStub and LibStub("LibDBIcon-1.0", true)
if not ldb or not ldbi then return end
if not minimapLDBObj then
minimapLDBObj = ldb:NewDataObject(MINIMAP_ICON_NAME, {
type = "data source",
text = ADDON_DISPLAY_NAME,
icon = SLACKHACKS_ICON,
OnClick = function(clickedButton, mouseButton)
if mouseButton == "RightButton" then
openMinimapContextMenu(clickedButton)
else
local list = (Self.Debug and Self.Debug.GetErrorLog and Self.Debug:GetErrorLog())
or (errorLogTable and errorLogTable()) or {}
if #list > 0 and Self.Debug and Self.Debug.ShowWindow then
Self.Debug:ShowWindow()
else
openOptions()
end
end
end,
OnTooltipShow = function(tooltip)
local list = (Self.Debug and Self.Debug.GetErrorLog and Self.Debug:GetErrorLog())
or (errorLogTable and errorLogTable()) or {}
local count = #list
tooltip:AddLine(ADDON_DISPLAY_NAME, 1, 0.82, 0)
if count > 0 then
tooltip:AddLine(" ")
if count == 1 then
tooltip:AddLine("You have 1 un-reported error in SlackHacks.", 1, 0.3, 0.3, true)
else
tooltip:AddLine(("You have %d un-reported errors in SlackHacks."):format(count), 1, 0.3, 0.3, true)
end
tooltip:AddLine("Left-click: Open error report window", 0.8, 0.8, 0.8)
else
tooltip:AddLine("Left-click: Open options", 0.8, 0.8, 0.8)
end
tooltip:AddLine("Right-click: Quick toggle menu", 0.8, 0.8, 0.8)
end,
OnEnter = function(button)
GameTooltip:SetOwner(button, "ANCHOR_BOTTOMLEFT")
if minimapLDBObj.OnTooltipShow then
minimapLDBObj.OnTooltipShow(GameTooltip)
end
GameTooltip:Show()
end,
OnLeave = function()
GameTooltip:Hide()
end,
})
end
if not ldbi:IsRegistered(MINIMAP_ICON_NAME) then
local iconDB = (db and db.profile and db.profile.minimapIcon)
or (Self.db and Self.db.profile and Self.db.profile.minimapIcon)
or { enabled = true, minimapPos = 220 }
ldbi:Register(MINIMAP_ICON_NAME, minimapLDBObj, iconDB)
end
end
function updateMinimapIcon()
local ldbi = LibStub and LibStub("LibDBIcon-1.0", true)
if not ldbi then return end
if not ldbi:IsRegistered(MINIMAP_ICON_NAME) then
initMinimapIcon()
end
local list = (Self.Debug and Self.Debug.GetErrorLog and Self.Debug:GetErrorLog())
or (errorLogTable and errorLogTable()) or {}
local count = #list
local button = ldbi:GetMinimapButton(MINIMAP_ICON_NAME)
local isIconEnabled = true
if db and db.profile and db.profile.minimapIcon then
if db.profile.minimapIcon.enabled ~= nil then
isIconEnabled = db.profile.minimapIcon.enabled
end
elseif Self.db and Self.db.profile and Self.db.profile.minimapIcon then
if Self.db.profile.minimapIcon.enabled ~= nil then
isIconEnabled = Self.db.profile.minimapIcon.enabled
end
end
local shouldShow = count > 0 or isIconEnabled
if shouldShow then
if button then
if count > 0 then
local badge = ensureMinimapBadge(button)
if count > 99 then
badge.countText:SetText("99+")
badge:SetSize(22, 16)
elseif count >= 10 then
badge.countText:SetText(tostring(count))
badge:SetSize(18, 16)
else
badge.countText:SetText(tostring(count))
badge:SetSize(16, 16)
end
badge:Show()
elseif button.errorBadge then
button.errorBadge:Hide()
end
end
ldbi:Show(MINIMAP_ICON_NAME)
else
if button and button.errorBadge then
button.errorBadge:Hide()
end
ldbi:Hide(MINIMAP_ICON_NAME)
end
end
Self.UpdateMinimapIcon = updateMinimapIcon
local function getWIPModuleNames()
local names = {}
for _, mod in ipairs(WIP_MODULES) do
table.insert(names, mod.name)
end
return table.concat(names, ", ")
end
local function printSlashHelp()
print(grey(icon(16)) .. " " .. color("FFD100")(ADDON_DISPLAY_NAME .. " Slash Commands:") .. "")
print(" " .. color("FFFFFF")("/slack") .. " - Open the SlackHacks config window")
print(" " .. color("FFFFFF")("/slack help") .. " - Show this list of slash commands")
print(" " .. color("FFFFFF")("/slack debug") .. " - Toggle debug mode on/off")
print(" " .. color("FFFFFF")("/slack bugs") .. " - View and report error logs")
print(" " .. color("FFFFFF")("/slack reset") .. " - Reset profile and addon state to defaults")
print(" " .. color("FFFFFF")("/slack wipoff") .. " - Disable work-in-progress modules (" .. getWIPModuleNames() .. ")")
print(" " .. color("FFFFFF")("/slack vend <mode>") .. " - Set Self Vendor's Automatic Trade Response (e.g. vantus, flask, buffs, off)")
end
function disableWIPModules()
if not Self.db or not Self.db.profile then return end
for _, mod in ipairs(WIP_MODULES) do
if mod.disable then
-- pcall'd so one module erroring out can't abort the loop and leave the remaining WIP
-- modules (and the options UI refresh below) never touched.
local ok, err = pcall(mod.disable)
if not ok then
geterrorhandler()(("SlackHacks: error disabling WIP module '%s': %s"):format(mod.name, tostring(err)))
end
end
end
local acr = LibStub("AceConfigRegistry-3.0", true)
if acr then
acr:NotifyChange("SlackHacks")
end
prn("disabled all WIP modules (" .. getWIPModuleNames() .. ").")
end
function handleSlashCommand(input)
local command = strlower(strtrim(input or ""))
-- "vendor" and "trade" are undocumented aliases of "vend"; everything after the word is the mode.
local vendCommand, vendArguments = command:match("^(%S+)%s*(.*)$")
if vendCommand == "vend" or vendCommand == "vendor" or vendCommand == "trade" then
Self.SelfVendor:HandleSlash(vendArguments)
elseif command == "" then
openOptions()
printSlashHelp()
elseif command == "help" then
printSlashHelp()
elseif command == "debug" then
toggleDebugging()
elseif command == "bugs" or command == "bug" or command == "bugreport" or command == "error" or command == "errors" or command == "errorlog" then
reportBugs()
elseif command == "reset" then
promptResetProfile()
elseif command == "wipoff" then
disableWIPModules()
elseif command == "induce-error" then
Self.Debug:InduceError()
else
prn("unknown command '" .. command .. "'. Type " .. color("FFFFFF")("/slack help") .. " for available commands.")
end
end
local selfVendorModeSorting = {
Enum.SelfVendorMode.FLASK,
Enum.SelfVendorMode.OIL,
Enum.SelfVendorMode.AUGMENT_RUNES,
Enum.SelfVendorMode.VANTUS_RUNE,
Enum.SelfVendorMode.CONSUMABLES,
Enum.SelfVendorMode.AUGMENTS,
}
local function listviewVendorItemValues()
local values = {}
for key, item in pairs(db.profile.listviewBag.trashItems or {}) do
if type(item) == "table" then
local suffix = "Quality " .. tostring(item.quality or 0) .. ", iLvl " .. tostring(item.itemLevel or 0)
if item.upgradeTrack and item.upgradeTrack ~= "" then
suffix = suffix .. ", " .. item.upgradeTrack
end
values[key] = (item.name or "Unknown item") .. " (" .. suffix .. ")"
else
values[key] = tostring(key)
end
end
return values
end
local function selfVendorModeOptions()
local args = {}
args.requestDescription = {
type = "description",
name = "|cffffd100Let players request buff items by saying phrases like 'crit oil rune' in group chat, /say, or a whisper to be auto-traded a crit flask, oil, and x runes from your inventory. Any combination of the below selected enabled options will work.|r",
fontSize = "medium",
width = "full",
order = 0,
}
args.enabled = {
name = "Enable Self Vendor Module",
desc = "Accept Self Vendor requests in party, raid, instance, say, and whisper chat. Requests may also include 'and', 'give', 'need', or 'please'.",
type = "toggle",
descStyle = "inline",
width = "full",
get = function() return db.profile.selfVendor.enabled end,
set = function(_, value) Self.SelfVendor:SetEnabled(value) end,
order = 2,
}
args.source = {
name = "Flask and Augments Source",
desc = "Select Wowhead or Icy Veins for optimal flask selection and Augments recommendations.",
descStyle = "inline",
type = "select",
values = { wowhead = "Wowhead", icyveins = "Icy Veins" },
get = function() return db.profile.selfVendor.source end,
set = function(_, value) Self.SelfVendor:SetSource(value) end,
order = 5,
}
args.requirePrefix = {
name = "Require Chat Prefix",
desc = "Only process requests that begin with the configured prefix.",
type = "toggle",
descStyle = "inline",
width = "full",
get = function() return db.profile.selfVendor.requirePrefix end,
set = function(_, value) db.profile.selfVendor.requirePrefix = value end,
order = 3,
}
args.chatPrefix = {
name = "Chat Prefix",
desc = "The first character(s) (or word) required at the beginning of the chat message to trigger vendoring.",
type = "input",
get = function() return db.profile.selfVendor.chatPrefix end,
set = function(_, value) db.profile.selfVendor.chatPrefix = value end,
validate = function(_, value) return #value > 0 and not value:find("%s") end,
disabled = function() return not db.profile.selfVendor.requirePrefix end,
order = 4,
}
args.guildOnly = {
name = "Only Vend to Fellow Guildies",
desc = "Ignore requests from players who aren't in your guild, including group members.",
type = "toggle",
descStyle = "inline",
width = "full",
get = function() return db.profile.selfVendor.guildOnly end,
set = function(_, value) db.profile.selfVendor.guildOnly = value end,
order = 5.5,
}
for order, mode in ipairs(selfVendorModeSorting) do
local configuredMode = mode
local details = SELF_VENDOR_MODES[mode]