forked from EllesmereGaming/EllesmereUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEUI_QoL.lua
More file actions
1016 lines (914 loc) · 43.4 KB
/
EUI_QoL.lua
File metadata and controls
1016 lines (914 loc) · 43.4 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
-------------------------------------------------------------------------------
-- EUI_QoL.lua
-- Runtime logic for all Quality-of-Life features toggled in the QoL Features
-- tab of Global Settings. No UI code here -- only gameplay behaviour.
-------------------------------------------------------------------------------
local qolFrame = CreateFrame("Frame")
qolFrame:RegisterEvent("PLAYER_LOGIN")
qolFrame:SetScript("OnEvent", function(self)
self:UnregisterEvent("PLAYER_LOGIN")
---------------------------------------------------------------------------
-- Health Potion Macro
---------------------------------------------------------------------------
do
-- Item IDs per category (newest expansion first so best items are picked)
local ITEM_LISTS = {
-- 1 = Healthstone
[1] = { 5512 },
-- 2 = Health Potions (Midnight → War Within → older)
[2] = { 241305, 212943, 211880 },
-- 3 = Combat Potions (Midnight → War Within)
[3] = { 241309, 212265, 212259, 212260 },
}
local MACRO_NAME = "EUI_Health"
local MACRO_ICON = "INV_MISC_QUESTIONMARK"
-- Find the first item from a list that is in the player's bags
local function FindItemInBags(itemIDs)
for _, itemID in ipairs(itemIDs) do
for bag = BACKPACK_CONTAINER, NUM_BAG_SLOTS do
for slot = 1, C_Container.GetContainerNumSlots(bag) do
local info = C_Container.GetContainerItemInfo(bag, slot)
if info and info.itemID == itemID then
return itemID
end
end
end
end
return nil
end
-- Tracks the last written macro body so we skip EditMacro when nothing changed
local cachedMacroBody = nil
local function RefreshHealthMacro()
if not (EllesmereUIDB and EllesmereUIDB.healthMacroEnabled) then return end
if InCombatLockdown() then return end
-- Walk priorities in order and grab the first matching item from bags
local slots = {
EllesmereUIDB.healthMacroPrio1 or 1,
EllesmereUIDB.healthMacroPrio2 or 2,
EllesmereUIDB.healthMacroPrio3 or 3,
}
local tokens = {}
for i = 1, #slots do
local itemList = ITEM_LISTS[slots[i]]
if itemList then
local found = FindItemInBags(itemList)
if found then
tokens[#tokens + 1] = "item:" .. found
end
end
end
local newBody
if #tokens == 0 then
newBody = "#showtooltip\n/run print(\"EUI: No health consumable in bags.\")"
elseif #tokens == 1 then
newBody = "#showtooltip " .. tokens[1] .. "\n/use " .. tokens[1]
else
newBody = "#showtooltip " .. tokens[1] .. "\n/castsequence reset=combat " .. table.concat(tokens, ", ")
end
if newBody == cachedMacroBody then return end
cachedMacroBody = newBody
local idx = GetMacroIndexByName(MACRO_NAME)
if idx == 0 then
CreateMacro(MACRO_NAME, MACRO_ICON, newBody, nil)
else
EditMacro(idx, MACRO_NAME, MACRO_ICON, newBody)
end
end
EllesmereUI._applyHealthMacro = RefreshHealthMacro
-- Rebuild whenever bags change
local macroFrame = CreateFrame("Frame")
macroFrame:RegisterEvent("BAG_UPDATE")
macroFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
macroFrame:SetScript("OnEvent", function(self, event)
if event == "PLAYER_ENTERING_WORLD" then
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
end
if EllesmereUIDB and EllesmereUIDB.healthMacroEnabled then
C_Timer.After(0.5, RefreshHealthMacro)
end
end)
end
---------------------------------------------------------------------------
-- Food & Drink Macro
---------------------------------------------------------------------------
do
-- Only Mage food and actual drinks -- NO buff food (stat food stays for raid)
local CONSUMABLE_LIST = {
-- Mage food (restores both health and mana, no stat buff)
{ id = 113509 }, -- Conjured Mana Bun
{ id = 80618 }, -- Conjured Mana Fritter
{ id = 80610 }, -- Conjured Mana Pudding
{ id = 65499 }, -- Conjured Mana Cake
{ id = 43523 }, -- Conjured Mana Strudel
-- Midnight drinks (no stat buff)
{ id = 242298 }, -- Argentleaf Tea
{ id = 242693 }, -- Kafaccino
-- TWW drinks
{ id = 260260 }, -- Springrunner Sparkling
{ id = 247695 }, -- Sparkling Mana Supplement
{ id = 247694 }, -- Snifted Void Essence
{ id = 227322 }, -- Sanctified Sasparilla
{ id = 202315 }, -- Frozen Solid Tea
{ id = 197771 }, -- Delicious Dragon Spittle
-- Generic vendor water (fallback)
{ id = 8766 }, -- Refreshing Spring Water
{ id = 159 }, -- Refreshing Spring Water (old)
}
local MACRO_NAME = "EUI_FoodDrink"
local MACRO_ICON = "INV_MISC_QUESTIONMARK"
local function FindBest()
for _, e in ipairs(CONSUMABLE_LIST) do
if (C_Item.GetItemCount(e.id, false, false) or 0) > 0 then
return "item:" .. e.id
end
end
return nil
end
local function EnsureMacro()
if InCombatLockdown() then return false end
if GetMacroInfo(MACRO_NAME) ~= nil then return true end
return CreateMacro(MACRO_NAME, MACRO_ICON, "#showtooltip", nil) ~= nil
end
local lastItem = nil
local pendingUpdate = false
local function UpdateMacro(ignoreCombat)
if not (EllesmereUIDB and EllesmereUIDB.foodMacroEnabled) then return end
if not ignoreCombat and UnitAffectingCombat("player") then return end
if InCombatLockdown() then return end
if not EnsureMacro() then return end
local bestItem = FindBest()
if bestItem == lastItem then return end
local body = bestItem
and string.format("#showtooltip\n/castsequence reset=combat %s", bestItem)
or "#showtooltip"
EditMacro(GetMacroIndexByName(MACRO_NAME), MACRO_NAME, MACRO_ICON, body)
lastItem = bestItem
end
EllesmereUI._applyFoodMacro = function() UpdateMacro(true) end
local fdFrame = CreateFrame("Frame")
fdFrame:RegisterEvent("PLAYER_LOGIN")
fdFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
fdFrame:RegisterEvent("BAG_UPDATE_DELAYED")
fdFrame:RegisterEvent("SPELLS_CHANGED")
fdFrame:SetScript("OnEvent", function(self, event)
if not (EllesmereUIDB and EllesmereUIDB.foodMacroEnabled) then
if event ~= "PLAYER_LOGIN" then return end
end
if event == "PLAYER_LOGIN" then
C_Timer.After(1, function() UpdateMacro(true) end)
elseif event == "PLAYER_REGEN_ENABLED" then
UpdateMacro(true)
elseif event == "BAG_UPDATE_DELAYED" then
if not pendingUpdate then
pendingUpdate = true
C_Timer.After(0.05, function()
pendingUpdate = false
UpdateMacro(false)
end)
end
elseif event == "SPELLS_CHANGED" then
-- Mage food appears/disappears when conjured
UpdateMacro(false)
end
end)
end
---------------------------------------------------------------------------
-- Auto Unwrap Collections (Mounts / Pets / Toys)
---------------------------------------------------------------------------
do
local busy = false
-- Dismiss the pending "new item" glow on all mounts that need it,
-- temporarily narrowing the journal filter so we only iterate collected ones.
local function AckMountAlerts()
if not C_MountJournal then return false end
local pending = C_MountJournal.GetNumMountsNeedingFanfare
and C_MountJournal.GetNumMountsNeedingFanfare()
if not pending or pending <= 0 then return false end
-- Snapshot active filters, force "collected only", sweep, then restore
local snapshot = {}
for i = LE_MOUNT_JOURNAL_FILTER_COLLECTED, LE_MOUNT_JOURNAL_FILTER_UNUSABLE do
snapshot[i] = C_MountJournal.GetCollectedFilterSetting(i) and true or false
C_MountJournal.SetCollectedFilterSetting(i, i == LE_MOUNT_JOURNAL_FILTER_COLLECTED)
end
for i = 1, C_MountJournal.GetNumDisplayedMounts() do
local id = C_MountJournal.GetDisplayedMountID(i)
if id and C_MountJournal.NeedsFanfare(id) then
C_MountJournal.ClearFanfare(id)
end
end
for i = LE_MOUNT_JOURNAL_FILTER_COLLECTED, LE_MOUNT_JOURNAL_FILTER_UNUSABLE do
C_MountJournal.SetCollectedFilterSetting(i, snapshot[i])
end
return true
end
local function AckPetAlerts()
if not C_PetJournal or not C_PetJournal.GetNumPetsNeedingFanfare then return false end
if (C_PetJournal.GetNumPetsNeedingFanfare() or 0) == 0 then return false end
local any = false
for _, id in ipairs(C_PetJournal.GetOwnedPetIDs and C_PetJournal.GetOwnedPetIDs() or {}) do
if id and C_PetJournal.PetNeedsFanfare and C_PetJournal.PetNeedsFanfare(id) then
if C_PetJournal.ClearFanfare then C_PetJournal.ClearFanfare(id) end
any = true
end
end
return any
end
local function AckToyAlerts()
if not C_ToyBoxInfo or not C_ToyBoxInfo.ClearFanfare then return false end
local any = false
-- Fast path via ToyBox.fanfareToys lookup table
if ToyBox and ToyBox.fanfareToys then
for id, needs in pairs(ToyBox.fanfareToys) do
if needs and id and C_ToyBoxInfo.NeedsFanfare and C_ToyBoxInfo.NeedsFanfare(id) then
C_ToyBoxInfo.ClearFanfare(id)
any = true
end
end
if any then return true end
end
-- Fallback: full scan
if C_ToyBox and C_ToyBox.GetNumToys and C_ToyBox.GetToyFromIndex then
for i = 1, C_ToyBox.GetNumToys() do
local id = C_ToyBox.GetToyFromIndex(i)
if id and C_ToyBoxInfo.NeedsFanfare and C_ToyBoxInfo.NeedsFanfare(id) then
C_ToyBoxInfo.ClearFanfare(id)
any = true
end
end
end
return any
end
local function DismissCollectionAlerts()
if not (EllesmereUIDB and EllesmereUIDB.autoUnwrapCollections) then return end
if busy then return end
busy = true
C_Timer.After(0.2, function()
busy = false
if not (EllesmereUIDB and EllesmereUIDB.autoUnwrapCollections) then return end
local changed = AckMountAlerts() or AckPetAlerts() or AckToyAlerts()
if changed then
if CollectionsMicroButton and MainMenuMicroButton_HideAlert then
MainMenuMicroButton_HideAlert(CollectionsMicroButton)
end
if CollectionsMicroButton_SetAlertShown then
CollectionsMicroButton_SetAlertShown(false)
end
end
end)
end
EllesmereUI._applyAutoUnwrap = function() end
hooksecurefunc("MainMenuMicroButton_ShowAlert", function(_, text)
if not (EllesmereUIDB and EllesmereUIDB.autoUnwrapCollections) then return end
if text == COLLECTION_UNOPENED_PLURAL or text == COLLECTION_UNOPENED_SINGULAR then
DismissCollectionAlerts()
end
end)
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("NEW_MOUNT_ADDED")
f:RegisterEvent("NEW_PET_ADDED")
f:RegisterEvent("NEW_TOY_ADDED")
f:SetScript("OnEvent", function(self, event)
if event == "PLAYER_LOGIN" then self:UnregisterEvent("PLAYER_LOGIN") end
DismissCollectionAlerts()
end)
end
---------------------------------------------------------------------------
-- Auto Open Containers
---------------------------------------------------------------------------
do
local openableCache = {}
local pendingOpen = false
local function IsOpenable(bag, slot)
local info = C_Container.GetContainerItemInfo(bag, slot)
if not info or not info.itemID then return false end
local cached = openableCache[info.itemID]
if cached ~= nil then return cached end
-- Check tooltip for the "Right Click to Open" / ITEM_OPENABLE text
local tip = C_TooltipInfo and C_TooltipInfo.GetBagItem and C_TooltipInfo.GetBagItem(bag, slot)
if tip and tip.lines then
for _, line in ipairs(tip.lines) do
if line and line.leftText and line.leftText == ITEM_OPENABLE then
openableCache[info.itemID] = true
return true
end
end
end
openableCache[info.itemID] = false
return false
end
local containerFrame = CreateFrame("Frame")
containerFrame:RegisterEvent("BAG_UPDATE_DELAYED")
containerFrame:SetScript("OnEvent", function()
if EllesmereUIDB and EllesmereUIDB.autoOpenContainers == false then return end
if InCombatLockdown() then return end
if not pendingOpen then
pendingOpen = true
C_Timer.After(0.3, function()
-- Collect all openable items first
local itemsToOpen = {}
for bag = BACKPACK_CONTAINER, NUM_BAG_SLOTS do
for slot = 1, C_Container.GetContainerNumSlots(bag) do
if IsOpenable(bag, slot) then
table.insert(itemsToOpen, { bag = bag, slot = slot })
end
end
end
-- Open them one by one with delay between each
local function OpenNext(index)
if index > #itemsToOpen then
pendingOpen = false
return
end
local item = itemsToOpen[index]
if IsOpenable(item.bag, item.slot) then
C_Container.UseContainerItem(item.bag, item.slot)
end
C_Timer.After(0.15, function() OpenNext(index + 1) end)
end
OpenNext(1)
end)
end
end)
end
---------------------------------------------------------------------------
-- Hide Screenshot Status
---------------------------------------------------------------------------
do
local function ApplyScreenshotStatus()
local actionStatus = _G.ActionStatus
if not actionStatus then return end
if not EllesmereUIDB or EllesmereUIDB.hideScreenshotStatus ~= false then
actionStatus:UnregisterEvent("SCREENSHOT_STARTED")
actionStatus:UnregisterEvent("SCREENSHOT_SUCCEEDED")
actionStatus:UnregisterEvent("SCREENSHOT_FAILED")
actionStatus:Hide()
else
actionStatus:RegisterEvent("SCREENSHOT_STARTED")
actionStatus:RegisterEvent("SCREENSHOT_SUCCEEDED")
actionStatus:RegisterEvent("SCREENSHOT_FAILED")
end
end
EllesmereUI._applyScreenshotStatus = ApplyScreenshotStatus
local ssFrame = CreateFrame("Frame")
ssFrame:RegisterEvent("PLAYER_LOGIN")
ssFrame:SetScript("OnEvent", function(self)
self:UnregisterEvent("PLAYER_LOGIN")
ApplyScreenshotStatus()
end)
end
---------------------------------------------------------------------------
-- Train All Button
---------------------------------------------------------------------------
do
local trainBtn = nil
local hooked = false
-- How many primary profession slots are still free?
local function FreeProfessionSlots()
if not GetProfessions then return 2 end
local a, b = GetProfessions()
return 2 - (a and 1 or 0) - (b and 1 or 0)
end
-- Can skill at index i be purchased given current funds/slots?
local function SkillIsAffordable(i, wallet, freeSlots)
if not GetTrainerServiceInfo or not GetTrainerServiceCost then return false, 0, false end
local _, kind = GetTrainerServiceInfo(i)
if kind ~= "available" then return false, 0, false end
local cost, takesProfSlot = GetTrainerServiceCost(i)
cost = cost or 0
if cost > wallet then return false, 0, false end
if takesProfSlot and freeSlots <= 0 then return false, 0, false end
return true, cost, takesProfSlot
end
-- Return total count and total gold cost of everything trainable right now
local function TrainableSummary()
if not GetNumTrainerServices then return 0, 0 end
local n, gold = 0, 0
local wallet = GetMoney and GetMoney() or 0
local slots = FreeProfessionSlots()
for i = 1, GetNumTrainerServices() do
local ok, cost = SkillIsAffordable(i, wallet, slots)
if ok then n = n + 1; gold = gold + cost end
end
return n, gold
end
local function RefreshButton()
if not trainBtn then return end
if not (EllesmereUIDB and EllesmereUIDB.trainAllButton) then
trainBtn:Hide(); return
end
local n = TrainableSummary()
trainBtn:SetEnabled(n > 0)
trainBtn:Show()
end
local function SpawnButton()
if not (EllesmereUIDB and EllesmereUIDB.trainAllButton) then return end
if not ClassTrainerFrame or not ClassTrainerTrainButton then return end
if trainBtn then trainBtn:Show(); RefreshButton(); return end
trainBtn = CreateFrame("Button", "EUI_TrainAllButton", ClassTrainerFrame, "MagicButtonTemplate")
trainBtn:SetText("Train All")
trainBtn:SetHeight(ClassTrainerTrainButton:GetHeight() or 22)
trainBtn:SetWidth(80)
trainBtn:SetPoint("RIGHT", ClassTrainerTrainButton, "LEFT", -2, 0)
trainBtn:SetScript("OnClick", function()
local wallet = GetMoney and GetMoney() or 0
local slots = FreeProfessionSlots()
for i = 1, GetNumTrainerServices() do
local ok, cost, takesProfSlot = SkillIsAffordable(i, wallet, slots)
if ok then
BuyTrainerService(i)
wallet = wallet - cost
if takesProfSlot then slots = slots - 1 end
end
end
end)
trainBtn:SetScript("OnEnter", function(self)
local n, gold = TrainableSummary()
if n <= 0 then return end
local msg = string.format("Learn %d skill%s for %s",
n, n == 1 and "" or "s",
C_CurrencyInfo.GetCoinTextureString(gold))
EllesmereUI.ShowWidgetTooltip(self, msg)
end)
trainBtn:SetScript("OnLeave", function() EllesmereUI.HideWidgetTooltip() end)
if not hooked then
hooksecurefunc("ClassTrainerFrame_Update", RefreshButton)
hooked = true
end
RefreshButton()
end
local function ApplyTrainAllButton()
if EllesmereUIDB and EllesmereUIDB.trainAllButton then
EventUtil.ContinueOnAddOnLoaded("Blizzard_TrainerUI", SpawnButton)
if IsAddOnLoaded and IsAddOnLoaded("Blizzard_TrainerUI") then SpawnButton() end
elseif trainBtn then
trainBtn:Hide()
end
end
EllesmereUI._applyTrainAllButton = ApplyTrainAllButton
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", function(self, event, addonName)
if event == "PLAYER_LOGIN" then
self:UnregisterEvent("PLAYER_LOGIN")
ApplyTrainAllButton()
elseif event == "ADDON_LOADED" and addonName == "Blizzard_TrainerUI" then
self:UnregisterEvent("ADDON_LOADED")
ApplyTrainAllButton()
end
end)
end
---------------------------------------------------------------------------
-- AH Current Expansion Only
---------------------------------------------------------------------------
do
local ahFrame = CreateFrame("Frame")
ahFrame:RegisterEvent("AUCTION_HOUSE_SHOW")
ahFrame:SetScript("OnEvent", function()
if not (EllesmereUIDB and EllesmereUIDB.ahCurrentExpansion) then return end
if not AuctionHouseFrame or not AuctionHouseFrame.SearchBar then return end
C_Timer.After(0, function()
local fb = AuctionHouseFrame.SearchBar.FilterButton
if not fb or not fb.filters then return end
if not (Enum and Enum.AuctionHouseFilter and Enum.AuctionHouseFilter.CurrentExpansionOnly) then return end
fb.filters[Enum.AuctionHouseFilter.CurrentExpansionOnly] = true
AuctionHouseFrame.SearchBar:UpdateClearFiltersButton()
end)
end)
end
---------------------------------------------------------------------------
-- Auto Sell Junk + Auto Repair
---------------------------------------------------------------------------
local merchantFrame = CreateFrame("Frame", "EUI_MerchantHandler", UIParent)
merchantFrame:RegisterEvent("MERCHANT_SHOW")
merchantFrame:SetScript("OnEvent", function()
if not EllesmereUIDB then return end
-- Auto sell junk
if EllesmereUIDB.autoSellJunk ~= false then
local soldCount = 0
for bag = 0, 4 do
for slot = 1, C_Container.GetContainerNumSlots(bag) do
local info = C_Container.GetContainerItemInfo(bag, slot)
if info and info.quality == Enum.ItemQuality.Poor and not info.hasNoValue then
C_Container.UseContainerItem(bag, slot)
soldCount = soldCount + 1
end
end
end
if soldCount > 0 then
print("|cff0CD29DEllesmereUI:|r Sold " .. soldCount .. " junk item" .. (soldCount > 1 and "s" or "") .. ".")
end
end
-- Auto repair
if EllesmereUIDB.autoRepair ~= false then
if CanMerchantRepair() then
local cost, canRepair = GetRepairAllCost()
if canRepair and cost > 0 then
local useGuild = (EllesmereUIDB.autoRepairGuild ~= false)
and IsInGuild()
and CanGuildBankRepair()
and cost <= GetGuildBankWithdrawMoney()
RepairAllItems(useGuild)
if useGuild then
C_Timer.After(0.5, function()
local remainCost, stillNeed = GetRepairAllCost()
if stillNeed and remainCost > 0 then
RepairAllItems(false)
end
end)
end
local gold = floor(cost / 10000)
local silver = floor((cost % 10000) / 100)
local src = useGuild and " (guild bank)" or ""
print("|cff0CD29DEllesmereUI:|r Repaired all items for " .. gold .. "g " .. silver .. "s." .. src)
end
end
end
end)
---------------------------------------------------------------------------
-- Quick Loot
---------------------------------------------------------------------------
do
local lootFrame = CreateFrame("Frame")
lootFrame:RegisterEvent("LOOT_READY")
lootFrame:SetScript("OnEvent", function()
if not (EllesmereUIDB and EllesmereUIDB.quickLoot) then return end
if IsShiftKeyDown() then return end
for i = 1, GetNumLootItems() do
local index = i
C_Timer.After(0.05 * index, function()
LootSlot(index)
end)
end
end)
end
---------------------------------------------------------------------------
-- Auto-Fill Delete Confirmation
---------------------------------------------------------------------------
do
for i = 1, 4 do
local popup = _G["StaticPopup" .. i]
if popup then
hooksecurefunc(popup, "Show", function(self)
if not self then return end
if self.which ~= "DELETE_GOOD_ITEM" and self.which ~= "DELETE_GOOD_QUEST_ITEM" then return end
if not (EllesmereUIDB and EllesmereUIDB.autoFillDelete) then return end
local editBox = self.editBox or (self.GetEditBox and self:GetEditBox())
if not editBox then return end
editBox:SetText(DELETE_ITEM_CONFIRM_STRING)
editBox:SetFocus()
end)
end
end
end
---------------------------------------------------------------------------
-- Skip Cinematics
---------------------------------------------------------------------------
do
local cinHooked = false
local function SetupCinematicHooks()
if cinHooked then return end
if not CinematicFrame or not CinematicFrame.HookScript then return end
cinHooked = true
CinematicFrame:HookScript("OnKeyDown", function(_, key)
if not (EllesmereUIDB and EllesmereUIDB.skipCinematics) then return end
if key == "ESCAPE" then
if CinematicFrame:IsShown() and CinematicFrame.closeDialog then
CinematicFrame.closeDialog:Hide()
end
end
end)
CinematicFrame:HookScript("OnKeyUp", function(_, key)
if not (EllesmereUIDB and EllesmereUIDB.skipCinematics) then return end
if key == "SPACE" or key == "ESCAPE" or key == "ENTER" then
if CinematicFrame:IsShown() and CinematicFrame.closeDialog then
local confirmBtn = _G["CinematicFrameCloseDialogConfirmButton"]
if confirmBtn then confirmBtn:Click() end
end
end
end)
if MovieFrame and MovieFrame.HookScript then
MovieFrame:HookScript("OnKeyUp", function(_, key)
if not (EllesmereUIDB and EllesmereUIDB.skipCinematics) then return end
if key == "SPACE" or key == "ESCAPE" or key == "ENTER" then
if MovieFrame:IsShown() and MovieFrame.CloseDialog and MovieFrame.CloseDialog.ConfirmButton then
MovieFrame.CloseDialog.ConfirmButton:Click()
end
end
end)
end
end
local cinEventFrame = CreateFrame("Frame")
cinEventFrame:RegisterEvent("CINEMATIC_START")
cinEventFrame:RegisterEvent("PLAY_MOVIE")
cinEventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
cinEventFrame:SetScript("OnEvent", function(self, event)
if event == "PLAYER_ENTERING_WORLD" then
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
SetupCinematicHooks()
return
end
if not (EllesmereUIDB and EllesmereUIDB.skipCinematicsAuto) then return end
if event == "CINEMATIC_START" then
if CinematicFrame and CinematicFrame.isRealCinematic then
StopCinematic()
elseif CanCancelScene and CanCancelScene() then
CancelScene()
end
elseif event == "PLAY_MOVIE" then
if MovieFrame then MovieFrame:Hide() end
end
end)
end
---------------------------------------------------------------------------
-- Sort by Mythic+ Rating (DISABLED -- taints Blizzard applicants viewer)
--
-- The implementation below hooksecurefunc'd LFGListUtil_SortApplicants
-- and called table.sort(applicants, ...) which mutated the Blizzard-
-- owned applicants table in place from our insecure addon context.
-- Every swap during the sort wrote applicant IDs back into the table
-- through insecure code, tainting every entry. Later, Blizzard's
-- LFGListApplicationViewer_UpdateInfo iterated that tainted table and
-- hit errors comparing applicantInfo.comment (secret string tainted by
-- EllesmereUI) and applicant dungeon scores.
--
-- Left commented out so we can revisit with a taint-safe approach
-- later (likely: maintain a local shadow ordering and use it purely
-- for display via a PostUpdate callback, without touching the live
-- Blizzard applicants table).
---------------------------------------------------------------------------
--[[
do
local function GetApplicantScore(applicantID)
if not C_LFGList or not C_LFGList.GetApplicantMemberInfo then return nil end
local _, _, _, _, _, _, _, _, _, _, _, dungeonScore = C_LFGList.GetApplicantMemberInfo(applicantID, 1)
if dungeonScore == nil then return nil end
if issecretvalue and issecretvalue(dungeonScore) then return nil end
if type(dungeonScore) ~= "number" then return nil end
return dungeonScore
end
hooksecurefunc("LFGListUtil_SortApplicants", function(applicants)
if not (EllesmereUIDB and EllesmereUIDB.sortByMythicScore) then return end
if not applicants then return end
local scores = {}
local originalOrder = {}
local hasSortable = false
for i, appID in ipairs(applicants) do
originalOrder[appID] = i
local score = GetApplicantScore(appID)
if score ~= nil then
scores[appID] = score
hasSortable = true
end
end
if not hasSortable then return end
table.sort(applicants, function(a, b)
local sa = scores[a]
local sb = scores[b]
if sa and sb and sa ~= sb then return sa > sb end
if sa and not sb then return true end
if not sa and sb then return false end
return (originalOrder[a] or 0) < (originalOrder[b] or 0)
end)
end)
end
--]]
---------------------------------------------------------------------------
-- Auto Insert Keystone
---------------------------------------------------------------------------
do
local function InsertKeystone()
if EllesmereUIDB and EllesmereUIDB.autoInsertKeystone == false then return end
if C_ChallengeMode.GetSlottedKeystoneInfo() then return end
for bag = BACKPACK_CONTAINER, NUM_BAG_SLOTS do
local slots = C_Container.GetContainerNumSlots(bag)
for slot = 1, slots do
local link = C_Container.GetContainerItemLink(bag, slot)
if link and link:find("|Hkeystone:") then
C_Container.PickupContainerItem(bag, slot)
if CursorHasItem() then
C_ChallengeMode.SlotKeystone()
end
return
end
end
end
end
local ksFrame = CreateFrame("Frame")
ksFrame:RegisterEvent("CHALLENGE_MODE_KEYSTONE_RECEPTABLE_OPEN")
ksFrame:RegisterEvent("ADDON_LOADED")
ksFrame:SetScript("OnEvent", function(self, event, arg1)
if event == "CHALLENGE_MODE_KEYSTONE_RECEPTABLE_OPEN" then
InsertKeystone()
elseif event == "ADDON_LOADED" and arg1 == "Blizzard_ChallengesUI" then
self:UnregisterEvent("ADDON_LOADED")
if ChallengesKeystoneFrame then
ChallengesKeystoneFrame:HookScript("OnShow", InsertKeystone)
end
end
end)
if IsAddOnLoaded and IsAddOnLoaded("Blizzard_ChallengesUI") then
if ChallengesKeystoneFrame then
ChallengesKeystoneFrame:HookScript("OnShow", InsertKeystone)
end
end
end
---------------------------------------------------------------------------
-- Quick Signup (double-click to sign up)
---------------------------------------------------------------------------
do
local lastClickTime = 0
local lastClickEntry = nil
local DOUBLE_CLICK_THRESHOLD = 0.4
hooksecurefunc("LFGListSearchEntry_OnClick", function(entry, button)
if not (EllesmereUIDB and EllesmereUIDB.quickSignup) then return end
if button == "RightButton" then return end
local panel = LFGListFrame and LFGListFrame.SearchPanel
if not panel then return end
if not LFGListSearchPanelUtil_CanSelectResult(entry.resultID) then return end
if not panel.SignUpButton or not panel.SignUpButton:IsEnabled() then return end
local now = GetTime()
if lastClickEntry == entry.resultID and (now - lastClickTime) < DOUBLE_CLICK_THRESHOLD then
if panel.selectedResult ~= entry.resultID then
LFGListSearchPanel_SelectResult(panel, entry.resultID)
end
LFGListSearchPanel_SignUp(panel)
lastClickEntry = nil
lastClickTime = 0
else
lastClickEntry = entry.resultID
lastClickTime = now
end
end)
-- Auto-accept role check for Quick Signup
LFGListApplicationDialog:HookScript("OnShow", function(self)
if not (EllesmereUIDB and EllesmereUIDB.quickSignup) then return end
local shiftBypass = EllesmereUIDB.quickSignupAutoRoleShift and IsShiftKeyDown()
if self.SignUpButton:IsEnabled() and not shiftBypass then
self.SignUpButton:Click()
end
end)
-- Classic Dungeon Finder role check for Quick Signup
local roleFrame = CreateFrame("Frame")
roleFrame:RegisterEvent("LFG_ROLE_CHECK_SHOW")
roleFrame:SetScript("OnEvent", function()
if not (EllesmereUIDB and EllesmereUIDB.quickSignup) then return end
if not UnitInParty("player") then return end
-- Skip if Shift is held and shift-bypass is enabled
if EllesmereUIDB.quickSignupAutoRoleShift and IsShiftKeyDown() then return end
local leader, tank, healer, dps = GetLFGRoles()
if LFDRoleCheckPopupRoleButtonTank.checkButton:IsEnabled() then
LFDRoleCheckPopupRoleButtonTank.checkButton:SetChecked(tank)
end
if LFDRoleCheckPopupRoleButtonHealer.checkButton:IsEnabled() then
LFDRoleCheckPopupRoleButtonHealer.checkButton:SetChecked(healer)
end
if LFDRoleCheckPopupRoleButtonDPS.checkButton:IsEnabled() then
LFDRoleCheckPopupRoleButtonDPS.checkButton:SetChecked(dps)
end
LFDRoleCheckPopupAcceptButton:Enable()
LFDRoleCheckPopupAcceptButton:Click()
end)
end
---------------------------------------------------------------------------
-- Persistent LFG Signup Note
---------------------------------------------------------------------------
do
local vanilla = LFGListApplicationDialog_Show
local patched = false
local function PatchedShow(self, resultID)
if resultID then
local info = C_LFGList.GetSearchResultInfo(resultID)
if info then
self.resultID = resultID
self.activityID = info.activityID or (info.activityIDs and info.activityIDs[1])
end
end
LFGListApplicationDialog_UpdateRoles(self)
StaticPopupSpecial_Show(self)
end
local function SyncPatch()
if EllesmereUIDB and EllesmereUIDB.persistSignupNote then
if not patched then
LFGListApplicationDialog_Show = PatchedShow
patched = true
end
else
if patched then
LFGListApplicationDialog_Show = vanilla
patched = false
end
end
end
EllesmereUI._applyPersistSignupNote = SyncPatch
SyncPatch()
end
---------------------------------------------------------------------------
-- Hide Blizzard Party / Raid Manager frame
---------------------------------------------------------------------------
do
local hookedMgr = false
local function ApplyHideBlizzardPartyFrame()
local shouldHide = EllesmereUIDB and EllesmereUIDB.hideBlizzardPartyFrame
local mgr = CompactRaidFrameManager or _G["CompactRaidFrameManager"]
if not mgr then return end
if shouldHide then
mgr:Hide()
if not hookedMgr then
hookedMgr = true
mgr:HookScript("OnShow", function(self)
if EllesmereUIDB and EllesmereUIDB.hideBlizzardPartyFrame then
self:Hide()
end
end)
end
end
end
EllesmereUI._applyHideBlizzardPartyFrame = ApplyHideBlizzardPartyFrame
local initFrame = CreateFrame("Frame")
initFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
initFrame:RegisterEvent("GROUP_ROSTER_UPDATE")
initFrame:SetScript("OnEvent", function(self, event)
if event == "PLAYER_ENTERING_WORLD" then
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
end
ApplyHideBlizzardPartyFrame()
end)
end
---------------------------------------------------------------------------
-- Instance Reset Announce
-- After a successful /reset, posts a message to instance chat so the
-- whole group knows the instance is ready to re-enter.
---------------------------------------------------------------------------
do
-- Capture the player name once at login; used in the chat message.
local playerName = UnitName("player") or "Unknown"
-- We detect a successful reset by watching CHAT_MSG_SYSTEM for the
-- Blizzard confirmation string. The exact string varies by locale so
-- we match the most common substrings used across all WoW clients.
local RESET_PATTERNS = {
"has been reset", -- enUS / enGB
"wurde zur", -- deDE (zurückgesetzt)
"a été réinitialisé", -- frFR
"ha sido reiniciada", -- esES / esMX
"è stato resettato", -- itIT
"foi reiniciada", -- ptBR / ptPT
"сброшен", -- ruRU
"已重置", -- zhCN / zhTW
"초기화되었습니다", -- koKR
}
-- Patterns that indicate a reset FAILED because players are still inside.
local FAIL_PATTERNS = {
"players still", -- enUS / enGB: "There are players still inside..."
"noch spieler", -- deDE
"joueurs sont encore", -- frFR
"jugadores todavía", -- esES / esMX
"giocatori sono ancora", -- itIT
"jogadores ainda", -- ptBR / ptPT
"игроки ещё", -- ruRU
"还有玩家", -- zhCN
"아직 플레이어", -- koKR
}
local function MatchesAny(msg, patterns)
if not msg then return false end
local ok, lower = pcall(string.lower, msg)
if not ok then return false end
for _, pat in ipairs(patterns) do
local ok2, result = pcall(string.find, lower, string.lower(pat), 1, true)
if ok2 and result then
return true
end
end
return false
end
local resetAnnounceFrame = CreateFrame("Frame")
resetAnnounceFrame:RegisterEvent("CHAT_MSG_SYSTEM")
resetAnnounceFrame:SetScript("OnEvent", function(self, event, msg)
if not (EllesmereUIDB and EllesmereUIDB.instanceResetAnnounce) then return end
-- Only announce if we are inside an instance group.
-- IsInGroup(LE_PARTY_CATEGORY_INSTANCE) covers both party and raid
-- inside an instance; fall back to IsInGroup() for older API.
local inInstanceGroup = (IsInGroup and LE_PARTY_CATEGORY_INSTANCE and
IsInGroup(LE_PARTY_CATEGORY_INSTANCE))
or (IsInGroup and IsInGroup())
if not inInstanceGroup then return end
-- Small delay so Blizzard's own system message renders first.
if MatchesAny(msg, RESET_PATTERNS) then
C_Timer.After(0.3, function()
local channel = IsInRaid() and "RAID" or "PARTY"