-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.lua
74 lines (59 loc) · 1.93 KB
/
settings.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
local Settings = {}
DQT.Settings = Settings
Settings.panelData = {
type = "panel",
name = "Pollox's Daily Quest Tracker",
author = "Pollox",
website = "https://www.esoui.com/downloads/info2192-PolloxsDailyQuestTracker.html"
}
-- Section name -> should show section
Settings.sectionsToShow = {}
-- @param savedSettings settings table that gets saved to disk
function Settings:initialize(savedSettings)
self.settings = savedSettings
local LAM = LibAddonMenu2
LAM:RegisterAddonPanel(DQT.Main.name, self.panelData)
local optionsData = {}
-- options to filter by character
local characterHeader = {
type = "header",
name = GetString(SI_DQT_CHARACTERS_HEADER)
}
optionsData[#optionsData + 1] = characterHeader
for _, character in ipairs(DQT.Utils:getCharacters()) do
local checkbox = {
type = "checkbox",
name = character.name,
getFunc = function() return self.settings.charactersToShow[character.id] end,
setFunc = function(value) self.settings.charactersToShow[character.id] = value end,
requiresReload = true
}
optionsData[#optionsData + 1] = checkbox
end
-- options to filter by section
local sectionHeader = {
type = "header",
name = GetString(SI_DQT_SECTION_HEADER)
}
optionsData[#optionsData + 1] = sectionHeader
for _, section in ipairs(DQT.Info.QuestSections) do
local checkbox = {
type = "checkbox",
name = section:getName(),
getFunc = function() return self:shouldShowSection(section) end,
setFunc = function(value) self.settings.sectionsToShow[section:getName()] = value end,
requiresReload = true
}
optionsData[#optionsData + 1] = checkbox
end
LAM:RegisterOptionControls(DQT.Main.name, optionsData)
end
--[[
@param section quest section or timer section
--]]
function Settings:shouldShowSection(section)
return self.settings.sectionsToShow[section:getName()]
end
function Settings:shouldShowCharacter(characterId)
return self.settings.charactersToShow[characterId]
end