11local W , F , E , L = unpack ((select (2 , ... ))) --- @type WindTools , Functions , ElvUI , LocaleTable
22local AK = W :NewModule (" AlreadyKnown" , " AceEvent-3.0" , " AceHook-3.0" ) --- @class AlreadyKnown : AceModule , AceEvent-3.0 , AceHook-3.0
33
4- -- Some check logic references code from Legion Remix Helper.
4+ -- Some check logic references code from Legion Remix Helper & AlreadyKnown
55
66local _G = _G
77local ceil = ceil
88local format = format
9+ local ipairs = ipairs
910local mod = mod
1011local select = select
1112local strfind = strfind
1213local strmatch = strmatch
1314local tonumber = tonumber
1415
16+ local ContainsIf = ContainsIf
1517local GetBuybackItemInfo = GetBuybackItemInfo
1618local GetBuybackItemLink = GetBuybackItemLink
1719local GetCurrentGuildBankTab = GetCurrentGuildBankTab
@@ -21,12 +23,15 @@ local GetMerchantItemLink = GetMerchantItemLink
2123local GetMerchantNumItems = GetMerchantNumItems
2224local GetNumBuybackItems = GetNumBuybackItems
2325local PlayerHasToy = PlayerHasToy
26+ local RunNextFrame = RunNextFrame
2427local SetItemButtonDesaturated = SetItemButtonDesaturated
2528local SetItemButtonTextureVertexColor = SetItemButtonTextureVertexColor
2629
2730local C_AddOns_IsAddOnLoaded = C_AddOns .IsAddOnLoaded
2831local C_Item_GetItemInfoInstant = C_Item .GetItemInfoInstant
32+ local C_Item_GetItemInventoryTypeByID = C_Item .GetItemInventoryTypeByID
2933local C_Item_GetItemLearnTransmogSet = C_Item .GetItemLearnTransmogSet
34+ local C_Item_IsCosmeticItem = C_Item .IsCosmeticItem
3035local C_MerchantFrame_GetItemInfo = C_MerchantFrame .GetItemInfo
3136local C_MountJournal_GetMountFromItem = C_MountJournal .GetMountFromItem
3237local C_MountJournal_GetMountInfoByID = C_MountJournal .GetMountInfoByID
@@ -39,23 +44,44 @@ local C_TransmogCollection_PlayerHasTransmogByItemInfo = C_TransmogCollection.Pl
3944local C_TransmogSets_GetSetInfo = C_TransmogSets .GetSetInfo
4045local C_Transmog_GetAllSetAppearancesByID = C_Transmog .GetAllSetAppearancesByID
4146
47+ local Enum_ItemClass_Battlepet = Enum .ItemClass .Battlepet
4248local BUYBACK_ITEMS_PER_PAGE = BUYBACK_ITEMS_PER_PAGE
4349local COLLECTED = COLLECTED
44- local Enum_ItemClass_Battlepet = Enum .ItemClass .Battlepet
4550local ITEM_SPELL_KNOWN = ITEM_SPELL_KNOWN
51+ local PET_SEARCH_PATTERN = strmatch (ITEM_PET_KNOWN , " [^%((]+" )
4652local MAX_GUILDBANK_SLOTS_PER_TAB = 98
4753local NUM_SLOTS_PER_GUILDBANK_GROUP = 14
4854
4955local knowables = {
5056 [Enum .ItemClass .Consumable ] = true ,
57+ [Enum .ItemClass .Armor ] = true ,
58+ [Enum .ItemClass .ItemEnhancement ] = true ,
5159 [Enum .ItemClass .Recipe ] = true ,
5260 [Enum .ItemClass .Miscellaneous ] = true ,
53- [Enum .ItemClass .ItemEnhancement ] = true ,
61+ [Enum .ItemClass .Battlepet ] = true ,
62+ }
63+
64+ local transmogInventoryTypes = {
65+ [Enum .InventoryType .IndexBodyType ] = true ,
66+ [Enum .InventoryType .IndexTabardType ] = true ,
5467}
68+
5569local knowns = {}
5670
5771local function isPetCollected (speciesID )
58- return speciesID and speciesID ~= 0 and C_PetJournal_GetNumCollectedInfo (speciesID ) > 0
72+ local num = speciesID and C_PetJournal_GetNumCollectedInfo (speciesID )
73+ return num and num > 0
74+ end
75+
76+ local function isTransmogCollected (itemID , link )
77+ if not C_Item_IsCosmeticItem (itemID ) then
78+ local inventoryType = C_Item_GetItemInventoryTypeByID (itemID )
79+ if not transmogInventoryTypes [inventoryType ] then
80+ return false
81+ end
82+ end
83+
84+ return C_TransmogCollection_PlayerHasTransmogByItemInfo (itemID )
5985end
6086
6187local function isTransmogSetCollected (itemID )
85111
86112local function isMountCollected (itemID )
87113 local mountID = C_MountJournal_GetMountFromItem (itemID )
88- return mountID and mountID ~= 0 and select (11 , C_MountJournal_GetMountInfoByID (mountID ))
114+ return mountID and select (11 , C_MountJournal_GetMountInfoByID (mountID ))
89115end
90116
91117local function isToyCollected (itemID )
@@ -120,27 +146,32 @@ local function isAlreadyKnown(link, index)
120146 return true
121147 end
122148
149+ if not knowables [classID ] then
150+ return
151+ end
152+
123153 if
124154 isMountCollected (linkID )
125155 or isToyCollected (linkID )
126156 or isPetItemCollected (linkID )
157+ or isTransmogCollected (linkID )
127158 or isTransmogSetCollected (linkID )
128159 then
129160 knowns [link ] = true
130161 return true
131162 end
132163
133- if not knowables [classID ] then
134- return
135- end
136-
137164 -- Final check via tooltip parsing
138- local data = C_TooltipInfo_GetHyperlink (link , nil , nil , true )
165+ local data = C_TooltipInfo_GetHyperlink (link )
139166 if data then
140167 for _ , line in ipairs (data .lines ) do
141168 local text = line .leftText
142169 if text then
143- if strfind (text , COLLECTED , 1 , true ) or strfind (text , ITEM_SPELL_KNOWN , 1 , true ) then
170+ if
171+ strfind (text , COLLECTED , 1 , true )
172+ or strfind (text , ITEM_SPELL_KNOWN , 1 , true )
173+ or strmatch (text , PET_SEARCH_PATTERN )
174+ then
144175 knowns [link ] = true
145176 return true
146177 end
0 commit comments