fix the tooltips not going away
[QuestHelper.git] / hidden.lua
blob4f3600a7cd2495c64c22d915df5de26b33126200
1 QuestHelper_File["hidden.lua"] = "Development Version"
2 QuestHelper_Loadtime["hidden.lua"] = GetTime()
4 do return end -- bzzzzt
6 local function HiddenReason(obj)
7 local depends
8 for i, j in pairs(obj.after) do
9 if i.watched and not i:Known() then
10 if not depends then
11 depends = QHFormat("DEPENDS_ON_SINGLE", i:Reason(true))
12 elseif type(depends) == "string" then
13 depends = 2
14 else
15 depends = depends + 1
16 end
17 end
18 end
20 if depends then
21 if type(depends) == "string" then
22 return depends, false
23 else
24 return QHFormat("DEPENDS_ON_COUNT", depends), false
25 end
26 end
28 if obj.user_ignore == nil then
29 if obj.filter_level and QuestHelper_Pref.filter_level then
30 return QHText("FILTERED_LEVEL"), true, "level"
31 end
33 if obj.filter_zone and QuestHelper_Pref.filter_zone then
34 return QHText("FILTERED_ZONE"), true, "zone"
35 end
37 if obj.filter_done and QuestHelper_Pref.filter_done then
38 return QHText("FILTERED_COMPLETE"), true, "done"
39 end
41 if obj.filter_blocked and QuestHelper_Pref.filter_blocked then
42 return QHText("FILTERED_BLOCKED"), true, "blocked"
43 end
45 if obj.filter_watched and QuestHelper_Pref.filter_watched then
46 return QHText("FILTERED_UNWATCHED"), true, "watched"
47 end
48 elseif obj.user_ignore then
49 return QHText("FILTERED_USER"), true
50 end
52 return QHText("FILTERED_UNKNOWN"), false
53 end
55 function QuestHelper:PopulateHidden(menu)
56 local empty = true
58 for obj in pairs(self.to_add) do
59 if not obj:Known() then
60 reason, can_show, filter = HiddenReason(obj)
61 empty = false
63 local item = self:CreateMenuItem(menu, obj:Reason(true))
64 local menu2 = self:CreateMenu()
65 item:SetSubmenu(menu2)
67 local item2 = self:CreateMenuItem(menu2, reason)
69 if can_show then
70 local menu3 = self:CreateMenu()
71 item2:SetSubmenu(menu3)
72 local item3 = self:CreateMenuItem(menu3, QHText("HIDDEN_SHOW"))
73 item3:SetFunction(function (obj) obj.user_ignore = false end, obj)
75 if filter then
76 item3 = self:CreateMenuItem(menu3, QHFormat("DISABLE_FILTER", QHText("FILTER_"..string.upper(filter))))
77 item3:SetFunction(function (filter) QuestHelper_Pref["filter_"..filter] = false end, filter)
78 end
80 -- I'd add an option to adjust the level filter, but I can't tell what value would be required.
81 end
82 end
83 end
85 if empty then
86 self:CreateMenuItem(menu, QHText("HIDDEN_NONE"))
87 end
88 end
90 function QuestHelper:ShowHidden()
91 local menu = self:CreateMenu()
93 self:CreateMenuTitle(menu, QHText("HIDDEN_TITLE"))
94 self:PopulateHidden(menu)
95 menu:ShowAtCursor()
96 end