Quantcast
WoWInterface - View Single Post - SetCurrencyByID, SetCurrencyToken and SetCurrencyTokenByID not firing?
View Single Post
04-09-20, 08:20 AM   #1
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 121
SetCurrencyByID, SetCurrencyToken and SetCurrencyTokenByID not firing?

So I'm having this bizarre issue where SetCurrencyByID, SetCurrencyToken and SetCurrencyTokenByID are not firing at all when hovering over a token cost in token vendors. Such as War Resources or Honor Tokens and such.

I've tried several methods to figure out why they aren't firing and can only assume another hidden function is being used for GameTooltip. I know it has to do with AltCurrency but can't seem to figure out how to grab the CurrencyID or token being fired for the GameTooltip. Some of these token currencies are pushed to AltCurrencyFrame_Update. Yet not matter what I do or what I hook, I cannot get the token currency to fire for GameTooltip.

Does anyone have any ideas?

I've tried the following.

Code:
		hooksecurefunc(GameTooltip, "SetCurrencyToken", function(self, index)
		print('SetCurrencyToken', self, index)

		end)
		hooksecurefunc(GameTooltip, "SetCurrencyTokenByID", function(self, currencyID)
		print('SetCurrencyToken', self, currencyID)

		end)
		hooksecurefunc(GameTooltip, "SetCurrencyByID", function(self, currencyID)
                print('SetCurrencyByID', self, currencyID)

		end)
None of the above works when you hover over a token under a token vendor. Like I said the only thing I can assume is that it's not GameTooltip being used or the Currency is being set by a hidden function. That or it's being passed somehow differently.

The ONLY thing that seems to work is to hook into the token frames themselves under the merchant frame.


Code:
		hooksecurefunc("MerchantFrame_UpdateAltCurrency", function(index, indexOnPage, canAfford)
			local itemCount = GetMerchantItemCostInfo(index)
			local frameName = "MerchantItem"..indexOnPage.."AltCurrencyFrame"
			local usedCurrencies = 0

			-- update Alt Currency Frame with itemValues
			if ( itemCount > 0 ) then
				for i=1, MAX_ITEM_COST do
					local itemTexture, itemValue, itemLink = GetMerchantItemCostItem(index, i)
					if ( itemTexture ) then
						usedCurrencies = usedCurrencies + 1
						if not _G[frameName.."Item"..usedCurrencies].isHooked then
							_G[frameName.."Item"..usedCurrencies]:HookScript("OnEnter", function() 
                                                           print('currency', itemLink)
							end)
							_G[frameName.."Item"..usedCurrencies].isHooked = true
						end
					end
				end
			end
			
		end)
this code also works, pretty much the same as above but going directly to AltCurrency

Code:
		local oldAltCurrencyFrame_Update = AltCurrencyFrame_Update
		AltCurrencyFrame_Update = function(frameName, texture, cost, canAfford)
			if _G[frameName] and _G[frameName].itemLink then
				if not _G[frameName].isHooked then
					_G[frameName]:HookScript("OnEnter", function() 
                                              print(_G[frameName].itemLink)
					end)
					_G[frameName].isHooked = true
				end
				print(frameName, texture, cost, canAfford, _G[frameName].itemLink)
			end
			oldAltCurrencyFrame_Update(frameName, texture, cost, canAfford)
		end
Does anyone have any idea of what's going on?
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }

Last edited by Xruptor : 04-09-20 at 08:47 AM.
  Reply With Quote