Quantcast
C_CurrencyInfo.GetCurrencyInfo - WoWInterface
Thread Tools Display Modes
12-05-20, 03:18 PM   #1
Tim
A Frostmaul Preserver
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 292
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?
  Reply With Quote
12-05-20, 03:38 PM   #2
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 402
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
  Reply With Quote
12-05-20, 03:50 PM   #3
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 550
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

Last edited by Kanegasi : 12-05-20 at 03:53 PM.
  Reply With Quote
12-05-20, 04:02 PM   #4
Tim
A Frostmaul Preserver
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 292
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » C_CurrencyInfo.GetCurrencyInfo

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off