Added colour for the progress of objectives in the quest tracker.
[QuestHelper.git] / objtips.lua
blobd3315ded2962ea647ae5d86709405724ba397f01
1 QuestHelper_File["objtips.lua"] = "Development Version"
3 local real_GameTooltipOnShow = GameTooltip:GetScript("OnShow") or QuestHelper.nop
5 local function addObjectiveObjTip(tooltip, objective, depth)
6 if objective.watched or objective.progress then
7 if objective.quest then
8 tooltip:AddLine((" "):rep(depth)..QHFormat("TOOLTIP_QUEST", string.match(objective.quest.obj or "", "^%d*/%d*/(.*)$") or "???"), 1, 1, 1)
10 depth = depth + 1
11 end
13 if objective.progress then
14 QuestHelper:AppendObjectiveProgressToTooltip(objective, tooltip, nil, depth)
15 else
16 tooltip:AddLine((" "):rep(depth)..QHText("TOOLTIP_WATCHED"), unpack(QuestHelper:GetColourTheme().tooltip))
17 end
19 -- Calling Show again to cause the tooltip's dimensions to be recalculated.
20 -- Since the frame should already be shown, the OnShow event shouldn't be called again.
21 tooltip:Show()
22 end
24 if objective.used then
25 for obj, text in pairs(objective.used) do
26 tooltip:AddLine((" "):rep(depth)..QHFormat(text, obj.obj), 1, 1, 1)
27 addObjectiveObjTip(tooltip, obj, depth+1)
28 end
29 end
30 end
32 local function addObjectiveTip(tooltip, cat, obj)
33 local list = QuestHelper.objective_objects[cat]
34 if list then
35 local objective = list[obj]
36 if objective then
37 addObjectiveObjTip(tooltip, objective, 0)
38 end
39 end
40 end
42 GameTooltip:SetScript("OnShow", function(self, ...)
43 if not self then
44 -- Some other AddOns hook this function, but don't bother to pass the values they were called with.
45 self = GameTooltip
46 end
48 if QuestHelper_Pref.tooltip then
49 local monster, item = self:GetUnit(), self:GetItem()
51 if monster then
52 addObjectiveTip(self, "monster", monster)
53 end
55 if item then
56 addObjectiveTip(self, "item", item)
57 end
58 end
60 return real_GameTooltipOnShow(self, ...)
61 end)