1 local E
, L
= unpack(ElvUI
)
2 local GS
= E
:NewModule("ElvUI_GearScore", "AceHook-3.0")
3 local TT
= E
:GetModule("Tooltip")
5 local inspectCache
= {}
8 function GS
:ShowInspectInfo(self
, tt
, unit
, r
, g
, b
)
9 local canInspect
= CanInspect(unit
)
10 if not canInspect
then return end
12 local GUID
= UnitGUID(unit
)
13 if GUID
== E
.myguid
then
14 local _
, specName
= E
:GetTalentSpecInfo()
15 local gearScore
= GS
:GetGearScore("player")
16 local gsR
, gsG
, gsB
= GearScore_GetQuality(gearScore
)
18 tt
:AddDoubleLine(L
["Talent Specialization:"], specName
, nil, nil, nil, r
, g
, b
)
19 tt
:AddDoubleLine(L
["Gear Score:"], gearScore
, nil, nil, nil, gsR
, gsG
, gsB
);
21 elseif inspectCache
[GUID
] then
22 local specName
= inspectCache
[GUID
].specName
23 local gearScore
= inspectCache
[GUID
].gearScore
24 local gsR
, gsG
, gsB
= GearScore_GetQuality(gearScore
)
26 if (GetTime() - inspectCache
[GUID
].time
) < 900 and specName
and gearScore
then
27 tt
:AddDoubleLine(L
["Talent Specialization:"], specName
, nil, nil, nil, r
, g
, b
)
28 tt
:AddDoubleLine(L
["Gear Score:"], gearScore
, nil, nil, nil, gsR
, gsG
, gsB
);
31 inspectCache
[GUID
] = nil
35 if InspectFrame
and InspectFrame
.unit
then
36 if UnitIsUnit(InspectFrame
.unit
, unit
) then
38 GS
:INSPECT_TALENT_READY(nil, unit
)
43 TT
:RegisterEvent("INSPECT_TALENT_READY")
47 function GS
:INSPECT_TALENT_READY(self
, event
, unit
)
49 if lastGUID
~= UnitGUID("mouseover") then return end
51 TT
:UnregisterEvent(event
)
54 if not UnitExists(unit
) then return end
57 local gearScore
= GS
:GetGearScore(unit
)
58 local _
, specName
= E
:GetTalentSpecInfo(true)
59 inspectCache
[lastGUID
] = {time
= GetTime()}
62 inspectCache
[lastGUID
].specName
= specName
66 inspectCache
[lastGUID
].gearScore
= gearScore
69 GameTooltip
:SetUnit(unit
)
72 function GS
:GetGearScore(unit
)
73 return GearScore_GetScore(UnitName(unit
), unit
)
76 function GS
:Initialize()
77 GS
:RawHook(TT
, "ShowInspectInfo")
78 GS
:RawHook(TT
, "INSPECT_TALENT_READY")
81 E
:RegisterModule(GS
:GetName())