forked from Randactyl/AdvancedFilters
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAdvancedFilters.lua
More file actions
2442 lines (2242 loc) · 138 KB
/
AdvancedFilters.lua
File metadata and controls
2442 lines (2242 loc) · 138 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
AdvancedFilters = AdvancedFilters or {}
local AF = AdvancedFilters
local tos = tostring
local firstOpened
local firstOpenedIsBank = false
local changeFilterCallsAfterFirstOpenWasBank = 0
local vanillaUIChangesToSearchBarsWereDone = false
AF.vanillaUIChangesToSearchBarsWereDone = vanillaUIChangesToSearchBarsWereDone
--local apiVersion = GetAPIVersion()
---==========================================================================================================================================================================
--______________________________________________________________________________________________________________________
-- TODO - BEGIN
--______________________________________________________________________________________________________________________
--#14 Drag & drop item at vendor buyback inventory list throws error:
--[[
EsoUI/Ingame/Inventory/InventorySlot.lua:2597: Attempt to access a private function 'PickupStoreBuybackItem' from insecure code. The callstack became untrusted 3 stack frame(s) from the top.
stack traceback:
EsoUI/Ingame/Inventory/InventorySlot.lua:2597: in function '(anonymous)'
|caaaaaa<Locals> inventorySlot = ud </Locals>|r
EsoUI/Ingame/Utility/ZO_SlotUtil.lua:14: in function 'RunHandlers'
|caaaaaa<Locals> handlerTable = [table:1]{}, slot = ud, handlers = [table:2]{}, i = 1 </Locals>|r
(tail call): ?
ZO_StackSplitSource_DragStart:4: in function '(main chunk)'
|caaaaaa<Locals> self = ud, button = 1 </Locals>|r
]]
--#19: 2019-12-23, Feature, Baertram:
-- Use context menu at dropdownboxes to show the last used filters from dropdown boxes at the given subfilterGroup
-- e.g. select Weapons>1hd as subfilterGroup, select "Level filter 1-49" from dropdown filterbox.
-- Right click the dropdown box and ALWAYS show entries "Invert current filter 1-49", "Select all".
-- But also show below the last selected filter 1-49 now (up to last 5 selected ones from whatever subfilterGroup).
-- Should check though if the filter of the dropdown box can be applied to the current panel and subfilterGroup! -> Possible?
--> Not doable that easily as filters which cannot be applied at a panel should not be shown in teh "last selected" list then, and so on
--[[
--#76 Add support for nested submenus in nested submenus (currently only 1 level depth is supported)
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
--TODO Last updated: 2025-09-18
--Max todos: #81
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
--CURRENTLY WORKING ON - Last updated: 2025-09-18
--==========================================================================================================================================================================
--______________________________________________________________________________________________________________________
-- UPDATE INFORMATION: since AF 1.6.4.9 - Current 1.6.5.0
--______________________________________________________________________________________________________________________
-- ADDED
#81 Add Cyrodiil vengeance inventory support
--
-- ADDED ON REQUEST
-- CHANGED
-- FIXED
--
---==========================================================================================================================================================================
---==========================================================================================================================================================================
---==========================================================================================================================================================================
--______________________________________________________________________________________________________________________
-- NOT REPLICABLE
--______________________________________________________________________________________________________________________
--______________________________________________________________________________________________________________________
-- TODO - END
--______________________________________________________________________________________________________________________
]]
---==========================================================================================================================================================================
--Constants in local variables
local controlsForChecks = AF.controlsForChecks
local playerInvVar = controlsForChecks.playerInv
local smithingBaseVar = controlsForChecks.smithingBaseVar
local smithingVar = controlsForChecks.smithing
local enchantingVar = controlsForChecks.enchanting
local enchantingBaseVar = controlsForChecks.enchantingBaseVar
local alchemyVar = controlsForChecks.alchemy
local provisionerVar = controlsForChecks.provisioner
local retraitVar = controlsForChecks.retrait
local quickslotVar = controlsForChecks.quickslot
local quickslotFragment = controlsForChecks.quickslotFragment
local companionInvVar = controlsForChecks.companionInv
local store = controlsForChecks.store
--local furnitureVault = controlsForChecks.furnitureVault
--local universalDecon = controlsForChecks.universalDecon
local universalDeconPanel = controlsForChecks.universalDeconPanel
local universalDeconPanelInv = controlsForChecks.universalDeconPanelInv
--local universalDeconPanelInvControl = controlsForChecks.universalDeconPanelInvControl
local universalDeconScene = controlsForChecks.universalDeconScene
local subfilterBarInventorytypesOfUniversalDecon = AF.subfilterBarInventorytypesOfUniversalDecon
local universalDeconSelectedTabToAFInventoryType = AF.universalDeconSelectedTabToAFInventoryType
--local universalDeconKeyToAFFilterType = AF.universalDeconKeyToAFFilterType
local isUniversalDeconPanelShown
--local functions for speedup
local util = AF.util
local RefreshSubfilterBar = util.RefreshSubfilterBar
local GetCraftingType = util.GetCraftingType
local ThrottledUpdate = util.ThrottledUpdate
local CheckIfNoSubfilterBarShouldBeShown = util.CheckIfNoSubfilterBarShouldBeShown
local UpdateCurrentFilter = util.UpdateCurrentFilter
local GetInventoryFromCraftingPanel = util.GetInventoryFromCraftingPanel
local IsCraftingStationInventoryType = util.IsCraftingStationInventoryType
local IsCraftingPanelShown = util.IsCraftingPanelShown
--local mapCurrentFilterItemFilterCategoryToItemFilterType = util.mapCurrentFilterItemFilterCategoryToItemFilterType
local hideInventoryControls = util.HideInventoryControls
local getListControlForSubfilterBarReanchor = util.GetListControlForSubfilterBarReanchor
local isCraftingPanelShown = util.IsCraftingPanelShown
local getInvTypeCurrentQuickslotFilter = util.GetInvTypeCurrentQuickslotFilter
local getCurrentFilter = util.GetCurrentFilter
local checkForCustomInventoryFilterBarButton= util.CheckForCustomInventoryFilterBarButton
local mapCraftingStationFilterType2ItemFilterType = util.MapCraftingStationFilterType2ItemFilterType
local mapUniversalDeconstructionFilterType2ItemFilterType = util.MapUniversalDeconstructionFilterType2ItemFilterType
local doesInventoryTypeNeedsMappingToCustomAFCurrentFilter = AF.DoesInventoryTypeNeedsMappingToCustomAFCurrentFilter
local function delayedCall(delay, functionToCall, params)
if functionToCall then
delay = delay or 0
zo_callLater(function() functionToCall(params) end, delay)
end
end
function AF.showChatDebug(functionName, chatOutputVars)
local functionNameStr = tos(functionName) or "n/a"
functionNameStr = " " .. functionNameStr
chatOutputVars = chatOutputVars or ""
local strings = AF.strings
local afPrefixError = ""
--Center screen annonucenment
local csaText
if strings and strings["errorCheckChatPlease"] then
csaText = strings["errorCheckChatPlease"]
afPrefixError = strings.AFPREFIXERROR
else
csaText = "|cFF0000[AdvancedFilters ERROR]|r Please read the error message in the chat!"
end
if csaText ~= "" then
local params = CENTER_SCREEN_ANNOUNCE:CreateMessageParams(CSA_CATEGORY_LARGE_TEXT, SOUNDS.GROUP_KICK)
params:SetCSAType(CENTER_SCREEN_ANNOUNCE_TYPE_DISPLAY_ANNOUNCEMENT)
params:SetText(csaText)
CENTER_SCREEN_ANNOUNCE:AddMessageWithParams(params)
end
--Chat output
if not strings then return end
d(">>>======== AF ERROR - BEGIN ========>>>")
d(afPrefixError .. "|c00ccff" .. tos(functionNameStr) .. "|r")
d(strings.errorWhatToDo1)
d(strings.errorWhatToDo2)
d("-> [" .. tos(functionNameStr) .. "]\n")
if chatOutputVars ~= "" then
d(chatOutputVars)
end
d("<<<======== AF ERROR - END ========<<<")
end
local showChatDebug = AF.showChatDebug
--Set the last used currentFilter of the bank inventory to internal AF data tables
local function updateLastBankCurrentFilter(bankInvType)
local bankInvTypes = AF.bankInvTypes
--Check if current inventory is a bank withdraw panel
local isBankInvType = bankInvTypes[bankInvType] or false
if not isBankInvType then return end
if not playerInvVar.inventories or not playerInvVar.inventories[bankInvType] then return end
local currentBankFilter = playerInvVar.inventories[bankInvType].currentFilter
--d(">Current bank currentFilter: " ..tos(currentBankFilter))
AF.lastCurrentFilter[bankInvType] = currentBankFilter
end
--Is the last opened bank currentFilter saved then use this as new currentFilter if the current currentFilter is 0 ("All")
local function checkIfBankLastCurrentFilterIsGiven(self, filterTab)
if AF.settings.debugSpam then d(">checkIfBankLastCurrentFilterIsGiven - START") end
local currentInvType = AF.currentInventoryType
local tabInvType = filterTab.inventoryType
local tabInventory = self.inventories[tabInvType]
local currentFilter = tabInventory.currentFilter
--local currentFilter, _, _ = self:GetTabFilterInfo(tabInvType, filterTab) --filterData.filterType, filterData.activeTabText, filterData.hiddenColumns
--d(">invType: " ..tos(currentInvType) ..", currentFilter: " ..tos(currentFilter))
if not currentFilter then currentFilter = 0 end
if currentFilter == 0 then
local bankInvTypes = AF.bankInvTypes
--Check if current inventory is a bank withdraw panel
local isBankInvType = bankInvTypes[currentInvType] or false
--d(">isBankInvType: " ..tos(isBankInvType))
if isBankInvType == true then
if AF.settings.debugSpam then d(">isBank: true") end
--Check if for this bank withdraw panel a last currentFilter was known
if AF.lastCurrentFilter and AF.lastCurrentFilter[currentInvType] then
currentFilter = AF.lastCurrentFilter[currentInvType]
--Reset the last used currentFilter at the bank again so it is not re-used at next inventory:ChangeFilter() call
--d(">lastBankCurrentFilter: " ..tos(currentFilter))
AF.lastCurrentFilter[currentInvType] = nil
--d(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
--d(">>>>> Last bank filter deleted!")
--d(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
end
end
end
if AF.settings.debugSpam then d(">checkIfBankLastCurrentFilterIsGiven - END - currentFilter: " ..tos(currentFilter)) end
return currentFilter
end
--Reanchor & hide some controls at the vanilla UI, like the searchBar and box.
--Based on the baseControl the controls to change are children
local function reanchorAndHideVanillaUIControls(baseControl)
--d("[AF]reanchorAndHideVanillaUIControls")
if not baseControl then return end
local ZOsControlNames = AF.ZOsControlNames
local tabsName = ZOsControlNames.tabs
local searchDividerName = ZOsControlNames.searchDivider
--SearchDivider
local searchDivider = GetControl(baseControl, searchDividerName)
if searchDivider then
searchDivider:SetHidden(true)
end
--Tabs
local tabs = GetControl(baseControl, tabsName)
if tabs then
--d(">Found tabs: " ..tos(tabs:GetName()))
local tabsActiveName = ZOsControlNames.active
local tabsActive = GetControl(tabs, tabsActiveName)
if tabsActive then
--Hide the "All: All" text at the subfilterbar
tabsActive:SetHidden(true)
end
end
--Search filters
local searchFiltersName = ZOsControlNames.searchFilters
local searchFilters = GetControl(baseControl, searchFiltersName)
if searchFilters then
--d(">Found searchFilters: " .. tos(searchFilters:GetName()))
--Text search box
local textSearchName = ZOsControlNames.textSearch
local searchFiltersTextSearch = GetControl(searchFilters, textSearchName)
if searchFiltersTextSearch then
--d(">>1")
local searchFilterBoxOffsetY = -10
if PerfectPixel ~= nil or PP ~= nil then
searchFilterBoxOffsetY = 70
end
searchFiltersTextSearch:ClearAnchors()
searchFiltersTextSearch:SetParent(baseControl)
searchFiltersTextSearch:SetAnchor(BOTTOMLEFT, baseControl, TOPLEFT, 0, (-1 * searchFiltersTextSearch:GetHeight()) + searchFilterBoxOffsetY)
if not VotanSearchBox_SavedVariables then
searchFiltersTextSearch:SetDimensions(150, 25)
searchFiltersTextSearch:SetAlpha(0.45)
end
end
searchFilters:SetHidden(true)
--Search filters sub tab buttons
local subTabsName = ZOsControlNames.subTabs
local searchFiltersSubTabs = GetControl(searchFilters, subTabsName)
if searchFiltersSubTabs then
searchFiltersSubTabs:SetHidden(true)
end
end
end
--======================================================================================================================
--=== HOOKS - BEGIN ====================================================================================================
--======================================================================================================================
--Load the hooks of the different inventories etc.
local function InitializeHooks()
AF.currentInventoryType = INVENTORY_BACKPACK
AF.currentInventoryCurrentFilter = 0
AF.blockOnInventoryFilterChangedPreHookForCraftBag = false
--Workaround for the "last opened filter" at the inventories so that closing the inv will not clear the last selected filter
--Thanks to code65536! for the idea
--[[ 2021-12-23 Seems ZOs fixed this already internally
ZO_BackpackLayoutFragment.Hide = function(self)
--PLAYER_INVENTORY:ApplyBackpackLayout(DEFAULT_BACKPACK_LAYOUT_DATA) -> This will reset the last selected filter
self:OnHidden()
end
]]
--TABLE TRACKER
--[[
this is a hacky way of knowing when items go in and out of an inventory.
t = the tracked table (ZO_InventoryManager.isListDirty/playerInvVar.isListDirty)
k = inventoryType
v = isDirty
pk = private key (no two empty tables are the same) where we store t
mt = our metatable where we can do the tracking
]]
--create private key
local pk = {}
--create metatable
local mt = {
__index = function(t, k)
--d("*access to element " .. tos(k))
--access the tracked table
return t[pk][k]
end,
__newindex = function(t, k, v)
-->This function is called by e.g. LibFilters 3 function SafeUpdateList, which calls
-->playerInvVar:UpdateList(INVENTORY_*) (e.g. INVENTORY_BANK)
--d("*update of element " .. tos(k) .. " to " .. tos(v))
--update the tracked table
t[pk][k] = v
--refresh subfilters for inventory type
local subfilterGroup = AF.subfilterGroups[k]
if not subfilterGroup then return end
local craftingType = GetCraftingType()
local invType = AF.currentInventoryType
local currentSubfilterBar = subfilterGroup.currentSubfilterBar
if not currentSubfilterBar then return end
local RefreshSubfilterBarUpdaterName = "MetaTable___RefreshSubfilterBar_" .. invType .. "_" .. craftingType .. currentSubfilterBar.name
if AF.settings.debugSpam then d("[AF]Metatable proxy: Calling ThrottledUpdate: " ..tos(RefreshSubfilterBarUpdaterName)) end
ThrottledUpdate(RefreshSubfilterBarUpdaterName,
10, RefreshSubfilterBar, currentSubfilterBar)
end,
}
--tracking function. Returns a proxy table with our metatable attached.
--t is e.g. playerInvVar.isListDirty
local function track(t)
local proxy = {}
proxy[pk] = t
setmetatable(proxy, mt)
return proxy
end
--untracking function. Returns the tracked table and destroys the proxy.
local function untrack(proxy)
local t = proxy[pk]
proxy = nil
return t
end
--As some inventories/panels use the same parents to anchor the subfilter bars to
--the change of the panel won't change the parent and thus doesn't hide the subfilter
--bars properly.
--Example: ENCHANTING creation & extraction, deconstruction/improvement for woodworking/blacksmithing/clothing & jewelry deconstruction/improvement
--and inventory + inventory quest
--This function checks the inventory type and hides the old subfilterbar if needed.
local function hideSubfilterBarSameParent(inventoryType, isUniversalDecon)
--d("hideSubfilterBarSameParent - isUniversalDecon: " ..tos(isUniversalDecon))
if AF.settings.debugSpam then d("[AF]hideSubfilterBarSameParent - inventoryType: " .. inventoryType) end
if not inventoryType then return end
if isUniversalDecon == true then
--Detect the last shown subFilterBar at the universal decon panel
local lastUniversalDeconSubfilterBar = AF.lastUniversalDeconSubfilterBar
if lastUniversalDeconSubfilterBar ~= nil then
--d(">>lastUniversalDeconSubfilterBar hiding: " ..tos(lastUniversalDeconSubfilterBar.control:GetName()))
lastUniversalDeconSubfilterBar.control:SetHidden(true)
end
return
end
local mapInvTypeToInvTypeBefore = AF.mapInvTypeToInvTypeBefore
if not mapInvTypeToInvTypeBefore then return end
if mapInvTypeToInvTypeBefore[inventoryType] == nil then return false end
local invTypeBefore = mapInvTypeToInvTypeBefore[inventoryType]
if not invTypeBefore then return end
local subfilterGroupBefore = AF.subfilterGroups[invTypeBefore]
if subfilterGroupBefore ~= nil and subfilterGroupBefore.currentSubfilterBar then
if AF.settings.debugSpam then d(">[AF]hideSubfilterBarSameParent - currentSubfilterBar hidden") end
subfilterGroupBefore.currentSubfilterBar:SetHidden(true)
end
end
--Detect if the current panel (crafting e.g.) is not supporting any subFilter groupes and bars (e.g. SMITHING creation/recipes, enchanting recipes, ...)
local function detectNotSupportedSubfilterPanel(craftingType)
--Supported panel? SubfilterBar filters are provided?
--Check if any not supported panel is given and do not show a message in chat then
local notSupportedPanel = false
local panelModeVar
local notSupportedPanels = AF.notSupportedPanels
local notSupportedPanelForCrafting = notSupportedPanels[craftingType]
if notSupportedPanelForCrafting ~= nil then
if craftingType ~= CRAFTING_TYPE_INVALID then
--Check which crafting it is and get the current crafting's mode variable/state
if craftingType == CRAFTING_TYPE_ENCHANTING then
panelModeVar = enchantingVar.enchantingMode
elseif craftingType == CRAFTING_TYPE_BLACKSMITHING or craftingType == CRAFTING_TYPE_CLOTHIER or craftingType == CRAFTING_TYPE_WOODWORKING or craftingType == CRAFTING_TYPE_JEWELRYCRAFTING then
panelModeVar = smithingVar.mode
elseif craftingType == CRAFTING_TYPE_ALCHEMY then
panelModeVar = alchemyVar.mode
elseif craftingType == CRAFTING_TYPE_PROVISIONING then
panelModeVar = provisionerVar.filterType
end
if panelModeVar ~= nil then
if notSupportedPanelForCrafting[panelModeVar] == true then
notSupportedPanel = true
end
end
--else
--Universal Decon or Retrait: All panels are supported until now
end
end
return notSupportedPanel, panelModeVar
end
AF.util.detectNotSupportedSubfilterPanel = detectNotSupportedSubfilterPanel
--Show the subfilter bar of AdvancedFilters below the parent filter (e.g. button for armor, weapons, material, ...)
--The subfilter bars are defined via the file constants.lua in table "subfilterGroups".
--The contents of the subfilter bars are defined in file constants.lua in table "subfilterButtonNames"
--The filter contents and their callback functions (see top of file files/filterCallbacks.lua) for each content of the subfilter bar are defined in file files/filterCallbacks.lua
--in the table "subfilterCallbacks".
--Their parents (e.g. the player inventory or the bank or the crafting smithing station) are defined in file constants.lua in table "filterBarParents"
local function ShowSubfilterBar(currentFilter, craftingType, customInventoryFilterButtonsItemType, currentInvType, isUniversalDecon)
local debugSpam = AF.settings.debugSpam
if debugSpam then
d(">>----- SHOW SUBFILTER BAR -----\n----------------------------------------------->>")
d(">currentFilter: " ..tos(currentFilter) .. ", craftingType: " ..tos(craftingType) .. ", customInventoryFilterButtonsItemType: " .. tos(customInventoryFilterButtonsItemType) ..", currentInvType: " ..tos(currentInvType))
end
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--Update the y offsetts in pixels for the subfilter bar, so it is shown below the parent's filter buttons
local function UpdateListAnchors(self, shiftY, p_subFilterBar, p_isCraftingInventoryType)
if self == nil then return end
debugSpam = AF.settings.debugSpam
local invTypeUpdateListAnchor = AF.currentInventoryType
if debugSpam then
d("[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[")
d("[AF]UpdateListAnchors invTypeUpdateListAnchor: " ..tos(invTypeUpdateListAnchor) .. ", shiftY: " .. tos(shiftY))
end
local isQuickslot = (self == quickslotVar or invTypeUpdateListAnchor == LF_QUICKSLOT) or false
local isGuildStoreSell = (self == playerInvVar and TRADING_HOUSE.currentMode == ZO_TRADING_HOUSE_MODE_SELL) or false
--Check if the current layoutData (offsets of controls in the inventory) is given
--local layoutData = (p_isCraftingInventoryType == true and util.GetCraftingInventoryLayoutData(invTypeUpdateListAnchor)) or self.appliedLayout
local layoutData = self.appliedLayout
if layoutData == nil or isGuildStoreSell == true then
--Check if the layoutData or any offsets for the list are stored in AF internal constants
if debugSpam then
d(">layoutData was taken from default AF BACKPACK LAYOUT!, isGuildStoreSell: " ..tos(isGuildStoreSell))
end
--Standard inv layout
layoutData = BACKPACK_DEFAULT_LAYOUT_FRAGMENT.layoutData
local additionalLayoutData = util.GetAlternativeInventoryLayoutData(invTypeUpdateListAnchor)
if additionalLayoutData ~= nil then
local layoutWasChanged = false
local layoutDataCopy = ZO_ShallowTableCopy(layoutData)
for key,value in pairs(additionalLayoutData) do
layoutDataCopy[key] = value
layoutWasChanged = true
end
layoutData = layoutDataCopy
if debugSpam and layoutWasChanged == true then
d(">>Overwrote some layoutData settings with additional layoutdata")
end
end
end
if debugSpam then
d(">>invTypeUpdateListAnchor: " ..tos(invTypeUpdateListAnchor) .. "-layoutData.backpackOffsetY: " ..tos(layoutData.backpackOffsetY) .. ", sortByOffsetY: " ..tos(layoutData.sortByOffsetY) .. ", width: " .. tos(layoutData.width))
end
if not layoutData then
return
end
--For debugging
AF.currentLayoutData = layoutData
local list = self.list
if not list and self.inventories ~= nil and self.inventories[invTypeUpdateListAnchor] ~= nil then
list = self.inventories[invTypeUpdateListAnchor].listView
end
--No inventory list found: Detect it now (crafting research e.g.)
if not list then
if debugSpam then
d(">no list control found yet")
end
local listData
local moveInvBottomBarDown
local anchorTo = (p_subFilterBar and p_subFilterBar.control) or nil
local reanchorData
--Get the Smithing research list(s) e.g. and reanchor it
listData, moveInvBottomBarDown, reanchorData = getListControlForSubfilterBarReanchor(invTypeUpdateListAnchor)
if not listData then return end
--list:SetWidth(layoutData.width)
list = listData.control
if list then
--d(">>list found by util.GetListControlForSubfilterBarReanchor")
list:ClearAnchors()
list:SetAnchor(listData.anchorPoint or TOP, listData.relativeTo or anchorTo, listData.relativePoint or BOTTOM, listData.offsetX or 0, listData.offsetY or layoutData.backpackOffsetY)
--Move the inventory's bottom bar more down?
if moveInvBottomBarDown then
--Do not move the bar if the addon PerfectPixel is active as it was moved already
if not PP then
moveInvBottomBarDown:ClearAnchors()
moveInvBottomBarDown:SetAnchor(TOPLEFT, list:GetParent(), BOTTOMLEFT, 0, shiftY)
moveInvBottomBarDown:SetAnchor(BOTTOMRIGHT)
end
end
end
else
if debugSpam then
d(">list was found!")
end
--List given
list:SetWidth(layoutData.width)
list:ClearAnchors()
local offsetYList = layoutData.backpackOffsetY
local anchorVar
if isQuickslot == true then
anchorVar = controlsForChecks.quickslotControl
--offsetYList = offsetYList + shiftY
end
list:SetAnchor(TOPRIGHT, anchorVar, TOPRIGHT, 0, offsetYList)
list:SetAnchor(BOTTOMRIGHT)
if debugSpam then
d(">ZO_ScrollList was moved on Y to: " .. (offsetYList) .. ", new height: " ..tos(list:GetHeight()))
end
ZO_ScrollList_SetHeight(list, list:GetHeight())
end
--For debugging
if list then
AF.currentList = list
end
--Additional controls to reanchor?
--Get the Smithing research line horizontal scroll list, and other controls below, and reanchor it e.g.
local _, _, reanchorData = getListControlForSubfilterBarReanchor(invTypeUpdateListAnchor)
if reanchorData ~= nil then
if debugSpam then
d(">>>ReAnchor data was found!")
end
for _, reanchorControlData in ipairs(reanchorData) do
local controlToReanchor = reanchorControlData.control
if controlToReanchor ~= nil then
if reanchorControlData.anchorPoint ~= nil
and reanchorControlData.relativeTo ~= nil and reanchorControlData.relativePoint ~= nil
and reanchorControlData.offsetX ~= nil and reanchorControlData.offsetY ~= nil then
if debugSpam and reanchorControlData.GetName and reanchorControlData.relativeTo.GetName then
d(">>reanchoring \'" ..tos(reanchorControlData:GetName()) .. "\' anchorPoint: "..tos(reanchorControlData.anchorPoint) .. " to relativeControl \'" .. tos(reanchorControlData.relativeTo:GetName()) .. "\', relativePoint: " ..tos(reanchorControlData.relativePoint) .. ", offSetX: " ..tos(reanchorControlData.offsetX) .. ", offSetY: " ..tos(reanchorControlData.offsetY))
end
controlToReanchor:ClearAnchors()
controlToReanchor:SetAnchor(reanchorControlData.anchorPoint, reanchorControlData.relativeTo, reanchorControlData.relativePoint, reanchorControlData.offsetX, reanchorControlData.offsetY)
end
end
end
end
--Sort header reanchor
local sortBy = self.sortHeaders or self.sortHeaderGroup
if sortBy == nil and self.GetDisplayInventoryTable then
sortBy = self:GetDisplayInventoryTable(invTypeUpdateListAnchor).sortHeaders
end
if sortBy == nil then return end
sortBy = sortBy.headerContainer
sortBy:ClearAnchors()
local sortHeaderOffsetY = 0
local anchorVar
if isQuickslot == true then
--sortHeaderOffsetY = shiftY
anchorVar = controlsForChecks.quickslotControl
end
local offsetYSortHeader = (layoutData.sortByOffsetY ~= nil and layoutData.sortByOffsetY + sortHeaderOffsetY) or sortHeaderOffsetY
--[[
if p_isCraftingInventoryType == true then
offsetYSortHeader = offsetYSortHeader + shiftY
end
]]
sortBy:SetAnchor(TOPRIGHT, anchorVar, TOPRIGHT, 0, offsetYSortHeader)
if debugSpam then
d(">sortBy was moved on Y to: " ..tos(offsetYSortHeader))
end
--Should some inventory controls be hidden?
-->Called in the fragment callback function for OnShow!
--hideInventoryControls(invTypeUpdateListAnchor)
if debugSpam then
d("]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]")
end
end
----------------------------------------------------------------------------------------------------------------
--ReAnchor other controls so that the subfilter bar will be shown properly
local getCraftingTablePanelIncludeBankedCheckbox = util.GetCraftingTablePanelIncludeBankedCheckbox
local function reAnchorIncludeBankedItemsCheckbox(filterPanelId, subFilterBarHeight)
--d("[AF]reAnchorIncludeBankedItemsCheckbox")
--FCOCraftFilter enabled? Then do nothing as it will hide the checkbox!
--if FCOCraftFilter ~= nil then return end
--Currently the checkbox is only shown at the crafting panels
filterPanelId = filterPanelId or util.GetCurrentFilterTypeForInventory(AF.currentInventoryType)
isUniversalDeconPanelShown = isUniversalDeconPanelShown or util.LibFilters.IsUniversalDeconstructionPanelShown
util.IsUniversalDeconPanelShown = isUniversalDeconPanelShown
isUniversalDecon = isUniversalDecon or isUniversalDeconPanelShown(filterPanelId)
if not isCraftingPanelShown() and not isUniversalDecon then return end
--d(">filterPanelId: " ..tos(filterPanelId))
local ZOsControlNames = AF.ZOsControlNames
--[[
local includeBankedCBoxName = ZOsControlNames.includeBankedCheckbox
local craftingTablePanel = util.GetCraftingTablePanel(filterPanelId)
local includeBankedCbox = craftingTablePanel and craftingTablePanel.control and craftingTablePanel.control:GetNamedChild(includeBankedCBoxName)
local parentCtrl = craftingTablePanel.control
if not includeBankedCbox then
local craftingTablePanelInv = util.GetCraftingTablePanelInventory(filterPanelId)
includeBankedCbox = craftingTablePanelInv and craftingTablePanelInv.control and craftingTablePanelInv.control:GetNamedChild(includeBankedCBoxName)
parentCtrl = craftingTablePanelInv.control
end
]]
getCraftingTablePanelIncludeBankedCheckbox = getCraftingTablePanelIncludeBankedCheckbox or util.GetCraftingTablePanelIncludeBankedCheckbox
local includeBankedCbox, parentCtrl, universalDeconCraftTypeFilterDDBox = getCraftingTablePanelIncludeBankedCheckbox(filterPanelId, isUniversalDecon)
if includeBankedCbox and parentCtrl then
--Unanchor the filterDivider control
local includeBankedCBoxFilterDividerName = ZOsControlNames.filterDivider
local filterDivider = parentCtrl:GetNamedChild(includeBankedCBoxFilterDividerName)
if filterDivider and filterDivider.ClearAnchors then filterDivider:ClearAnchors() end
--Unanchor the buttonDivider control
local includeBankedCBoxButtonDividerName = ZOsControlNames.buttonDivider
local buttonDivider = parentCtrl:GetNamedChild(includeBankedCBoxButtonDividerName)
if buttonDivider and buttonDivider.ClearAnchors then buttonDivider:ClearAnchors() end
--Move on the y axis the "height of a subfilter bar" pixels to the top, and an additional 5 pixels more to the top
--SetAnchor(AnchorPosition myPoint, object anchorTargetControl, AnchorPosition anchorControlsPoint, number offsetX, number offsetY)
includeBankedCbox:ClearAnchors()
includeBankedCbox:SetAnchor(TOPLEFT, parentCtrl, TOPLEFT, 0, subFilterBarHeight-5)
--Universal deconstruction
if isUniversalDecon and universalDeconCraftTypeFilterDDBox ~= nil then
universalDeconCraftTypeFilterDDBox:ClearAnchors()
universalDeconCraftTypeFilterDDBox:SetHidden(true)
end
end
end
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
local invType = currentInvType
if invType == nil then invType = AF.currentInventoryType end
local currentFilterToUse
if debugSpam then
d(">invType: " ..tos(invType) .. ", currentInvType: " ..tos(currentInvType) .. ", AF.currentInventoryType: " ..tos(AF.currentInventoryType))
end
--Check for custom added inventory filter button
--CraftBag
if invType == INVENTORY_CRAFT_BAG then
local afCBCurrentFilter = AF.craftBagCurrentFilter
local oldCurrentFilter = currentFilter
if AF.settings.debugSpam then d("[AF]ShowSubfilterBar craftbag, oldCurrentFilter: " ..tos(oldCurrentFilter) ..", currentFilter: " .. tos(currentFilter) .. ", afCBCurrentFilter: " .. tos(afCBCurrentFilter)) end
--d("~~~~~~~~ Show SubfilterBar craftBagCurrentFilter: " ..tos(AF.craftBagCurrentFilter) .. "; oldCurrentFilter: " .. tos(oldCurrentFilter) ..", currentFilter: " ..tos(currentFilter))
--Last saved CraftBag selected tab filter (currentFilter) was saved as the CB fragment was hidden, and it was not selecting "All" items, and the current filter at the
--CraftBag is the same as the last saved one?
if afCBCurrentFilter and afCBCurrentFilter ~= ITEMFILTERTYPE_ALL and afCBCurrentFilter == currentFilter then
--Set prevention variable for function ShowSubfilterBar at the craftbag.
--Check if the currentFilter variable changed to 0 () now (Which happens if we opened the guild store after the craftbag, and reopening the craftbag now.
--See issue 7 at AdvancedFilters github: https://github.com/Randactyl/AdvancedFilters/issues/7
--local currentCBFilter = playerInvVar.inventories[INVENTORY_CRAFT_BAG].currentFilter
local currentCBFilter = getCurrentFilter(INVENTORY_CRAFT_BAG, true) --Only get the base inventory currentFilter, no mapped one (e.g. CraftBag's misc. tab -> ITEMFILTERTYPE_AF_CRAFTBAG_MISCELLANEOUS instead of ITEM_TYPE_DISPLAY_CATEGORY_MISCELLANEOUS)
if debugSpam then
d(">currentCBFilter: " .. tos(currentCBFilter))
end
if currentCBFilter == ITEMFILTERTYPE_ALL then
--The currentFilter has reset to "All", so we need to restore it to the last known value again now
--d(">>changing PLAYER_INVENTORY craftbag currentfilter to: " .. tos(currentCBFilter))
PLAYER_INVENTORY.inventories[INVENTORY_CRAFT_BAG].currentFilter = afCBCurrentFilter
currentFilter = afCBCurrentFilter
end
end
--Check if we need to map the currentFilterToUse to another filter, internal AF filte -> To show the proper subfilterBar
--e.g. map inventories ITEM_TYPE_DISPLAY_CATEGORY_MISCELLANEOUS at CraftBag to internal AF filterType ITEMFILTERTYPE_AF_CRAFTBAG_MISCELLANEOUS
currentFilterToUse = getCurrentFilter(invType, false, currentFilter)
--d(">>currentFilterToUse: " .. tos(currentFilterToUse))
elseif invType == LF_QUICKSLOT then
--Quickslots
--Get the currentFilter
currentFilterToUse = getInvTypeCurrentQuickslotFilter(invType, currentFilter)
if currentFilterToUse == nil then return end
elseif isUniversalDecon == true then
--currentFilter is UNIVERSAL_DECONSTRUCTION.deconstructionPanel.inventory.AF_currentFilter
currentFilterToUse = customInventoryFilterButtonsItemType
if currentFilterToUse == nil then currentFilterToUse = currentFilter end
else
--d("[AF]invType: " .. tos(invType) .. ", currentFilterToUse1: " ..tos(currentFilterToUse) .. "; customInventoryFilterButtonsItemType: " .. tos(customInventoryFilterButtonsItemType) .. "; currentFilter: " ..tos(currentFilter))
--Is the filterType of the current menuBar button a custom addon filter function or filterType?
currentFilterToUse = customInventoryFilterButtonsItemType
if currentFilterToUse == nil then currentFilterToUse = currentFilter end
--Check if we need to map the currentFilterToUse to another filter, internal AF filter.
--e.g. map inventories ITEM_TYPE_DISPLAY_CATEGORY_MISCELLANEOUS at CraftBag to internal AF filterType ITEMFILTERTYPE_AF_CRAFTBAG_MISCELLANEOUS
doesInventoryTypeNeedsMappingToCustomAFCurrentFilter = doesInventoryTypeNeedsMappingToCustomAFCurrentFilter or util.DoesInventoryTypeNeedsMappingToCustomAFCurrentFilter
if doesInventoryTypeNeedsMappingToCustomAFCurrentFilter(invType) then
currentFilterToUse = getCurrentFilter(invType, false, currentFilterToUse)
end
end
if craftingType == nil then craftingType = GetCraftingType() end
if AF.settings.debugSpam then d("[AF]ShowSubfilterBar - currentFilter: " .. tos(currentFilter) .. ", currentFilterToUse: " ..tos(currentFilterToUse) .. ", craftingType: " .. tos(craftingType) .. ", invType: " .. tos(invType) .. ", customInventoryFilterButtonsItemType: " ..tos(customInventoryFilterButtonsItemType)) end
--[[
--Guild store?
if currentFilter == ITEMFILTERTYPE_TRADING_HOUSE then
--d(">GuildStore itemfiltertype found!")
--Set the "block inventory filter prehook" variable
AF.blockOnInventoryFilterChangedPreHookForCraftBag = true
else
--d(">NO GuildStore itemfiltertype found!")
AF.blockOnInventoryFilterChangedPreHookForCraftBag = false
end
]]
--Supported panel? SubfilterBar filters are provided?
--Check if any not supported panel is given and do not show a message in chat then
local notSupportedPanel, panelModeVar = detectNotSupportedSubfilterPanel(craftingType)
--Error handling: Hiding old subfilter bar
-- e.g. for missing variables, or if other addons might have changed the currentFilter or currentInventoryType (indirectly by their stuff -> loadtime was increased -> filter change did not happen in time for AF due to this)
local doDebugOutput = AF.settings.doDebugOutput
local subfilterGroupMissingForInvType = false
local subfilterBarMissing = false
if doDebugOutput then
local showErrorInChat = false
if invType == nil then
--d(">InvType is nil")
showErrorInChat = true
end
if AF.subfilterGroups[invType] == nil then
showErrorInChat = true
--d(">subfilterGroupMissingForInvType: " .. tos(invType))
subfilterGroupMissingForInvType = true
end
if currentFilterToUse == nil then
--d(">currentFilterToUse is nil")
showErrorInChat = true
end
if craftingType == nil then
--d(">craftingType is nil")
showErrorInChat = true
end
local subFilterBarName
if invType ~= nil and craftingType ~= nil and currentFilterToUse ~= nil then
local nextSubfilterBar = AF.subfilterGroups[invType][craftingType][currentFilterToUse]
if nextSubfilterBar == nil then
--d(">subfilterBarMissing true")
subfilterBarMissing = true
showErrorInChat = true
subFilterBarName = "N/A"
else
subFilterBarName = nextSubfilterBar.name
--d(">nextSubfilterBarName: " ..tos(subFilterBarName))
end
end
if notSupportedPanel then
if debugSpam then
d("<Not supported panel for craftingType "..tos(craftingType) .. ", panelMode: " ..tos(panelModeVar))
end
end
--Show a debug message now and abort here?
if showErrorInChat and AF.subFiltersBarInactive[currentFilterToUse] == nil and notSupportedPanel == false then
showChatDebug("ShowSubfilterBar - BEGIN", "InventoryType: " ..tos(invType) .. ", craftingType: " ..tos(craftingType) .. "/" .. util.GetCraftingType() .. ", currentFilter: " .. tos(currentFilterToUse) .. ", subFilterGroupMissing: " ..tos(subfilterGroupMissingForInvType) .. ", subfilterBarMissing: " ..tos(subfilterBarMissing) .. ", subfilterBarName: " ..tos(subFilterBarName))
return false
end
end
--Not supported panel detected, abort here as we got no subfilterGroup and thus no Bar to show!
if notSupportedPanel == true then
return false
end
--Get the old subfilterbar + the new subfilterbar group data
local subfilterGroup = AF.subfilterGroups[invType]
--hide old bar, if it exists
if subfilterGroup.currentSubfilterBar ~= nil then
subfilterGroup.currentSubfilterBar:SetHidden(true)
end
--hide old bar at same parent
hideSubfilterBarSameParent(invType, isUniversalDecon)
--Old subfilterbar(s) was(were) hidden, so check if a new one should be shown now
if CheckIfNoSubfilterBarShouldBeShown(currentFilterToUse, invType) then
if AF.settings.debugSpam then d("<<ABORT: CheckIfNoSubfilterBarShouldBeShown: true") end
return
end
--do nothing if we're in a guild store and regular filters are disabled.
--LibCommonInventoryFilters is not used anymore!
--[[
if not ZO_TradingHouse:IsHidden() and (util.libCIF and util.libCIF._guildStoreSellFiltersDisabled) then
if AF.settings.debugSpam then d("<<ABORT: Trading house libCIF:guildSToreSellFiltersDisabled!") end
return
end
]]
--Get the new subFilterBar to show
local subfilterBarBase = subfilterGroup[craftingType]
if subfilterBarBase == nil then
showChatDebug("ShowSubfilterBar - SubFilterBarBase missing", "InventoryType: " ..tos(invType) .. ", craftingType: " ..tos(craftingType) .. "/" .. util.GetCraftingType() .. ", currentFilter: " .. tos(currentFilterToUse) .. ", subFilterGroupMissing: " ..tos(subfilterGroupMissingForInvType) .. ", subfilterBarMissing: " ..tos(subfilterBarMissing))
return
end
local subfilterBar = subfilterBarBase[currentFilterToUse]
if subfilterBar == nil and AF.subFiltersBarInactive[currentFilterToUse] == nil then
--SubfilterBar is nil but maybe we do not need any here at teh given inventory & curerntFilter?
if currentFilterToUse ~= nil and AF.subFiltersBarInactive[currentFilterToUse] == nil then
showChatDebug("ShowSubfilterBar - SubFilterBar missing", "InventoryType: " ..tos(invType) .. ", craftingType: " ..tos(craftingType) .. "/" .. util.GetCraftingType() .. ", currentFilter: " .. tos(currentFilterToUse) .. ", subFilterGroupMissing: " ..tos(subfilterGroupMissingForInvType) .. ", subfilterBarMissing: " ..tos(subfilterBarMissing))
return
end
end
--if new bar exists
local craftingInv
local isCraftingInventoryType = false
local subFilterBarHeight
if subfilterBar then
local inventoryType = subfilterBar.inventoryType
local isCraftingPanel = IsCraftingPanelShown()
if AF.settings.debugSpam then d(">>New subfilterBar was found, isCraftingPanel: " ..tos(isCraftingPanel)) end
--Crafting
if isCraftingPanel == true then
isCraftingInventoryType = IsCraftingStationInventoryType(inventoryType)
if isCraftingInventoryType then
craftingInv = GetInventoryFromCraftingPanel(inventoryType)
end
end
--set current bar reference
subfilterGroup.currentSubfilterBar = subfilterBar
if AF.settings.debugSpam then d(">subfilterBar exists, name: " .. tos(subfilterBar.control:GetName()) .. ", inventoryType: " ..tos(inventoryType)) end
--Update the currentFilter to the current inventory
UpdateCurrentFilter(inventoryType, currentFilter, isCraftingInventoryType, craftingInv, currentFilterToUse)
--For debugging
if isUniversalDecon == true then
AF.lastUniversalDeconSubfilterBar = subfilterBar
end
AF.currentSubfilterBar = subfilterBar
if debugSpam then
d(">>>subfilterBar.inventoryType: " ..tos(inventoryType))
end
--activate current subfilter bar's button -> Will also update the filter dropdown box!
subfilterBar:ActivateButton(subfilterBar:GetCurrentButton())
--show the new subfilter bar
subfilterBar:SetHidden(false)
subFilterBarHeight = subfilterBar.control:GetHeight()
--set proper inventory anchor displacement
if subfilterBar.inventoryType == INVENTORY_TYPE_VENDOR_BUY then
UpdateListAnchors(store, subFilterBarHeight, subfilterBar, false)
elseif isUniversalDecon == true or subfilterBarInventorytypesOfUniversalDecon[inventoryType] then
isUniversalDecon = true
UpdateListAnchors(universalDeconPanelInv, subFilterBarHeight, subfilterBar, false)
elseif invType == LF_QUICKSLOT then
UpdateListAnchors(quickslotVar, 0, nil, false)
elseif invType == LF_INVENTORY_COMPANION then
UpdateListAnchors(companionInvVar, subFilterBarHeight, subfilterBar, isCraftingInventoryType)
elseif isCraftingInventoryType then
UpdateListAnchors(craftingInv, subFilterBarHeight, subfilterBar, isCraftingInventoryType)
else
UpdateListAnchors(playerInvVar, subFilterBarHeight, subfilterBar, isCraftingInventoryType)
end
else
--Crafting
if IsCraftingPanelShown() then
isCraftingInventoryType = IsCraftingStationInventoryType(invType)
if isCraftingInventoryType then
craftingInv = GetInventoryFromCraftingPanel(invType)
end
end
if AF.settings.debugSpam then d(">>New subfilterBar was NOT found, isCraftingPanel: " ..tos(IsCraftingPanelShown())) end
--Update the currentfilter to the inventory so it will be the correct one (e.g. if you change after this "return false" below to the CraftBag and back to the inventory,
--the currentFilter will be the wrong one from before, and thus the subfilterbar of the before filter wil be shown at this currentFilter).
--Update the currentFilter to the current inventory
UpdateCurrentFilter(invType, currentFilter, isCraftingInventoryType, craftingInv, currentFilterToUse)
--remove all filters
util.RemoveAllFilters()
--set original inventory anchor displacement
if invType == INVENTORY_TYPE_VENDOR_BUY then
UpdateListAnchors(store, 0, nil, false)
elseif isUniversalDecon == true or subfilterBarInventorytypesOfUniversalDecon[invType] then
isUniversalDecon = true
UpdateListAnchors(universalDeconPanelInv, 0, nil, false)
elseif invType == LF_QUICKSLOT then
UpdateListAnchors(quickslotVar, 0, nil, false)
elseif invType == LF_INVENTORY_COMPANION then
UpdateListAnchors(companionInvVar, 0, nil, false)
elseif isCraftingInventoryType then
UpdateListAnchors(craftingInv, 0, nil, true)
else
UpdateListAnchors(playerInvVar, 0, nil, false)
end
--remove current bar reference
subfilterGroup.currentSubfilterBar = nil
--Error handling: Showing new subfilter bar
if doDebugOutput then
if (currentFilterToUse == nil or (currentFilterToUse ~= nil and AF.subFiltersBarInactive[currentFilterToUse] == nil)) and notSupportedPanel == false then
showChatDebug("ShowSubfilterBar - END", "InventoryType: " ..tos(invType) .. ", craftingType: " ..tos(craftingType) .. "/" .. util.GetCraftingType() .. ", currentFilter: " .. tos(currentFilterToUse))
end
end
end
--Reanchor the checkbox "Include banked items" at the crafting panels
if isCraftingInventoryType or isUniversalDecon then
subFilterBarHeight = (subfilterBar and subfilterBar.control:GetHeight()) or 50
reAnchorIncludeBankedItemsCheckbox(nil, subFilterBarHeight)
end
end -- function "ShowSubfilterBar"
--=== FRAGMENTS=========================================================================================================
--FRAGMENT HOOKS
local function hookFragment(fragment, inventoryType)
local function onFragmentShowing(p_fragment)
local debugSpam = AF.settings.debugSpam
if debugSpam then
d("[AF]OnFragmentShowing - inventoryType: " ..tos(inventoryType) .. ", invTypeOverride: " ..tos(AF.currentInventoryTypeOverride))
end
local doNormalChecks = true
local inventoryControl
local inventoryTypeUpdated
--Special treatment for qucisklots
if p_fragment == quickslotFragment and inventoryType == LF_QUICKSLOT then
--d(">quickSlot")
if debugSpam then
d(">quickslots")
end
doNormalChecks = false
AF.currentInventoryTypeOverride = nil
AF.currentInventoryType = LF_QUICKSLOT
inventoryControl = (QUICKSLOT_KEYBOARD ~= nil and quickslotVar.control) or quickslotVar.container
inventoryTypeUpdated = LF_QUICKSLOT
ThrottledUpdate("ShowSubfilterBar_Quickslots", 20, ShowSubfilterBar, quickslotVar.currentFilter, nil, nil, LF_QUICKSLOT)
if controlsForChecks.quickslotWheelUnderlay ~= nil then
controlsForChecks.quickslotWheelUnderlay:SetHidden(true)
end
end
if doNormalChecks == true then
local libFiltersPanelId
if util.DoesInventoryTypeEqualLibFiltersType(inventoryType) == true then
libFiltersPanelId = inventoryType
else
libFiltersPanelId = util.LibFilters:GetCurrentFilterTypeForInventory(inventoryType)
end
if debugSpam then
d(">libFiltersPanelId: " ..tos(libFiltersPanelId))
end
--AF.currentInventoryTypeOverride will be set if the inventory's quest item tab was opened before the
--inventory fragment get's hidden. AF.currentInventoryCurrentFilter will be ITEM_TYPE_DISPLAY_CATEGORY_QUEST
--(8) in that case!
--But do not override the inventoryType if the mail send/player trade panels open as they do not own a quest
--item inventory tab!
if inventoryType == INVENTORY_BACKPACK and
AF.currentInventoryTypeOverride and AF.currentInventoryTypeOverride == INVENTORY_QUEST_ITEM then
local sceneNames = AF.scenesForChecks
--Check if mail send or player trade are shown
if debugSpam then
d(">>libFiltersPanelId - INVENTORY_BACKPACK: " ..tos(libFiltersPanelId))
end
if ((libFiltersPanelId and (libFiltersPanelId == LF_MAIL_SEND or libFiltersPanelId == LF_TRADE or
libFiltersPanelId == LF_BANK_DEPOSIT or libFiltersPanelId == LF_GUILDBANK_DEPOSIT or
libFiltersPanelId == LF_GUILDSTORE_SELL or
libFiltersPanelId == LF_FENCE_SELL or libFiltersPanelId == LF_FENCE_LAUNDER )) or
(MAIL_SEND.control and not MAIL_SEND.control:IsHidden()) or
(TRADE.control and not TRADE.control:IsHidden()) or
util.IsSceneShown(sceneNames.bank) or
util.IsSceneShown(sceneNames.guildBank) or
util.IsSceneShown(sceneNames.tradinghouse) or
(TRADING_HOUSE.currentMode == ZO_TRADING_HOUSE_MODE_SELL or (TRADING_HOUSE.control and not TRADING_HOUSE.control:IsHidden())) or
util.IsSceneShown(sceneNames.fence)
)
then
AF.currentInventoryTypeOverride = nil
if debugSpam then
d("<<Deleted: AF.currentInventoryTypeOverrid")
end
end
end
local currentInventoryTypeOverride = AF.currentInventoryTypeOverride
AF.currentInventoryType = currentInventoryTypeOverride
if AF.currentInventoryType == nil then AF.currentInventoryType = inventoryType end
if debugSpam then
d(">>AF.currentInvType = " ..tos(AF.currentInventoryType) .. " / invType: " ..tos(inventoryType).. "/override: " ..tos(currentInventoryTypeOverride))
end
inventoryTypeUpdated = currentInventoryTypeOverride or inventoryType
AF.currentInventoryTypeOverride = nil
if inventoryType == INVENTORY_TYPE_VENDOR_BUY then