let's see if we can track this one down someday
[QuestHelper.git] / objtips.lua
blob3ceff636b1bba5ae89b5eda1bdd5b8d12506df34
1 QuestHelper_File["objtips.lua"] = "Development Version"
2 QuestHelper_Loadtime["objtips.lua"] = GetTime()
4 local real_GameTooltipOnShow = GameTooltip:GetScript("OnShow") or QuestHelper.nop
6 local function addObjectiveObjTip(tooltip, objective, depth, already_touched)
7 if depth > 10 then return end -- fuck that, man. Just fuck that.
8 already_touched[objective] = true -- YOU CANNOT EAT A PURSE
10 if objective.watched or objective.progress then
11 local depth2 = depth
13 if objective.quest then
14 tooltip:AddLine((" "):rep(depth2)..QHFormat("TOOLTIP_QUEST", string.match(objective.quest.obj or "", "^%d*/%d*/(.*)$") or "???"), 1, 1, 1)
16 depth2 = depth2 + 1
17 end
19 if objective.progress then
20 QuestHelper:AppendObjectiveProgressToTooltip(objective, tooltip, nil, depth2)
21 else
22 tooltip:AddLine((" "):rep(depth2)..QHText("TOOLTIP_WATCHED"), unpack(QuestHelper:GetColourTheme().tooltip))
23 end
25 -- Calling Show again to cause the tooltip's dimensions to be recalculated.
26 -- Since the frame should already be shown, the OnShow event shouldn't be called again.
27 tooltip:Show()
28 end
30 if objective.used then
31 for obj, text in pairs(objective.used) do
32 if not already_touched[obj] then -- no infinite loops please
33 tooltip:AddLine((" "):rep(depth)..QHFormat(text, obj.obj), 1, 1, 1)
34 addObjectiveObjTip(tooltip, obj, depth+1, already_touched)
35 end
36 end
37 end
39 already_touched[objective] = nil -- oh why not. just so I can get a screenshot of some poor sap getting a 2^n case
40 end
42 local function addObjectiveTip(tooltip, cat, obj)
43 local list = QuestHelper.objective_objects[cat]
44 if list then
45 local objective = list[obj]
46 if objective then
47 addObjectiveObjTip(tooltip, objective, 0, {})
48 end
49 end
50 end
52 GameTooltip:SetScript("OnShow", function(self, ...)
53 if not self then
54 -- Some other AddOns hook this function, but don't bother to pass the values they were called with.
55 self = GameTooltip
56 end
58 if QuestHelper_Pref.tooltip then
59 -- Apparantly, sometimes InventoryOnPar invokes our tooltip function with something that doesn't have GetItem method.
60 local monster, item = self.GetUnit and self:GetUnit(), self.GetItem and self:GetItem()
62 if monster then
63 addObjectiveTip(self, "monster", monster)
64 end
66 if item then
67 addObjectiveTip(self, "item", item)
68 end
69 end
71 return real_GameTooltipOnShow(self, ...)
72 end)