WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   C_CurrencyInfo.GetCurrencyInfo (https://www.wowinterface.com/forums/showthread.php?t=58436)

Tim 12-05-20 03:18 PM

C_CurrencyInfo.GetCurrencyInfo
 
Blizzard removed the texture path argument from GetCurrencyInfo() when they changed it over to C_CurrencyInfo.GetCurrencyInfo(). I'm trying to create fontstrings for currencies and can't find a way to get the filePath from textureID/FileID for anything. Any suggestions?

Vrul 12-05-20 03:38 PM

I think you can use the id number in place of an actual path based on Blizzard's code:
Lua Code:
  1. function CreateTextureMarkup(file, fileWidth, fileHeight, width, height, left, right, top, bottom, xOffset, yOffset)
  2.     return ("|T%s:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d|t"):format(
  3.           file
  4.         , height
  5.         , width
  6.         , xOffset or 0
  7.         , yOffset or 0
  8.         , fileWidth
  9.         , fileHeight
  10.         , left * fileWidth
  11.         , right * fileWidth
  12.         , top * fileHeight
  13.         , bottom * fileHeight
  14.     );
  15. end
  16.  
  17. function GetCurrencyString(currencyID, overrideAmount, colorCode, abbreviate)
  18.     colorCode = colorCode or HIGHLIGHT_FONT_COLOR_CODE;
  19.  
  20.     local currencyInfo = C_CurrencyInfo.GetCurrencyInfo(currencyID);
  21.     if currencyInfo then
  22.         local currencyTexture = currencyInfo.iconFileID;
  23.         local markup = CreateTextureMarkup(currencyTexture, 64, 64, 16, 16, 0, 1, 0, 1);
  24.         local amountString;
  25.         if abbreviate then
  26.             amountString = AbbreviateNumbers(overrideAmount or currencyInfo.quantity);
  27.         else
  28.             amountString = BreakUpLargeNumbers(overrideAmount or currencyInfo.quantity);
  29.         end
  30.         return ("%s%s %s|r"):format(colorCode, amountString, markup);
  31.     end
  32.  
  33.     return "";
  34. end

Kanegasi 12-05-20 03:50 PM

It was not removed, it was converted to a fileID instead back in I believe Legion. Then, Shadowlands converted the function to return a table. The fileID is under the key "iconFileID".

https://wow.gamepedia.com/API_C_Curr...etCurrencyInfo

The following code will print "You have ## of Soul Ash" in chat with the Soul Ash icon right before the name.

Lua Code:
  1. local data = C_CurrencyInfo.GetCurrencyInfo(1828)
  2.  
  3. if data.name and tonumber(data.quantity) then
  4.     local color = data.quality and ITEM_QUALITY_COLORS[data.quality].hex or ""
  5.     local message = "You have " .. data.quantity .. " of " .. (data.iconFileID and "|T"..data.iconFileID..":12|t" or "") .. color .. data.name .. "|r"
  6.     DEFAULT_CHAT_FRAME:AddMessage(message)
  7. end

Tim 12-05-20 04:02 PM

Thanks for the help.

@Kanegasi; Yeah I know they swapped over to ID, perhaps removed was the wrong word but you knew what I meant. I didn't even try to put the FileID in the fontstring, now I feel like an idiot, lol.


All times are GMT -6. The time now is 12:17 PM.

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