Skip to content

Commit 10b86f5

Browse files
committed
Fix keystone tooltips being broken on beta
1 parent b9c585c commit 10b86f5

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

modules/showScoreOnKeystoneTooltip.lua

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,26 @@ local Util = MPT.Util;
66

77
local 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+
916
function 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
1225
end
1326

1427
function Module:OnDisable()
28+
self.enabled = false
1529
self:UnhookAll();
1630
end
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;
3853
end
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+
4067
function 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

Comments
 (0)