-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsavedvars.lua
100 lines (82 loc) · 2.42 KB
/
savedvars.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
local SV = {}
DQT.SV = SV
-- Call this before using the object
function SV:init()
-- load account-wide saved variables
self.savedVarsPerAccount = ZO_SavedVars:NewAccountWide("PolloxsDailyQuestTracker_SavedVarsAccount", 1, nil, self:getAccountDefaults())
--[[ load saved variables for each character
character id -> saved variables for that character
--]]
self.savedVarsPerChar = {}
for _, character in ipairs(DQT.Utils:getCharacters()) do
-- Load a different set of variables for each character, and use character id as the key
self.savedVarsPerChar[character.id] = ZO_SavedVars:New("PolloxsDailyQuestTracker_SavedVarsChar",
1, nil, DQT.SV:getCharDefaults(), nil, nil, character.name, character.id, ZO_SAVED_VARS_CHARACTER_ID_KEY)
end
-- get the latest timer info for this character
DQT.Timer:init()
end
--[[
Get account wide saved variables
windowProperties = {x, y, width, height}
charactersToShow: characterId -> shouldShow
sectionsToShow: sectionName -> shouldShow
--]]
function SV:getAccountWide()
return self.savedVarsPerAccount
end
--[[
Get per character saved variables. See also getSavedVarsForChar.
@return characterId -> saved variables
--]]
function SV:getPerChar()
return self.savedVarsPerChar
end
--[[
Get per character saved variables
questStatuses:
quest name -> (time added (in utc), completed (boolean))
questTimers:
TIMER_TYPE -> reset time (in utc)
if entry is missing, reset time is unknown
--]]
function SV:getForChar(characterId)
return self.savedVarsPerChar[characterId]
end
-- Get default account-wide settings
function SV:getAccountDefaults()
-- get default window properties
local x, y = DQTWindow:GetScreenRect()
local width, height = DQTWindow:GetDimensions()
local windowProperties = {
x = x,
y = y,
width = width,
height = height
}
------ get default settings ------
-- by default, show all characters
local charactersToShow = {}
for _, character in ipairs(DQT.Utils:getCharacters()) do
charactersToShow[character.id] = true
end
-- by default, show all sections
local sectionsToShow = {}
for _, section in ipairs(DQT.Info.QuestSections) do
sectionsToShow[section:getName()] = true
end
return {
windowProperties = windowProperties,
settings = {
sectionsToShow = sectionsToShow,
charactersToShow = charactersToShow
}
}
end
-- Get default per character data
function SV:getCharDefaults()
return {
questStatuses = {},
questTimers = {}
}
end