Thread Tools Display Modes
01-24-15, 11:10 AM   #1
Miiru
A Flamescale Wyrmkin
 
Miiru's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 138
List of functions a function calls

Is it possible to get a list of functions a function calls? Or to output them ingame?

I am looking at this function: http://wowprogramming.com/docs/api/UseToy

They seem to have changed something on ptr and it would probably be helpful for me to know which functions it calls. Didnt find anything related in blizzard_collections addons.

Thanks
__________________
◘◘ Author of MiirGui Texture Pack - [Core] [Blue] [Grey] ◘◘

Last edited by Miiru : 01-24-15 at 11:42 AM.
  Reply With Quote
01-24-15, 11:14 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I'm not really sure what you're asking. "UseToy" is a game API function -- if it calls any other functions, they are on the C backend, out of sight of anything in Lua.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-24-15, 11:39 AM   #3
Miiru
A Flamescale Wyrmkin
 
Miiru's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 138
I got the function ToySpellButton_UpdateButton(self) hooked to change the layout of the ToyBox-Frame which works without any problems on live realms.

Now on ptr it works (besides little changes to not cause taint) untill the point someone uses a toy. Then it reverts back any changes i did to the fontstrings.

As i cannot find any other functions which could be the cause of this error, i wanted to know what exactly UseToy does besides actually using the toy (you know setting cooldowns, greying out items whatever).

So you say that is impossible?
__________________
◘◘ Author of MiirGui Texture Pack - [Core] [Blue] [Grey] ◘◘
  Reply With Quote
01-24-15, 01:28 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
It might not be anything that UseToy() does, but something after the UI calls that function.

The toy box UI might be doing something like this:

Lua Code:
  1. function ToyButton12:OnClick()
  2.      UseToy()
  3.      --do some other stuff to update the UI
  4. end

/edit: or maybe some sort of callback or event that happens that tells the UI to refresh
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh


Last edited by Seerah : 01-24-15 at 01:31 PM.
  Reply With Quote
01-24-15, 01:47 PM   #5
Miiru
A Flamescale Wyrmkin
 
Miiru's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 138
Originally Posted by Seerah View Post

Lua Code:
  1. function ToyButton12:OnClick()
  2.      UseToy()
  3.      --do some other stuff to update the UI
  4. end
This is the onclick:

Lua Code:
  1. function ToySpellButton_OnClick(self, button)
  2.     if ( button ~= "LeftButton" ) then
  3.         if (PlayerHasToy(self.itemID)) then
  4.             ToyBox_ShowToyDropdown(self.itemID, self, 0, 0);
  5.         end
  6.     else
  7.         UseToy(self.itemID);
  8.     end
  9. end
Doesn't look like it does something there.


/edit: or maybe some sort of callback or event that happens that tells the UI to refresh
But shouldnt it trigger the hooked function then? Why does it only change the font-string when the hook also changes borders etc :/
__________________
◘◘ Author of MiirGui Texture Pack - [Core] [Blue] [Grey] ◘◘
  Reply With Quote
01-24-15, 02:32 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I don't know. But if you show your code we'll have more to go on.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
01-24-15, 02:46 PM   #7
Miiru
A Flamescale Wyrmkin
 
Miiru's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 138
This is the current ptr Toybox.lua file:

http://pastebin.com/08n4FSEe

This is my hook:

Lua Code:
  1. -- Captain Hook's Hooks
  2.  
  3.    
  4.     local function miirgui_ToySpellButton_UpdateButton(self)
  5.         local itemIndex = (ToyBox_GetCurrentPage() - 1) * 18 + self:GetID();
  6.         local toyString = self.name;
  7.         local itemID, toyName, icon = C_ToyBox.GetToyInfo(self.itemID);
  8.         local slotFrameCollected = self.slotFrameCollected;
  9.         local slotFrameUncollected = self.slotFrameUncollected;
  10.         if (PlayerHasToy(self.itemID)) then
  11.             toyString:SetTextColor(1,1,1,1);
  12.             toyString:SetShadowColor(0, 0, 0, 1);
  13.             toyString:SetFont(unpack(miirgui.small))
  14.             slotFrameCollected:Show()
  15.             slotFrameCollected:SetTexture("Interface\\Buttons\\UI-Quickslot")
  16.             slotFrameCollected:SetHeight(74)
  17.             slotFrameCollected:SetWidth(74)
  18.         else
  19.             toyString:SetTextColor(0.5, 0.5, 0.5, 1);
  20.             toyString:SetFont(unpack(miirgui.small))
  21.             toyString:SetShadowColor(0, 0, 0, 0);
  22.             slotFrameUncollected:SetDesaturated(true)
  23.             slotFrameUncollected:SetTexture("Interface\\Buttons\\UI-Quickslot")
  24.             slotFrameUncollected:SetHeight(74)
  25.             slotFrameUncollected:SetWidth(74)
  26.             slotFrameUncollected:Show();
  27.         end
  28.             CollectionsSpellButton_UpdateCooldown(self);
  29.     end
  30.    
  31.             hooksecurefunc("ToySpellButton_UpdateButton",miirgui_ToySpellButton_UpdateButton)

I had to change the code slightly to avoid taint.

The hook works fine and does what it should, the only weird thing is that the font color (it's only the color, not even the flags) is changed when a toy is used (regardless if clicked or with /usetoy xx).
__________________
◘◘ Author of MiirGui Texture Pack - [Core] [Blue] [Grey] ◘◘
  Reply With Quote
01-25-15, 04:21 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, I would imagine using a toy triggers an event, so the UI knows to update stuff like the cooldown spiral.

The ToyBox registers for the "TOYS_UPDATED" event:
http://www.townlong-yak.com/framexml..._ToyBox.lua#14

and when that event fires:
http://www.townlong-yak.com/framexml..._ToyBox.lua#17

one of the functions it calls is "ToyBox_UpdateButtons":
http://www.townlong-yak.com/framexml...ToyBox.lua#246

which loops over all the buttons and calls "ToySpellButton_UpdateButton" on each of them:
http://www.townlong-yak.com/framexml...ToyBox.lua#159

and that function does indeed set the color of some text:
http://www.townlong-yak.com/framexml...ToyBox.lua#213
http://www.townlong-yak.com/framexml...ToyBox.lua#230

and since you are post-hooking that function, your changes shouldn't be overridden.

The only thing I notice is that you're duplicating a lot of code unnecessarily. The original function already shows/hides the collected/uncollected textures as necessary and updates the cooldown, so you should not do those things again in your hook. Your code should only include the parts that are different.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-25-15, 06:32 AM   #9
Miiru
A Flamescale Wyrmkin
 
Miiru's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 138
Thank you very much Phanx. I was also under the impression that the code should not be overwritten. I am gonna wait for a few patches and see if they are doing anything related to the toy box.

I am gonna work on that unnecessary code stuff
__________________
◘◘ Author of MiirGui Texture Pack - [Core] [Blue] [Grey] ◘◘
  Reply With Quote
02-05-15, 02:10 PM   #10
Miiru
A Flamescale Wyrmkin
 
Miiru's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 138
It even gets weirder now. When i have the toy window open and i cast a cast, it will also revert the colors back.

I am gonna upload a seperate version of only the color changes for that window and see if it behaves like that for everybody :/

Here it is: http://boujong.net/toybox.zip

This only changes the font-string color of the toybox on ptr. When a spell is cast or a toy is 'used' it reverty the changes back. :S
__________________
◘◘ Author of MiirGui Texture Pack - [Core] [Blue] [Grey] ◘◘

Last edited by Miiru : 02-05-15 at 02:25 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » List of functions a function calls


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