@@ -6,12 +6,26 @@ local Util = MPT.Util;
66
77local Module = Main :NewModule (' ShowScoreOnKeystoneTooltip' , ' AceHook-3.0' );
88
9+ function Module :OnInitialize ()
10+ if TooltipDataProcessor and TooltipDataProcessor .AddTooltipPostCall then
11+ hooksecurefunc (GameTooltip , ' SetHyperlink' , function (tooltip , hyperlink ) Module :OnSetHyperlink (tooltip , hyperlink ) end )
12+ hooksecurefunc (ItemRefTooltip , ' SetHyperlink' , function (tooltip , hyperlink ) Module :OnSetHyperlink (tooltip , hyperlink ) end )
13+ end
14+ end
15+
916function Module :OnEnable ()
10- self :SecureHookScript (GameTooltip , ' OnTooltipSetItem' , function (tooltip ) Module :OnTooltipShow (tooltip ); end );
11- self :SecureHookScript (ItemRefTooltip , ' OnTooltipSetItem' , function (tooltip ) Module :OnTooltipShow (tooltip ); end );
17+ self .enabled = true
18+ if TooltipDataProcessor and TooltipDataProcessor .AddTooltipPostCall then
19+ -- uncomment if they fix the issue that data.hyperlink is a generic keystone item link instead of the specific keystone link
20+ -- TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item,function(tooltip, data) Module:TooltipPostCall(tooltip, data) end)
21+ else
22+ self :SecureHookScript (GameTooltip , ' OnTooltipSetItem' , function (tooltip ) Module :OnTooltipShow (tooltip ); end );
23+ self :SecureHookScript (ItemRefTooltip , ' OnTooltipSetItem' , function (tooltip ) Module :OnTooltipShow (tooltip ); end );
24+ end
1225end
1326
1427function Module :OnDisable ()
28+ self .enabled = false
1529 self :UnhookAll ();
1630end
1731
@@ -30,17 +44,34 @@ function Module:GetOptions(defaultOptionsTable)
3044 desc = ' Open an example keystone tooltip.' ,
3145 func = function ()
3246 local link = string.format (' |cffa335ee|Hkeystone:180653:%d:16:10:1:2:3|h[Keystone]|h|r' , C_ChallengeMode .GetMapTable ()[1 ]);
47+ -- local link = string.format('|cFFA335EE|Hitem:180653::::::::60:252::::6:17:%d:18:16:19:10:20:1:21:2:22:3:::::|h[Mythic Keystone]|h|r', C_ChallengeMode.GetMapTable()[1]);
3348 SetItemRef (link , link , ' LeftButton' );
3449 end ,
3550 };
3651
3752 return defaultOptionsTable ;
3853end
3954
55+ function Module :OnSetHyperlink (tooltip , hyperlink )
56+ if not self .enabled then return ; end
57+ self :HandleHyperlink (tooltip , hyperlink );
58+ end
59+
60+ function Module :TooltipPostCall (tooltip , data )
61+ local itemLink = data .hyperlink ;
62+ if not itemLink then return ; end
63+
64+ self :HandleHyperlink (tooltip , itemLink );
65+ end
66+
4067function Module :OnTooltipShow (tooltip )
4168 local _ , itemLink = tooltip :GetItem ();
4269 if not itemLink then return end
4370
71+ self :HandleHyperlink (tooltip , itemLink );
72+ end
73+
74+ function Module :HandleHyperlink (tooltip , itemLink )
4475 local mapId = itemLink :match (' keystone:%d+:(%d+)' );
4576 if not mapId then
4677 local itemId = itemLink :match (' item:(%d+)' );
0 commit comments