Originally Posted by Lombra
What about C_TransmogCollection.GetAppearanceSourceInfo?
|
This is what I've
found in the UI source:
Lua Code:
local categoryID, appearanceVisualID, canEnchant, texture, isCollected, itemLink, appearanceLink, unknownNumber = C_TransmogCollection.GetAppearanceSourceInfo(appearanceSourceID);
It seems to work well when inspecting other players or with items on the AH
This is the code I used for testing, will do some tests later on other characters when I'm back:
Lua Code:
-- Lua API
local strfind, strmatch, tonumber, select = string.find, string.match, tonumber, select;
-- WoW API/Constants
local IsDressableItem, GetItemInfo = IsDressableItem, GetItemInfo;
local TRANSMOGRIFY_TOOLTIP_APPEARANCE_UNKNOWN, TRANSMOGRIFY_TOOLTIP_APPEARANCE_KNOWN = TRANSMOGRIFY_TOOLTIP_APPEARANCE_UNKNOWN, TRANSMOGRIFY_TOOLTIP_APPEARANCE_KNOWN;
-- Text
local tooltipAppearanceUnusable = "You can't collect this appearance";
local tooltipSuffix = " (*)"; -- Makes it easier to tell if Blizzard added the text or we did...
-----------------------------------------------------------------------------
-- Hidden DressUpModel
-- TODO: Use C_TransmogCollection.PlayerHasTransmog(itemID[, itemAppearanceModID]) when Blizzard finally decides to give us access to itemAppearanceModID for all items.
-----------------------------------------------------------------------------
local model = CreateFrame("DressUpModel");
local lastItem, lastResult;
-- I'm not sure if invisible frames impact game performance, resizing it just in case...
-- Can't :Hide() the frame, because it doesn't seem to "equip" items when hidden.
model:SetSize(1, 1);
local PlayerHasTransmog = function(item)
if (not model.isPlayer) then
model:SetUnit("player");
model:Undress();
model.isPlayer = true;
end
if (lastItem and lastItem == item) then
-- Tooltip update, reuse last results
return lastResult;
end
local isCollected = false;
model:TryOn(item);
-- TODO: Get correct slot using GetItemInfo
for i = 1, 18 do
local appearanceSourceID = model:GetSlotTransmogSources(i);
if (appearanceSourceID and appearanceSourceID > 0) then
isCollected = select(5, C_TransmogCollection.GetAppearanceSourceInfo(appearanceSourceID)) or false;
break;
end
end
model:Undress();
-- Cache results, TODO: Update it on transmog event, if there is one?
lastItem = item;
lastResult = isCollected;
return isCollected;
end
-----------------------------------------------------------------------------
-- Tooltip hooks
-----------------------------------------------------------------------------
local OnTooltipSetItemHook = function(self)
local _, itemLink = self:GetItem();
if (not itemLink) then return; end
local itemID = tonumber(strmatch(itemLink, "item:(%d+)"));
if (not itemID) then return; end
local isDressable = IsDressableItem(itemID);
local _, _, canBeSource, noSourceReason = C_Transmog.GetItemInfo(itemID);
if (not isDressable or not canBeSource) then
if (noSourceReason and noSourceReason == "INVALID_SOURCE") then
self:AddLine(tooltipAppearanceUnusable..tooltipSuffix, 255/255, 170/255, 126/255);
end
return;
end
local equipSlot = select(9, GetItemInfo(itemLink));
if (equipSlot == "INVTYPE_NECK" or equipSlot == "INVTYPE_FINGER" or equipSlot == "INVTYPE_TRINKET") then return; end
if (PlayerHasTransmog(itemLink)) then
self:AddLine(TRANSMOGRIFY_TOOLTIP_APPEARANCE_KNOWN..tooltipSuffix, 170/255, 255/255, 126/255);
else
-- Check if Blizzard already added the text to the tooltip,
-- they only add it to items equippable by the current class.
local found = false;
local tooltipName = self:GetName();
local numLines = self:NumLines();
for i = numLines, 1, -1 do
local frame = _G[tooltipName.."TextLeft"..i];
if (frame) then
local text = frame:GetText();
if (text and text == TRANSMOGRIFY_TOOLTIP_APPEARANCE_UNKNOWN) then
found = true;
break;
end
end
end
if (not found) then
self:AddLine(TRANSMOGRIFY_TOOLTIP_APPEARANCE_UNKNOWN..tooltipSuffix, 136/255, 170/255, 255/255);
end
end
end
GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItemHook);
ItemRefTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItemHook);
ItemRefShoppingTooltip1:HookScript("OnTooltipSetItem", OnTooltipSetItemHook);
ItemRefShoppingTooltip2:HookScript("OnTooltipSetItem", OnTooltipSetItemHook);
ShoppingTooltip1:HookScript("OnTooltipSetItem", OnTooltipSetItemHook);
ShoppingTooltip2:HookScript("OnTooltipSetItem", OnTooltipSetItemHook);
Originally Posted by Lombra
Since you do need to map the bonus IDs to appearance mod IDs, it will be unreliable/inconsistent, after all. :P
I'm in need of this, as well. I would much prefer not having to involve the annoying bonus IDs.
|
Old bonus IDs are known I think, but I'd rather have a solution that doesn's need updating everytime they decide to add new ones.