/
core.lua
executable file
·230 lines (200 loc) · 8.3 KB
/
core.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
---------------------------------------------
-- rTooltip
---------------------------------------------
-- A simple tooltip mod
-- Galaxy - 2016
---------------------------------------------
local addon, ns = ...
local cfg = ns.cfg
if not cfg.embeds.rTooltip then return end
cfg.rtooltip.backdrop = { bgFile = (mediapath.."Tooltip_Background"), edgeFile = (mediapath.."Tooltip_Border"), tiled = false, edgeSize = 10, insets = {left=8, right=8, top=8, bottom=8} }
---------------------------------------------
-- VARIABLES
---------------------------------------------
local unpack, type = unpack, type
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
local FACTION_BAR_COLORS = FACTION_BAR_COLORS
local WorldFrame = WorldFrame
local GameTooltip = GameTooltip
local GameTooltipStatusBar = GameTooltipStatusBar
---------------------------------------------
-- FUNCTIONS
---------------------------------------------
--change some text sizes
GameTooltipHeaderText:SetFont(cfg.font, 14, "THINOUTLINE")
GameTooltipText:SetFont(cfg.font, 12, "THINOUTLINE")
Tooltip_Small:SetFont(cfg.font, 11, "THINOUTLINE")
--gametooltip statusbar
GameTooltipStatusBar:ClearAllPoints()
GameTooltipStatusBar:SetPoint("LEFT",5,0)
GameTooltipStatusBar:SetPoint("RIGHT",-5,0)
GameTooltipStatusBar:SetPoint("BOTTOM",GameTooltipStatusBar:GetParent(),"TOP",0,-6)
GameTooltipStatusBar:SetHeight(3)
--gametooltip statusbar bg
GameTooltipStatusBar.bg = GameTooltipStatusBar:CreateTexture(nil,"BACKGROUND",nil,-8)
GameTooltipStatusBar.bg:SetPoint("TOPLEFT",-1,1)
GameTooltipStatusBar.bg:SetPoint("BOTTOMRIGHT",1,-1)
GameTooltipStatusBar.bg:SetTexture(0,0,0)
GameTooltipStatusBar.bg:SetVertexColor(0,0,0,0.7)
--HookScript GameTooltip OnTooltipCleared
GameTooltip:HookScript("OnTooltipCleared", function(self)
GameTooltip_ClearStatusBars(self)
--self:SetBackdropBorderColor(1,1,1,1)
end)
--hooksecurefunc GameTooltip_SetDefaultAnchor
hooksecurefunc("GameTooltip_SetDefaultAnchor", function(tooltip, parent)
if cfg.rtooltip.cursorfocus then
tooltip:SetOwner(parent, "ANCHOR_CURSOR")
else
tooltip:SetOwner(parent, "ANCHOR_NONE")
tooltip:ClearAllPoints()
tooltip:SetPoint(unpack(cfg.rtooltip.pos))
end
end)
--func AddSpellIdRow
local function AddSpellIdRow(tooltip,spellid)
tooltip:AddDoubleLine("|cff0099ffSpell ID|r",spellid)
tooltip:Show()
end
-- ArtifactPowerIDs
hooksecurefunc(GameTooltip, "SetArtifactPowerByID", function(self, id)
if id then
local spellid = C_ArtifactUI.GetPowerInfo(id)
if spellid then AddSpellIdRow(self,spellid) end
end
end)
--func AddBossDebuffRow
local function AddBossDebuffRow(tooltip,isBossDebuff)
tooltip:AddDoubleLine("|cff0099ffBossDebuff|r","Yes")
tooltip:Show()
end
--hooksecurefunc GameTooltip SetUnitBuff
hooksecurefunc(GameTooltip, "SetUnitBuff", function(self,...)
local spellid = select(10,UnitBuff(...))
if spellid then AddSpellIdRow(self,spellid) end
end)
--hooksecurefunc GameTooltip SetUnitDebuff
hooksecurefunc(GameTooltip, "SetUnitDebuff", function(self,...)
local spellid = select(10,UnitDebuff(...))
if spellid then AddSpellIdRow(self,spellid) end
local isBossDebuff = select(12,UnitDebuff(...))
if isBossDebuff then AddBossDebuffRow(self,isBossDebuff) end
end)
--hooksecurefunc GameTooltip SetUnitAura
hooksecurefunc(GameTooltip, "SetUnitAura", function(self,...)
local spellid = select(10,UnitAura(...))
if spellid then AddSpellIdRow(self,spellid) end
local isBossDebuff = select(12,UnitAura(...))
if isBossDebuff then AddBossDebuffRow(self,isBossDebuff) end
end)
--hooksecurefunc SetItemRef
hooksecurefunc("SetItemRef", function(link, text, button, chatFrame)
if string.find(link,"^spell:") then
local spellid = string.sub(link,7)
AddSpellIdRow(ItemRefTooltip,spellid)
end
end)
GameTooltip:HookScript("OnShow", function(self)
local spellid = select(2,TooltipUtil.GetDisplayedSpell(self))
if spellid then
AddSpellIdRow(self,spellid)
end
end)
--func GetHexColor
local function GetHexColor(color)
return ("%.2x%.2x%.2x"):format(color.r*255, color.g*255, color.b*255)
end
local classColors, reactionColors = {}, {}
for class, color in pairs(RAID_CLASS_COLORS) do
classColors[class] = GetHexColor(RAID_CLASS_COLORS[class])
end
for i = 1, #FACTION_BAR_COLORS do
reactionColors[i] = GetHexColor(FACTION_BAR_COLORS[i])
end
local function GetTarget(unit)
if UnitIsUnit(unit, "player") then
return ("|cffff0000%s|r"):format("<YOU>")
elseif UnitIsPlayer(unit, "player")then
return ("|cff%s%s|r"):format(classColors[select(2, UnitClass(unit))], UnitName(unit))
elseif UnitReaction(unit, "player") then
return ("|cff%s%s|r"):format(reactionColors[UnitReaction(unit, "player")], UnitName(unit))
else
return ("|cffffffff%s|r"):format(UnitName(unit))
end
end
--HookScript GameTooltip OnTooltipSetUnit
GameTooltip:HookScript("OnShow", function(self,...)
local unit = select(1, TooltipUtil.GetDisplayedUnit(self)) or (GetMouseFocus() and GetMouseFocus():GetAttribute("unit")) or (UnitExists("mouseover") and "mouseover")
if not unit or (unit and type(unit) ~= "string") then return end
if not UnitGUID(unit) then return end
local ricon = GetRaidTargetIndex(unit)
if ricon then
local text = GameTooltipTextLeft1:GetText()
GameTooltipTextLeft1:SetText(("%s %s"):format(ICON_LIST[ricon].."14|t", text))
end
for i = 2, GameTooltip:NumLines() do
local line = _G["GameTooltipTextLeft"..i]
if line then
line:SetTextColor(0.5,0.5,0.5)
end
end
if UnitIsPlayer(unit) then
local _, unitClass = UnitClass(unit)
local color = RAID_CLASS_COLORS[unitClass]
GameTooltipStatusBar:SetStatusBarColor(color.r,color.g,color.b)
GameTooltipTextLeft1:SetTextColor(color.r,color.g,color.b)
if UnitIsAFK(unit) then
self:AppendText(" |cff00cccc<AFK>|r")
elseif UnitIsDND(unit) then
self:AppendText(" |cffcc0000<DND>|r")
end
local unitGuild = GetGuildInfo(unit)
local text = GameTooltipTextLeft2:GetText()
if unitGuild and text and text:find("^"..unitGuild) then
GameTooltipTextLeft2:SetText("<"..text..">")
GameTooltipTextLeft2:SetTextColor(255/255, 20/255, 200/255)
end
else
local reaction = UnitReaction(unit, "player")
if reaction then
local color = FACTION_BAR_COLORS[reaction]
if color then
GameTooltipStatusBar:SetStatusBarColor(color.r,color.g,color.b)
GameTooltipTextLeft1:SetTextColor(color.r,color.g,color.b)
end
end
local unitClassification = UnitClassification(unit)
if unitClassification == "worldboss" or UnitLevel(unit) == -1 then
if UnitReaction(unit, "player") == 2 then
--highlight bosses
GameTooltipTextLeft1:SetTextColor(1,0.1,0)
end
self:AppendText(" |TInterface\\TargetingFrame\\UI-TargetingFrame-Skull:14:14|t")
elseif unitClassification == "rare" then
self:AppendText(" |TInterface\\AddOns\\Roth_UI\\media\\diablo:14:14:0:0:16:16:0:15:0:14|t")
elseif unitClassification == "rareelite" then
self:AppendText(" |TInterface\\AddOns\\Roth_UI\\media\\diablo:14:14:0:0:16:16:0:15:0:14|t")
elseif unitClassification == "elite" then
self:AppendText(" |TInterface\\AddOns\\Roth_UI\\media\\plus:14:14|t")
end
end
if UnitIsGhost(unit) then
self:AppendText(" |cffaaaaaa<GHOST>|r")
GameTooltipTextLeft1:SetTextColor(0.5,0.5,0.5)
elseif UnitIsDead(unit) then
self:AppendText(" |cffaaaaaa<DEAD>|r")
GameTooltipTextLeft1:SetTextColor(0.5,0.5,0.5)
end
if (UnitExists(unit.."target")) then
GameTooltip:AddDoubleLine("|cffff9999Target|r",GetTarget(unit.."target") or "Unknown")
--GameTooltip:Show()
end
end)
--loop over menues
local menues = {
DropDownList1MenuBackdrop,
DropDownList2MenuBackdrop,
}
for idx, menu in ipairs(menues) do
menu:SetScale(cfg.rtooltip.scale)
end