update changes
[QuestHelper.git] / hidden.lua
blob0ca1db65772808826c6ac509e40f25c5da9d90d4
1 QuestHelper_File["hidden.lua"] = "Development Version"
2 QuestHelper_Loadtime["hidden.lua"] = GetTime()
4 local function HiddenReason(obj)
5 local depends
6 for i, j in pairs(obj.after) do
7 if i.watched and not i:Known() then
8 if not depends then
9 depends = QHFormat("DEPENDS_ON_SINGLE", i:Reason(true))
10 elseif type(depends) == "string" then
11 depends = 2
12 else
13 depends = depends + 1
14 end
15 end
16 end
18 if depends then
19 if type(depends) == "string" then
20 return depends, false
21 else
22 return QHFormat("DEPENDS_ON_COUNT", depends), false
23 end
24 end
26 if obj.user_ignore == nil then
27 if obj.filter_level and QuestHelper_Pref.filter_level then
28 return QHText("FILTERED_LEVEL"), true, "level"
29 end
31 if obj.filter_zone and QuestHelper_Pref.filter_zone then
32 return QHText("FILTERED_ZONE"), true, "zone"
33 end
35 if obj.filter_done and QuestHelper_Pref.filter_done then
36 return QHText("FILTERED_COMPLETE"), true, "done"
37 end
39 if obj.filter_blocked and QuestHelper_Pref.filter_blocked then
40 return QHText("FILTERED_BLOCKED"), true, "blocked"
41 end
43 if obj.filter_watched and QuestHelper_Pref.filter_watched then
44 return QHText("FILTERED_UNWATCHED"), true, "watched"
45 end
46 elseif obj.user_ignore then
47 return QHText("FILTERED_USER"), true
48 end
50 return QHText("FILTERED_UNKNOWN"), false
51 end
53 function QuestHelper:PopulateHidden(menu)
54 local empty = true
56 for obj in pairs(self.to_add) do
57 if not obj:Known() then
58 reason, can_show, filter = HiddenReason(obj)
59 empty = false
61 local item = self:CreateMenuItem(menu, obj:Reason(true))
62 local menu2 = self:CreateMenu()
63 item:SetSubmenu(menu2)
65 local item2 = self:CreateMenuItem(menu2, reason)
67 if can_show then
68 local menu3 = self:CreateMenu()
69 item2:SetSubmenu(menu3)
70 local item3 = self:CreateMenuItem(menu3, QHText("HIDDEN_SHOW"))
71 item3:SetFunction(function (obj) obj.user_ignore = false end, obj)
73 if filter then
74 item3 = self:CreateMenuItem(menu3, QHFormat("DISABLE_FILTER", QHText("FILTER_"..string.upper(filter))))
75 item3:SetFunction(function (filter) QuestHelper_Pref["filter_"..filter] = false end, filter)
76 end
78 -- I'd add an option to adjust the level filter, but I can't tell what value would be required.
79 end
80 end
81 end
83 if empty then
84 self:CreateMenuItem(menu, QHText("HIDDEN_NONE"))
85 end
86 end
88 function QuestHelper:ShowHidden()
89 local menu = self:CreateMenu()
91 self:CreateMenuTitle(menu, QHText("HIDDEN_TITLE"))
92 self:PopulateHidden(menu)
93 menu:ShowAtCursor()
94 end