WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Edit text of existing in-game frame (https://www.wowinterface.com/forums/showthread.php?t=59144)

Shargul 06-07-22 01:00 PM

Edit text of existing in-game frame
 
Hey all. I'm sort of a wow add-on noob so apologies if this is a trivial question.

I recently began creating my first add-on which calculates the probability of a skill-up when crafting certain trade-skill items, based on the following formula from the wiki. I've managed to implement it almost fully now, by gathering up all the percentage chances for the players crafts, as seen here:

https://imgur.com/a/At9rOOy

Now all I want to do is display these percentages beside each craftable item in the players TradeSkill frame, rather than just printing it out in chat like I have been doing thus far.

To help understand, I made a quick image edit of what I mean:

This
https://imgur.com/a/M8rNCQi

Rather than this:
https://imgur.com/a/CLlTv8T

Would anyone be able to give me some pointers on how to achieve this? I initially tried using the frame stack to access the child frames belonging to each consecutive item, but using functions like frame:SetText() and the like proved futile.

Any help with this would be greatly appreciated.

Fizzlemizz 06-07-22 06:32 PM

This in an addon that loads with the Blizzard_TradeSkillUI will add the recipe ID to the text.

You can use that (or whatever you need) to do your calculation and add that text instead. The Count ([nnn]) at the end of the text is a separate fontstring. There's only so much space so the recipe text can be truncated for long recipe titles.

Lua Code:
  1. local function AddRecipeInfo(self, textWidth, tradeSkillInfo)
  2.     if not self.isHeader then
  3.         self.Text:SetText(self.Text:GetText().."-(|cff00ff00ID:|r |cffffff00"..self.tradeSkillInfo.recipeID..")|r ")
  4.     end
  5. end
  6. for k, v in pairs(TradeSkillFrame.RecipeList.buttons) do
  7.     hooksecurefunc(v, "SetUpRecipe", AddRecipeInfo)
  8. end
Hooks the SetUpRecipe function of each row button in the recipes list to call the AddRecipeInfo function after it's finished.


All times are GMT -6. The time now is 09:55 PM.

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