-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNWTooltipFix.lua
198 lines (163 loc) · 6.24 KB
/
NWTooltipFix.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
--[[
NWTooltipFix
by null
https://github.com/nullfoxh/NWTooltipFix
For use on Atlantiss, Netherwing.
Shows pre-2.3 Spell and item values on tooltips.
Remove this addon on patch 2.3!
]]--
local _G, pairs, tonumber, GetSpellLink, GetTradeSkillInfo, IsControlKeyDown
= _G, pairs, tonumber, GetSpellLink, GetTradeSkillInfo, IsControlKeyDown
local find = string.find
local gsub = string.gsub
local match = string.match
local format = string.format
local itemtips = {
GameTooltip,
ShoppingTooltip1,
ShoppingTooltip2,
ItemRefTooltip,
}
local ItemSubData = {
[29713] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Pattern: Drums of Panic (Keepers of Time)
[29714] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Pattern: Drums of Restoration
[29717] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Pattern: Drums of Battle (Sha'tar)
[29718] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Pattern: Drums of Speed
[34172] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Pattern: Drums of Speed (Mag'har)
[34173] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Pattern: Drums of Speed (Kurenai)
[34174] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Pattern: Drums of Restoration (Mag'har)
[34175] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Pattern: Drums of Restoration (Kurenai)
[29528] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Drums of War
[29529] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Drums of Battle
[29530] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Drums of Speed
[29531] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Drums of Restoration
[29532] = { { " Drums can be used while shapeshifted.", "\n|cffffffff1 sec cast|r" }, }, -- Drums of Panic
}
-- not yet needed, commented out for now
local SpellSubData = {
-- For instance: Persuasion by Lady Vashj
-- [38511] = { { "$s1.", "200" }, { "$s2.", "1000" }, },
}
-- We can't get IDs for auras, so we need to use aura name
local AuraSubData = {
-- Persuasion by Lady Vashj
["Persuasion"] = { { "$s1.", "200" }, { "$s2.", "1000" }, },
["Scalding Water"] = { { "500", "1000" }, { "3 sec.", "2 sec." }, },
}
local HealSubData = {
["Equip: Increases healing done by up to (%d+) and damage done"] = "Equip: Increases healing done by spells and effects by up to %s.",
["Use: Increases healing done by up to (%d+) and damage done"] = "Use: Increases healing done by spells and effects by up to %s.",
["+(%d+) Healing Spells and"] = "|cffffffff+%s Healing Spells|r",
}
local function ReplaceHealing(obj)
local text = obj:GetText()
for k, v in pairs(HealSubData) do
local healing = match(text, k)
if healing then
obj:SetText(format(v, healing))
end
end
end
local function ReplaceOther(obj, subdata)
local text = obj:GetText()
for k, v in pairs(subdata) do
local str, count = gsub(text, v[1], v[2])
if count > 0 then
obj:SetText(str)
end
end
end
local function OnTipSetSpell(tip, tipname)
if IsControlKeyDown() then return end
local subdata
local name, rank = tip:GetSpell()
local id = GetSpellLink(name, rank)
id = id and tonumber(id:match("spell:(%d+)"))
if id then
subdata = SpellSubData[id]
end
if subdata then
for i = 1, tip:NumLines() do
local obj = _G[format("%sTextLeft%s", tipname, i)]
if subdata then
ReplaceOther(obj, subdata)
end
end
end
end
local function OnTipSetAura(self, ...)
if IsControlKeyDown() then return end
local title = GameTooltipTextLeft1:GetText()
local subdata = AuraSubData[title]
if subdata then
for i = 1, GameTooltip:NumLines() do
local obj = _G[format("GameTooltipTextLeft%s", i)]
ReplaceOther(obj, subdata)
end
end
end
local function OnTipSetItem(tip, name)
if IsControlKeyDown() then return end
local subdata
local _, link = tip:GetItem()
if link then
local id = tonumber(match(link, ":(%w+)"))
subdata = ItemSubData[id]
end
for i = 1, tip:NumLines() do
local obj = _G[format("%sTextLeft%s", name, i)]
ReplaceHealing(obj)
if subdata then
ReplaceOther(obj, subdata)
end
end
end
local function OnSetItemRefTip(link)
if find(link, "^spell:")then
--OnTipSetSpell(ItemRefTooltip, "ItemRefTooltip")
else
OnTipSetItem(ItemRefTooltip, "ItemRefTooltip")
end
end
for i = 1, #itemtips do
local t = itemtips[i]
t:HookScript("OnTooltipSetItem", function(self) OnTipSetItem(self, self:GetName()) end)
end
--GameTooltip:SetScript("OnTooltipSetSpell", function(self) OnTipSetSpell(GameTooltip, "GameTooltip") end)
hooksecurefunc("SetItemRef", OnSetItemRefTip)
hooksecurefunc(GameTooltip, "SetUnitBuff", OnTipSetAura)
hooksecurefunc(GameTooltip, "SetUnitDebuff", OnTipSetAura)
hooksecurefunc(GameTooltip, "SetPlayerBuff", OnTipSetAura)
if AtlasLootTooltip then
if AtlasLootTooltip:GetScript("OnShow") then
AtlasLootTooltip:HookScript("OnShow", function(self) OnTipSetItem(self, self:GetName()) end)
else
AtlasLootTooltip:SetScript("OnShow", function(self) OnTipSetItem(self, self:GetName()) end)
end
end
-- Fix for cooking recipe 'Fisherman's Feast' (spellid 42302)
-- We hook GetTradeSkillNumMade to return correct yield for the recipe
-- this should ensure crafting addons work correctly as well.
local function HookTradeSkillFrame()
local GetTradeSkillNumMade_orig = GetTradeSkillNumMade
GetTradeSkillNumMade = function(...)
local skillName, skillType, numAvailable, isExpanded = GetTradeSkillInfo(...)
if skillName == "Fisherman's Feast" then
return 1, 1
else
return GetTradeSkillNumMade_orig(...)
end
end
end
local f = CreateFrame("Frame")
f:SetScript("OnEvent", function(self, event, addon, ...)
if addon == "Blizzard_TradeSkillUI" then
HookTradeSkillFrame()
self:UnregisterEvent("ADDON_LOADED")
end
end)
if TradeSkillFrame then
HookTradeSkillFrame()
else
f:RegisterEvent("ADDON_LOADED")
end