WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Inspect another's transmog info? (https://www.wowinterface.com/forums/showthread.php?t=53435)

Hiketeia 05-14-16 02:13 PM

Inspect another's transmog info?
 
Still new at this all so I can't tell if I just can't find the function I want, or if it doesn't exist, or if I'm not using the calls I have correctly...

I want to be able to get item info about another person's transmog gear.

In the default UI, if you inspect someone, hover over them, the game tooltip shows the "Transmogrified to:" entry and lists the name of the item. Looking into InspectPaperDollFrame.lua in the Blizzard_InspectUI it just uses GameTooltip:SetInventoryItem(InspectFrame.unit, self:GetID()) to do that. Looking at GameTooltip.lua from FrameXML though has no SetInventoryItem method that I can review to see how it does that.

Looking through the API listing, and I found GetTransmogrifySlotInfo, with works great for my own inventory but doesn't seem to take a 'unit' like all the other GetInventory* calls so I can't use it during an inspect?

Will I have to do that tooltip scraping thing others have mentioned and then look up the inventory info based on the name of the item pulled from the tooltip? Seems like there should be a better way.

Thanks for any pointers.

In you're curious here is the code that dumps your own transmog info.
Lua Code:
  1. transmogSlots = { InspectHeadSlot, InspectShoulderSlot, InspectBackSlot, InspectChestSlot, InspectWristSlot, InspectHandsSlot, InspectWaistSlot, InspectLegsSlot, InspectFeetSlot, InspectMainHandSlot, InspectSecondaryHandSlot }
  2.  
  3. unit = "player"
  4.  
  5. for i, slot in ipairs(transmogSlots) do
  6.    slotId = slot:GetID()
  7.    local isTransmogrified, canTransmogrify, cannotTransmogrifyReason, hasPending, hasUndo, visibleItemID, textureName = GetTransmogrifySlotInfo(slotId)
  8.    if isTransmogrified then
  9.       local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(visibleItemID)
  10.       print (format("Slot %s is transmogrified to %s. %s", slotId, link))
  11.    end
  12.    
  13. end

Hiketeia 05-14-16 02:57 PM

So I used some code I found at this link: http://us.battle.net/wow/en/forum/topic/8481388146 for scanning tooltips. Got the name of the inventory item, works on me.

Tried it on a guy next to me, worked. Super!
Tried it on the next guy next me to me. Failed. Hmm... why is that nil... turns out GetItemInfo(itemName) only works if I own the gear :-(

Guess I'm out of luck going that route too :mad:

Code if it helps at all... excuse the sloppiness of it.

Lua Code:
  1. CreateFrame( "GameTooltip", "MyScanningTooltip", nil, "GameTooltipTemplate" ); -- Tooltip name cannot be nil
  2.  
  3. local function ScanTooltipOfUnitSlotForTransmog(unit,slot)
  4.    local tooltip = MyScanningTooltip
  5.    local isTransmogrified = false
  6.    local itemName = nil
  7.    tooltip:SetOwner( WorldFrame, "ANCHOR_NONE" ); -- does a ClearLines() already
  8.    tooltip:SetInventoryItem(unit,slot)
  9.    for i=1,MyScanningTooltip:NumLines() do
  10.       local left = _G["MyScanningTooltipTextLeft"..i]:GetText()
  11.       if left then
  12.          if isTransmogrified then
  13.             -- The line after the Transmog header has been found will be the name
  14.             -- might have to parse Illusion: Hidden
  15.             itemName = left
  16.             break -- return isTransmogrified, itemName
  17.          end
  18.          
  19.          if left == "Transmogrified to:" then -- Deal with localization - any better patterns to match?
  20.             isTransmogrified = true
  21.          end
  22.       end
  23.    end
  24.    return isTransmogrified, itemName
  25. end
  26.  
  27. transmogSlots = { InspectHeadSlot, InspectShoulderSlot, InspectBackSlot, InspectChestSlot, InspectWristSlot, InspectHandsSlot, InspectWaistSlot, InspectLegsSlot, InspectFeetSlot, InspectMainHandSlot, InspectSecondaryHandSlot }
  28.  
  29. -- Inspect the target manually before you try unless you've targetted yourself
  30. unit = "playertarget"
  31.  
  32.  
  33. for i, slot in ipairs(transmogSlots) do
  34.    slotId = slot:GetID()
  35.    
  36.    local isTransmogrified, itemName = ScanTooltipOfUnitSlotForTransmog(unit,slotId)
  37.    if isTransmogrified then
  38.       local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemName)
  39.       if link then
  40.          -- Can't call by itemName unless I have it in my bags... ugh!
  41.          print (format("Slot %s is transmogrified to %s.", slotId, link))
  42.       else
  43.          print (format("Slot %s is transmogrified to %s", slotId, itemName))
  44.       end
  45.    end
  46. end

Lombra 05-14-16 02:57 PM

Yes, you have to use tooltip scanning, which isn't going to be at all reliable. Can you even get item info via name if you don't have the item?

Hiketeia 05-14-16 02:58 PM

Quote:

Originally Posted by Lombra (Post 314778)
Yes, you have to use tooltip scanning, which isn't going to be at all reliable. Can you even get item info via name if you don't have the item?

Not that I can see :confused:

How responsive is the wow ui team for requesting new api calls? Maybe with all the wardrobe stuff happening for legion they'd give us one that could work? Best place for that would be on the official forums you think?

myrroddin 05-14-16 04:28 PM

Never messed with the inspection API, but shouldn't you be registering for INSPECT_READY()? Inspections are throttled at the server end, which might explain why you get it once, followed by nil values.

I'd even cache units and compare if you have them already before you call InspectUnit().

TOM_RUS 05-14-16 05:20 PM

In legion you can use C_TransmogCollection.GetInspectSources that returns some values (i've no idea if those are transmogged values or base). It seems that blizz is planning to use that API, but currently that part isn't finished. Those values than can be passed to C_TransmogCollection.GetAppearanceSourceInfo. You may try and see what you can get out of it.

Hiketeia 05-14-16 05:44 PM

myrroddin, thanks for the suggestion on INSPECT_READY. I was going to do that in the full code, just trying to do a proof of concept now. The nil was on the item call, it had the correct name already. The goal is to try into the inspection frame and trigger off its load.

TOM_RUS, good to know there is some stuff already available in Legion even if it is unclear the extent. I don't have beta access yet myself. I tried googling around for those api calls you mention and didn't turn anything up. Where did you find them? Is there a wiki, or github someplace that has the legion interface source posted?

TOM_RUS 05-14-16 06:04 PM

Quote:

Originally Posted by Hiketeia (Post 314791)
Where did you find them? Is there a wiki, or github someplace that has the legion interface source posted?

Yes Blizzard_InspectUI here: https://github.com/tomrus88/Blizzard....lua#L171-L184

At bottom there's dead code that never called. I think it was used in earlier builds, but not anymore... But API itself still returns "something".

Actually, that ViewButton was removed very recently.


All times are GMT -6. The time now is 11:27 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI