forked from Hyperioxes/AlchemyTooltips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TooltipHooks.lua
94 lines (65 loc) · 2.83 KB
/
TooltipHooks.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
local function ReturnItemLink(itemLink)
return itemLink
end
local function TooltipHook(tooltipControl, method, linkFunc)
local origMethod = tooltipControl[method]
tooltipControl[method] = function(self, ...)
local link = linkFunc(...)
local quality,icon
if GetItemLinkItemType(link) == 30 or GetItemLinkItemType(link) == 7 then
_,quality,icon = ATT_Functions:processItemLink(link)
else
quality,icon = 0,0
end
local orgText = GetString(SI_TOOLTIP_ITEM_NAME)
if quality ~= 0 then
local color = GetItemQualityColor(quality)
SafeAddString(SI_TOOLTIP_ITEM_NAME, color:Colorize(GetString(SI_TOOLTIP_ITEM_NAME)), 1)
end
origMethod(self, ...)
SafeAddString(SI_TOOLTIP_ITEM_NAME, orgText, 1)
if icon ~= 0 then
ZO_ItemIconTooltip_OnAddGameData(tooltipControl, TOOLTIP_GAME_DATA_ITEM_ICON , icon)
end
ATT_Functions:AddPotionInfo(self, ATT_Functions:checkPotion(link))
end
end
local function TooltipHook_Gamepad(tooltipControl, method, linkFunc)
local origMethod = tooltipControl[method]
tooltipControl[method] = function(self, ...)
local result = origMethod(self, ...)
local link = linkFunc(...)
local quality,icon
if GetItemLinkItemType(link) == 30 or GetItemLinkItemType(link) == 7 then
_,quality,icon = ATT_Functions:processItemLink(link)
else
quality,icon = 0,0
end
local orgText = GetString(SI_TOOLTIP_ITEM_NAME)
if quality ~= 0 then
local color = GetItemQualityColor(quality)
SafeAddString(SI_TOOLTIP_ITEM_NAME, color:Colorize(GetString(SI_TOOLTIP_ITEM_NAME)), 1)
end
SafeAddString(SI_TOOLTIP_ITEM_NAME, orgText, 1)
if icon ~= 0 then
ZO_ItemIconTooltip_OnAddGameData(tooltipControl, TOOLTIP_GAME_DATA_ITEM_ICON , icon)
end
ATT_Functions:AddPotionInfo(self, ATT_Functions:checkPotion(link))
return result
end
end
function ATT_HookBagTips()
TooltipHook(ItemTooltip, "SetBagItem", GetItemLink)
TooltipHook(ItemTooltip, "SetTradeItem", GetTradeItemLink)
TooltipHook(ItemTooltip, "SetBuybackItem", GetBuybackItemLink)
TooltipHook(ItemTooltip, "SetStoreItem", GetStoreItemLink)
TooltipHook(ItemTooltip, "SetAttachedMailItem", GetAttachedItemLink)
TooltipHook(ItemTooltip, "SetLootItem", GetLootItemLink)
TooltipHook(ItemTooltip, "SetTradingHouseItem", GetTradingHouseSearchResultItemLink)
TooltipHook(ItemTooltip, "SetTradingHouseListing", GetTradingHouseListingItemLink)
TooltipHook(ItemTooltip, "SetLink", ReturnItemLink)
TooltipHook(PopupTooltip, "SetLink", ReturnItemLink)
TooltipHook_Gamepad(GAMEPAD_TOOLTIPS:GetTooltip(GAMEPAD_LEFT_TOOLTIP), "LayoutItem", ReturnItemLink)
TooltipHook_Gamepad(GAMEPAD_TOOLTIPS:GetTooltip(GAMEPAD_RIGHT_TOOLTIP), "LayoutItem", ReturnItemLink)
TooltipHook_Gamepad(GAMEPAD_TOOLTIPS:GetTooltip(GAMEPAD_MOVABLE_TOOLTIP), "LayoutItem", ReturnItemLink)
end