-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTooltips.lua
181 lines (159 loc) · 6.68 KB
/
Tooltips.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
local name, addon = ...;
local function RGBPercToHex(r, g, b)
r = r <= 1 and r >= 0 and r or 0
g = g <= 1 and g >= 0 and g or 0
b = b <= 1 and b >= 0 and b or 0
return string.format("%02x%02x%02x", r * 255, g * 255, b * 255)
end
local statLabelMap = {
[CR_MASTERY] = function()
local primaryTalentTree = GetSpecialization();
if (primaryTalentTree) then
local masterySpell = GetSpecializationMasterySpells(primaryTalentTree);
if (masterySpell) then
local name = C_Spell.GetSpellName(masterySpell);
return format(name, STAT_MASTERY);
end
end
return nil;
end,
[CR_CRIT_SPELL] = function()
return format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_CRITICAL_STRIKE)
end,
[CR_VERSATILITY_DAMAGE_DONE] = function()
return format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_VERSATILITY)
end,
[CR_HASTE_SPELL] = function()
return format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_HASTE)
end,
[CR_LIFESTEAL] = function()
return format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_LIFESTEAL)
end,
[CR_AVOIDANCE] = function()
return format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_AVOIDANCE)
end,
[CR_SPEED] = function()
return format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_SPEED)
end,
}
local statEventMap = {
[CR_MASTERY] = "OnTooltipSetSpell",
[CR_CRIT_SPELL] = "OnShow",
[CR_VERSATILITY_DAMAGE_DONE] = "OnShow",
[CR_HASTE_SPELL] = "OnShow",
[CR_LIFESTEAL] = "OnShow",
[CR_AVOIDANCE] = "OnShow",
[CR_SPEED] = "OnShow",
}
local patterns = {
[CR_MASTERY] = "%s([,0-9]+) " .. STAT_MASTERY,
[CR_CRIT_SPELL] = "%s([,0-9]+) " .. STAT_CRITICAL_STRIKE,
[CR_VERSATILITY_DAMAGE_DONE] = "%s([,0-9]+) " .. STAT_VERSATILITY,
[CR_HASTE_SPELL] = "%s([,0-9]+) " .. STAT_HASTE,
[CR_LIFESTEAL] = "%s([,0-9]+) " .. STAT_LIFESTEAL,
[CR_AVOIDANCE] = "%s([,0-9]+) " .. STAT_AVOIDANCE,
[CR_SPEED] = "%s([,0-9]+) " .. STAT_SPEED,
}
function addon.tsv:OnTooltip(ev, tooltip, ...)
if (addon.tsv.db.global.showStatTooltips) then
local tt1 = GameTooltipTextLeft1;
if (tt1) then
local text = tt1:GetText();
if (text) then
for statId, labelGenerator in pairs(statLabelMap) do
if (statEventMap[statId] == ev) then
local label = labelGenerator();
if (label) then
label = label:gsub("%-", "%%-")
local s, e = text:find(label)
if (s and s <= 11) then
self:AddTrueStatValuesTooltip(tooltip, statId);
end
end
end
end
end
end
end
if (addon.tsv.db.global.showItemTooltips and ev == "OnTooltipSetItem") then
local name, link = tooltip:GetItem();
if (name ~= nil and link ~= nil) then
local isEquipped = IsEquippedItem(name);
local itemString = select(3, string.find(link, "|H(.+)|h"));
-- print(GetItemInfo(link));
for i = 1, 20, 1 do
local textleft = "GameTooltipTextLeft" .. tostring(i);
if (_G[textleft] and _G[textleft].GetText) then
local text = _G[textleft]:GetText();
if (text and text ~= "") then
for statId, pattern in pairs(patterns) do
local amount = string.match(text, pattern);
if (amount) then
local s, e = string.find(text, pattern);
local trueAmount = self:GetTrueStatRatingAdded(statId, amount);
local r, g, b = addon.tsv.db.global.fontColor.r, addon.tsv.db.global.fontColor.g,
addon.tsv.db.global.fontColor.b;
local hexStr = RGBPercToHex(r, g, b);
local trueText = text:sub(1, e) .. " |cff" .. hexStr .. "(" .. tostring(trueAmount) ..
")|r" .. text:sub(e + 1);
_G[textleft]:SetText(trueText);
end
end
end
end
end
end
_G["FRM"] = tooltip;
end
end
function addon.tsv:AddTrueStatValuesTooltip(tooltip, statId)
local statInfo = addon.TrueStatInfo[statId];
local pctLabel = (statInfo.bracketPenalty > 0) and ("-" .. tostring(statInfo.bracketPenalty * 100) .. "%") or ("0%");
local barLabel =
tostring(statInfo.bracketRating) .. "/" .. tostring(statInfo.bracketMaxRating) .. " [" .. pctLabel ..
" penalty]";
local r, g, b = addon.tsv.db.global.fontColor.r, addon.tsv.db.global.fontColor.g, addon.tsv.db.global.fontColor.b;
-- barLabel = "|cff0000ff"..barLabel.."|r";
local lostRating = (statInfo.baseRating - statInfo.trueRating);
lostRating = math.floor(0.005 + 100 * lostRating) / 100;
tooltip:AddDoubleLine("True Rating:", statInfo.trueRating, r, g, b, r, g, b);
tooltip:AddDoubleLine("Lost Rating:", lostRating, r, g, b, r, g, b);
GameTooltip_ShowProgressBar(tooltip, 0, statInfo.bracketMaxRating, statInfo.bracketRating, barLabel);
local frames = tooltip.insertedFrames;
local frames_n = #frames;
local insertedFrame = frames[frames_n];
if (insertedFrame and insertedFrame.Bar) then
insertedFrame.Bar:SetStatusBarColor(r, g, b, 1);
end
tooltip:AddLine("\n");
tooltip:Show();
end
--[[
hooksecurefunc('PaperDollFrame_UpdateStats', function()
if IsAddOnLoaded('DejaCharacterStats') then return end
for _, Table in ipairs({_G.CharacterStatsPane.statsFramePool:EnumerateActive()}) do
if type(Table) == 'table' then
for statFrame in pairs(Table) do
ColorizeStatPane(statFrame)
if statFrame.Background:IsShown() then
statFrame.leftGrad:Show()
statFrame.rightGrad:Show()
else
statFrame.leftGrad:Hide()
statFrame.rightGrad:Hide()
end
end
end
end
end)
function PaperDollFrame_SetLabelAndText(statFrame, label, text, isPercentage, numericValue)
if ( statFrame.Label ) then
statFrame.Label:SetText(format(STAT_FORMAT, label));
end
if ( isPercentage ) then
text = format("%d%%", numericValue + 0.5);
end
statFrame.Value:SetText(text);
statFrame.numericValue = numericValue;
end
]]