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