From 3fc530a3c14aff62ae0b0ddfb83eacd550e9eaa6 Mon Sep 17 00:00:00 2001 From: Caerdon Date: Sun, 27 Nov 2022 22:45:39 -0700 Subject: [PATCH] Fixed a few more issues with recognizing learned / unlearned items --- CaerdonWardrobe.toc | 2 +- features/Tooltip.lua | 6 +++-- tests/LeatherTests.lua | 2 +- types/EquipmentMixin.lua | 54 ++++++++++++++++++++++++++++++++-------- 4 files changed, 50 insertions(+), 14 deletions(-) diff --git a/CaerdonWardrobe.toc b/CaerdonWardrobe.toc index e456ba6..9190523 100755 --- a/CaerdonWardrobe.toc +++ b/CaerdonWardrobe.toc @@ -5,7 +5,7 @@ ## Title: Caerdon Wardrobe ## Notes: Shows BOE / BOA, openable, and unlearned pets, toys, mounts and wardrobe indicator on bank / bag / auction / merchant / guild bank / loot frame / loot roll / encounter journal slots ## Author: Caerdon -## Version: v3.3.3 +## Version: v3.3.4 ## SavedVariables: CaerdonWardrobeConfig ## OptionalDeps: WagoAnalytics, WoWUnit, AdiBags, AngrierWorldQuests, ArkInventory, Bagnon, BaudBag, cargBags_Nivaya, Combuctor, ElvUI, Inventorian, KkthnxUI, Pawn, Sorted, VenturePlan, WorldQuestsList, WorldQuestTab, WorldQuestTracker, ZygorGuidesViewer diff --git a/features/Tooltip.lua b/features/Tooltip.lua index 5933113..800d60b 100644 --- a/features/Tooltip.lua +++ b/features/Tooltip.lua @@ -272,8 +272,10 @@ function TooltipMixin:OnProcessInfo(tooltip, tooltipInfo) elseif tooltipInfo.getterName == "GetMerchantCostItem" then local slot, costIndex = unpack(tooltipInfo.getterArgs) local itemTexture, itemValue, itemLink, currencyName = GetMerchantItemCostItem(slot, costIndex); - local item = CaerdonItem:CreateFromItemLink(itemLink) - Tooltip:ProcessTooltip(tooltip, item) + if itemLink then + local item = CaerdonItem:CreateFromItemLink(itemLink) + Tooltip:ProcessTooltip(tooltip, item) + end elseif tooltipInfo.getterName == "GetMerchantItem" then local slot = unpack(tooltipInfo.getterArgs) local itemLink = GetMerchantItemLink(slot); diff --git a/tests/LeatherTests.lua b/tests/LeatherTests.lua index d26c217..c72e383 100644 --- a/tests/LeatherTests.lua +++ b/tests/LeatherTests.lua @@ -56,7 +56,7 @@ function Tests:ImbuedPioneerBracersNeed() AreEqual(info.canEquip, info.needsItem) AreEqual(UnitLevel("player") >= item:GetMinLevel(), info.hasMetRequirements) AreEqual(not info.canEquip, info.otherNeedsItem) - AreEqual(false, info.isCompletionistItem) + AreEqual(true, info.isCompletionistItem) AreEqual(true, info.matchesLootSpec) end diff --git a/types/EquipmentMixin.lua b/types/EquipmentMixin.lua index 4e8b0d6..eb97fe4 100644 --- a/types/EquipmentMixin.lua +++ b/types/EquipmentMixin.lua @@ -1,6 +1,37 @@ CaerdonEquipment = {} CaerdonEquipmentMixin = {} +local slotTable = { + INVTYPE_HEAD = 1, + INVTYPE_NECK = 2, + INVTYPE_SHOULDER = 3, + INVTYPE_BODY = 4, + INVTYPE_CHEST = 5, + INVTYPE_WAIST = 6, + INVTYPE_LEGS = 7, + INVTYPE_FEET = 8, + INVTYPE_WRIST = 9, + INVTYPE_HAND = 10, + INVTYPE_FINGER = 11, + INVTYPE_TRINKET = 13, + INVTYPE_WEAPON = 16, + INVTYPE_SHIELD = 17, + INVTYPE_RANGED = 16, + INVTYPE_CLOAK = 15, + INVTYPE_2HWEAPON = 16, + INVTYPE_BAG = 0, + INVTYPE_TABARD = 19, + INVTYPE_ROBE = 5, + INVTYPE_WEAPONMAINHAND = 16, + INVTYPE_WEAPONOFFHAND = 16, + INVTYPE_HOLDABLE = 17, + INVTYPE_AMMO = 0, + INVTYPE_THROWN = 16, + INVTYPE_RANGEDRIGHT = 17, + INVTYPE_QUIVER = 0, + INVTYPE_RELIC = 0 +} + --[[static]] function CaerdonEquipment:CreateFromCaerdonItem(caerdonItem) if type(caerdonItem) ~= "table" or not caerdonItem.GetCaerdonItemType then error("Usage: CaerdonEquipment:CreateFromCaerdonItem(caerdonItem)", 2) @@ -169,8 +200,8 @@ function CaerdonEquipmentMixin:GetTransmogInfo() else appearanceID, sourceID = C_TransmogCollection.GetItemInfo(itemLink) if not sourceID and C_Item.IsDressableItemByID(item:GetItemID()) then -- not finding via transmog collection so need to do the DressUp hack - -- local slotName = item:GetInventoryTypeName() - local slotID = C_Item.GetItemInventoryTypeByID(item:GetItemLink()) + local inventoryType = item:GetInventoryTypeName() + local slotID = slotTable[inventoryType] -- print(item:GetItemLink() .. " is dressable") @@ -179,14 +210,17 @@ function CaerdonEquipmentMixin:GetTransmogInfo() self.dressUp:SetUnit('player') end - self.dressUp:Undress() - self.dressUp:TryOn(itemLink, slotID) - -- print("CHECKING FOR SLOT: " .. tostring(slotID)) - local transmogInfo = self.dressUp:GetItemTransmogInfo(slotID) - if transmogInfo then - sourceID = transmogInfo.appearanceID -- I don't know why, but it is. - if sourceID and sourceID ~= NO_TRANSMOG_SOURCE_ID then - appearanceID = select(2, C_TransmogCollection.GetAppearanceSourceInfo(sourceID)) + if slotID and slotID > 0 then + self.dressUp:Undress() + self.dressUp:TryOn(itemLink, slotID) + -- print("CHECKING FOR SLOT: " .. tostring(slotID)) + local transmogInfo = self.dressUp:GetItemTransmogInfo(slotID) + + if transmogInfo then + sourceID = transmogInfo.appearanceID -- I don't know why, but it is. + if sourceID and sourceID ~= NO_TRANSMOG_SOURCE_ID then + appearanceID = select(2, C_TransmogCollection.GetAppearanceSourceInfo(sourceID)) + end end end end