1 QuestHelper_File
["tooltip.lua"] = "Development Version"
2 QuestHelper_Loadtime
["tooltip.lua"] = GetTime()
4 local function DoTooltip(self
, tooltipi
)
6 for data
, lines
in pairs(tooltipi
) do
10 --QuestHelper:TextOut(QuestHelper:StringizeTable(data))
11 --QuestHelper:TextOut(QuestHelper:StringizeTable(lines))
12 for _
, v
in ipairs(lines
) do
13 self
:AddLine((" "):rep(indent
) .. v
, 1, 1, 1)
16 self
:AddLine((" "):rep(indent
) .. data
.desc
, 1, 1, 1)
17 QuestHelper
:AppendObjectiveProgressToTooltip(data
, self
, nil, indent
+ 1)
19 --QuestHelper:TextOut(string.format("Got %d items", ct))
24 function QH_Tooltip_Add(tooltips
)
25 for k
, v
in pairs(tooltips
) do
26 local typ
, id
= k
:match("([^@]+)@@([^@]+)")
27 QuestHelper
: Assert(typ
and id
, k
)
28 if not ctts
[typ
] then ctts
[typ
] = {} end
29 if not ctts
[typ
][id
] then ctts
[typ
][id
] = {} end
30 QuestHelper
: Assert(not ctts
[typ
][id
][v
[2]]
)
31 ctts
[typ
][id
][v
[2]]
= v
[1]
34 function QH_Tooltip_Remove(tooltips
)
35 for k
, v
in pairs(tooltips
) do
36 local typ
, id
= k
:match("([^@]+)@@([^@]+)")
37 QuestHelper
: Assert(typ
and id
, k
)
38 QuestHelper
: Assert(ctts
[typ
][id
][v
[2]]
)
39 ctts
[typ
][id
][v
[2]]
= nil
42 for _
, _
in pairs(ctts
[typ
][id
]) do
52 -- TODO: move this into some common file, I hate that I'm duplicating them but I just want this to work. entire codebase will need a going-over soon
53 local function IsMonsterGUID(guid
)
54 QuestHelper
: Assert(#guid
== 18, "guid len " .. guid
) -- 64 bits, plus the 0x prefix
55 QuestHelper
: Assert(guid
:sub(1, 2) == "0x", "guid 0x-prefix " .. guid
)
56 return guid
:sub(5, 5) == "3" or guid
:sub(5, 5) == "5"
59 local function GetMonsterType(guid
)
60 QuestHelper
: Assert(#guid
== 18, "guid len " .. guid
) -- 64 bits, plus the 0x prefix
61 QuestHelper
: Assert(guid
:sub(1, 2) == "0x", "guid 0x-prefix " .. guid
)
62 QuestHelper
: Assert(guid
:sub(5, 5) == "3" or guid
:sub(5, 5) == "5", "guid 3-prefix " .. guid
) -- It *shouldn't* be a player or a pet by the time we've gotten here. If so, something's gone wrong.
63 return tonumber(guid
:sub(9, 12), 16) -- here's our actual identifier
66 local function GetItemType(link
, vague
)
67 return tonumber(string.match(link
,
68 (vague
and "" or "^") .. "|cff%x%x%x%x%x%x|Hitem:(%d+):[%d:-]+|h%[[^%]]*%]|h|r".. (vague
and "" or "$")
72 local function CopyOver(to
, from
)
73 to
:SetFont(from
:GetFont())
74 to
:SetFontObject(from
:GetFontObject())
75 to
:SetText(from
:GetText())
76 to
:SetTextColor(from
:GetTextColor())
77 to
:SetSpacing(from
:GetSpacing())
78 to
:SetShadowOffset(from
:GetShadowOffset())
79 to
:SetShadowColor(from
:GetShadowColor())
83 local function StripBlizzQHTooltipClone(ttp
)
84 if not UnitExists("mouseover") then return end
92 if qh_tooltip_print_a_lot
then print(line
, _G
["GameTooltipTextLeft" .. line
], _G
["GameTooltipTextLeft" .. line
]:IsShown()) end
94 while _G
["GameTooltipTextLeft" .. line
] and _G
["GameTooltipTextLeft" .. line
]:IsShown() do
95 local r
, g
, b
, a
= _G
["GameTooltipTextLeft" .. line
]:GetTextColor()
96 r
, g
, b
, a
= math
.floor(r
* 255 + 0.5), math
.floor(g
* 255 + 0.5), math
.floor(b
* 255 + 0.5), math
.floor(a
* 255 + 0.5)
98 if qh_tooltip_print_a_lot
then print(r
, g
, b
, a
) end
100 if r
== 255 and g
== 210 and b
== 0 and a
== 255 and not qh_tooltip_do_not_hide_things
then
101 if qh_tooltip_print_a_lot
then print("hiding") end
102 --_G["GameTooltipTextLeft" .. line]:SetText("hellos")
103 _G
["GameTooltipTextLeft" .. line
]:SetText(nil)
104 _G
["GameTooltipTextLeft" .. line
]:SetHeight(0)
105 _G
["GameTooltipTextLeft" .. line
]:ClearAllPoints()
106 _G
["GameTooltipTextLeft" .. line
]:SetPoint("TOPLEFT", _G
["GameTooltipTextLeft" .. (line
- 1)], "BOTTOMLEFT", 0, 1)
108 removed
= removed
+ 1
122 function CreateTooltip(self
)
125 if QuestHelper_Pref
.tooltip
then
126 local inu
, ilink
= self
:GetItem()
127 local un
, ulink
= self
:GetUnit()
128 if ulink
then ulink
= UnitGUID(ulink
) end
131 local ite
= tostring(GetItemType(ilink
))
133 if ctts
["item"] and ctts
["item"][ite
] then
134 DoTooltip(self
, ctts
["item"][ite
])
140 if qh_tooltip_print_a_lot
then print("wut", ulink
, IsMonsterGUID(ulink
)) print(ulink
) print(IsMonsterGUID(ulink
)) end
141 if ulink
and IsMonsterGUID(ulink
) then
142 if qh_tooltip_print_a_lot
then print("huhwuzat") print(QH_filter_hints
) end
144 glob_strip
= StripBlizzQHTooltipClone(self
)
146 local ite
= tostring(GetMonsterType(ulink
))
148 if ctts
["monster"] and ctts
["monster"][ite
] then
149 DoTooltip(self
, ctts
["monster"][ite
])
157 local unit_to_adjust
= nil
159 local ottsu
= GameTooltip
:GetScript("OnTooltipSetUnit")
160 QH_Hook(GameTooltip
, "OnTooltipSetUnit", function (self
, ...)
161 if qh_tooltip_print_a_lot
then print("lol") end
163 if ottsu
then ottsu(self
, ...) end
164 unit_to_adjust
= self
:GetUnit()
165 end, "tooltip OnTooltipSetUnit")
167 local ottsi
= GameTooltip
:GetScript("OnTooltipSetItem")
168 QH_Hook(GameTooltip
, "OnTooltipSetItem", function (self
, ...)
169 QH_Hook_NotMyFault(CreateTooltip
, self
)
170 if ottsi
then return QH_Hook_NotMyFault(ottsi
, self
, ...) end
171 end, "tooltip OnTooltipSetItem")
173 local ttsx
= GameTooltip
:GetScript("OnUpdate")
174 QH_Hook(GameTooltip
, "OnUpdate", function (self
, ...)
175 if ttsx
then QH_Hook_NotMyFault(ttsx
, self
, ...) end
176 if glob_strip
and unit_to_adjust
and unit_to_adjust
== self
:GetUnit() then
177 self
:SetHeight(self
:GetHeight() - glob_strip
* 3) -- maaaaaagic
180 end, "tooltip OnUpdate")