2016-10-10 19:48:47 +00:00
|
|
|
--[[
|
|
|
|
AchievementInfo
|
|
|
|
@author Asto, @Astarax
|
|
|
|
]]
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-07 12:47:51 +00:00
|
|
|
-- Function to determine if Account Wide Settings should be used
|
|
|
|
function AchievementInfo.loadUseAccountWideSettings()
|
|
|
|
return ZO_SavedVars:New("ACHIEVEMENT_INFO_DB_USE_AW", 1, nil, {
|
|
|
|
enabled = false
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 19:48:47 +00:00
|
|
|
-- Function to set and load the Saved Variables
|
|
|
|
function AchievementInfo.loadSavedVars()
|
|
|
|
local defaults = {
|
|
|
|
genEnabled = true,
|
|
|
|
genShowEveryUpdate = true,
|
|
|
|
genShowUpdateSteps = 25,
|
|
|
|
genShowDetails = false,
|
|
|
|
genShowOpenDetailsOnly = true,
|
|
|
|
genOnePerLine = true,
|
|
|
|
cat1 = true,
|
|
|
|
cat2 = true,
|
|
|
|
cat3 = true,
|
|
|
|
cat4 = true,
|
|
|
|
cat5 = true,
|
|
|
|
cat6 = true,
|
|
|
|
cat7 = true,
|
|
|
|
cat8 = true,
|
|
|
|
cat9 = true,
|
|
|
|
cat10 = true,
|
2019-02-10 14:12:44 +00:00
|
|
|
cat11 = true,
|
|
|
|
cat12 = true,
|
|
|
|
cat13 = true,
|
|
|
|
cat14 = true,
|
|
|
|
cat15 = true,
|
|
|
|
cat16 = true,
|
|
|
|
cat17 = true,
|
|
|
|
cat18 = true,
|
|
|
|
cat19 = true,
|
|
|
|
cat20 = true,
|
|
|
|
cat21 = true,
|
|
|
|
cat22 = true,
|
2020-06-07 12:47:51 +00:00
|
|
|
-- ... new one default to true
|
2016-10-10 19:48:47 +00:00
|
|
|
devDebug = false
|
|
|
|
}
|
|
|
|
|
2020-06-07 12:47:51 +00:00
|
|
|
if AchievementInfo.useAccountWideSettings["enabled"] == true then
|
|
|
|
return ZO_SavedVars:NewAccountWide("ACHIEVEMENT_INFO_DB", 1, nil, defaults)
|
|
|
|
end
|
|
|
|
|
2016-10-10 19:48:47 +00:00
|
|
|
return ZO_SavedVars:New("ACHIEVEMENT_INFO_DB", 1, nil, defaults)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Function to create the settings panel
|
|
|
|
function AchievementInfo.createSettingsPanel()
|
|
|
|
local panelData = {
|
|
|
|
type = "panel",
|
|
|
|
name = AchievementInfo.name,
|
2020-06-07 12:47:51 +00:00
|
|
|
displayName = AchievementInfo.clrDefault .. AchievementInfo.name,
|
2016-10-10 19:48:47 +00:00
|
|
|
author = AchievementInfo.author,
|
2020-06-07 12:47:51 +00:00
|
|
|
version = string.format("%.2f", AchievementInfo.version),
|
2016-10-10 19:48:47 +00:00
|
|
|
slashCommand = "/achievementInfo"
|
|
|
|
}
|
|
|
|
|
|
|
|
local optionsTable = {
|
|
|
|
[1] = {
|
|
|
|
type = "header",
|
2020-06-07 12:47:51 +00:00
|
|
|
name = AchievementInfo.clrSettingsHeader .. LANG.SettingsHeader.General
|
2016-10-10 19:48:47 +00:00
|
|
|
},
|
|
|
|
[2] = {
|
|
|
|
type = "checkbox",
|
|
|
|
name = LANG.SettingsOption.AddOnEnabled,
|
|
|
|
tooltip = LANG.SettingsOption.AddOnEnabledTooltip,
|
|
|
|
getFunc = function() return AchievementInfo.settingGet("genEnabled") end,
|
|
|
|
setFunc = function() AchievementInfo.settingToogle("genEnabled") end,
|
|
|
|
warning = LANG.SettingsOption.AddOnEnabledWarning
|
|
|
|
},
|
|
|
|
[3] = {
|
2020-06-07 12:47:51 +00:00
|
|
|
type = "checkbox",
|
|
|
|
name = LANG.SettingsOption.AccountWideEnabled,
|
|
|
|
tooltip = LANG.SettingsOption.AccountWideEnabledTooltip,
|
|
|
|
getFunc = function() return AchievementInfo.useAccountWideSettings["enabled"] end,
|
|
|
|
setFunc = function() AchievementInfo.toggleAccountWideSettings() end,
|
|
|
|
requiresReload = true
|
|
|
|
},
|
|
|
|
[4] = {
|
2016-10-10 19:48:47 +00:00
|
|
|
type = "checkbox",
|
|
|
|
name = LANG.SettingsOption.ShowEveryUpdate,
|
|
|
|
tooltip = LANG.SettingsOption.ShowEveryUpdateTooltip,
|
|
|
|
getFunc = function() return AchievementInfo.settingGet("genShowEveryUpdate") end,
|
|
|
|
setFunc = function() AchievementInfo.settingToogle("genShowEveryUpdate") end
|
|
|
|
},
|
2020-06-07 12:47:51 +00:00
|
|
|
[5] = {
|
2016-10-10 19:48:47 +00:00
|
|
|
type = "slider",
|
|
|
|
name = LANG.SettingsOption.ShowUpdateSteps,
|
|
|
|
tooltip = LANG.SettingsOption.ShowUpdateStepsTooltip,
|
|
|
|
min = 1,
|
|
|
|
max = 100,
|
|
|
|
step = 1,
|
|
|
|
getFunc = function() return AchievementInfo.settingGet("genShowUpdateSteps") end,
|
|
|
|
setFunc = function(value) AchievementInfo.settingSet("genShowUpdateSteps", value) end,
|
|
|
|
default = 25
|
|
|
|
},
|
2020-06-07 12:47:51 +00:00
|
|
|
[6] = {
|
2016-10-10 19:48:47 +00:00
|
|
|
type = "checkbox",
|
|
|
|
name = LANG.SettingsOption.ShowDetails,
|
|
|
|
tooltip = LANG.SettingsOption.ShowDetailsTooltip,
|
|
|
|
getFunc = function() return AchievementInfo.settingGet("genShowDetails") end,
|
|
|
|
setFunc = function() AchievementInfo.settingToogle("genShowDetails") end
|
|
|
|
},
|
2020-06-07 12:47:51 +00:00
|
|
|
[7] = {
|
2016-10-10 19:48:47 +00:00
|
|
|
type = "checkbox",
|
|
|
|
name = LANG.SettingsOption.ShowOpenDetailsOnly,
|
|
|
|
tooltip = LANG.SettingsOption.ShowOpenDetailsOnlyTooltip,
|
|
|
|
getFunc = function() return AchievementInfo.settingGet("genShowOpenDetailsOnly") end,
|
|
|
|
setFunc = function() AchievementInfo.settingToogle("genShowOpenDetailsOnly") end
|
|
|
|
},
|
2020-06-07 12:47:51 +00:00
|
|
|
[8] = {
|
2016-10-10 19:48:47 +00:00
|
|
|
type = "checkbox",
|
|
|
|
name = LANG.SettingsOption.OneElementPerLine,
|
|
|
|
tooltip = LANG.SettingsOption.OneElementPerLineTooltip,
|
|
|
|
getFunc = function() return AchievementInfo.settingGet("genOnePerLine") end,
|
|
|
|
setFunc = function() AchievementInfo.settingToogle("genOnePerLine") end,
|
|
|
|
warning = LANG.SettingsOption.OneElementPerLineWarning
|
|
|
|
},
|
2020-06-07 12:47:51 +00:00
|
|
|
[9] = {
|
2016-10-10 19:48:47 +00:00
|
|
|
type = "header",
|
|
|
|
name = AchievementInfo.clrSettingsHeader .. LANG.SettingsHeader.Categories
|
|
|
|
},
|
2020-06-07 12:47:51 +00:00
|
|
|
[10] = {
|
2016-10-10 19:48:47 +00:00
|
|
|
type = "description",
|
|
|
|
text = LANG.SettingsHeader.CategoriesDescription .. ":"
|
|
|
|
}
|
|
|
|
}
|
2019-10-23 20:24:30 +00:00
|
|
|
|
2016-10-10 19:48:47 +00:00
|
|
|
-- Add categories dynamically
|
|
|
|
local numCats = GetNumAchievementCategories()
|
|
|
|
|
|
|
|
for i = 1, numCats, 1 do
|
2019-10-23 20:24:30 +00:00
|
|
|
catName = GetAchievementCategoryInfo(i)
|
|
|
|
|
2016-10-10 19:48:47 +00:00
|
|
|
table.insert(optionsTable, {
|
|
|
|
type = "checkbox",
|
|
|
|
name = catName,
|
|
|
|
tooltip = LANG.SettingsOption.CategoryTooltip .. " '" .. catName .. "'",
|
2020-06-07 12:47:51 +00:00
|
|
|
getFunc = function() return AchievementInfo.settingGetForCategory("cat" .. i) end,
|
|
|
|
setFunc = function() AchievementInfo.settingToogle("cat" .. i) end
|
2016-10-10 19:48:47 +00:00
|
|
|
})
|
|
|
|
end
|
2019-10-23 20:24:30 +00:00
|
|
|
|
2016-10-10 19:48:47 +00:00
|
|
|
-- Debug setting at the end
|
|
|
|
table.insert(optionsTable, {
|
|
|
|
type = "header",
|
|
|
|
name = AchievementInfo.clrSettingsHeader .. LANG.SettingsHeader.Development
|
|
|
|
})
|
2019-10-23 20:24:30 +00:00
|
|
|
|
2016-10-10 19:48:47 +00:00
|
|
|
table.insert(optionsTable, {
|
|
|
|
type = "checkbox",
|
|
|
|
name = LANG.SettingsOption.DebugMode,
|
|
|
|
tooltip = LANG.SettingsOption.DebugModeTooltip,
|
|
|
|
getFunc = function() return AchievementInfo.settingGet("devDebug") end,
|
|
|
|
setFunc = function() AchievementInfo.settingToogle("devDebug") end,
|
|
|
|
warning = LANG.SettingsOption.DebugModeWarning
|
|
|
|
})
|
2019-10-23 20:24:30 +00:00
|
|
|
|
2016-10-10 19:48:47 +00:00
|
|
|
-- Register
|
2020-06-07 12:47:51 +00:00
|
|
|
LibAddonMenu2:RegisterAddonPanel(AchievementInfo.name .. "SettingsPanel", panelData)
|
|
|
|
LibAddonMenu2:RegisterOptionControls(AchievementInfo.name .. "SettingsPanel", optionsTable)
|
2016-10-10 19:48:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Function to retrieve settings
|
|
|
|
function AchievementInfo.settingGet(id)
|
|
|
|
if AchievementInfo.savedVars[id] == nil then
|
|
|
|
AchievementInfo.savedVars[id] = false
|
|
|
|
return false
|
|
|
|
else
|
|
|
|
return AchievementInfo.savedVars[id]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-07 12:47:51 +00:00
|
|
|
-- Function to retrieve settings for categories (default true)
|
|
|
|
function AchievementInfo.settingGetForCategory(id)
|
|
|
|
if AchievementInfo.savedVars[id] == nil then
|
|
|
|
AchievementInfo.savedVars[id] = true
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return AchievementInfo.savedVars[id]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 19:48:47 +00:00
|
|
|
-- Function to toggle Checkbox values
|
|
|
|
function AchievementInfo.settingToogle(id)
|
|
|
|
if AchievementInfo.savedVars[id] == false then
|
|
|
|
AchievementInfo.savedVars[id] = true
|
|
|
|
else
|
|
|
|
AchievementInfo.savedVars[id] = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-07 12:47:51 +00:00
|
|
|
-- Function to toggle Checkbox value for accountWideSettings
|
|
|
|
function AchievementInfo.toggleAccountWideSettings()
|
|
|
|
if AchievementInfo.useAccountWideSettings["enabled"] == false then
|
|
|
|
AchievementInfo.useAccountWideSettings["enabled"] = true
|
|
|
|
else
|
|
|
|
AchievementInfo.useAccountWideSettings["enabled"] = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-10 19:48:47 +00:00
|
|
|
-- Function to set settings
|
|
|
|
function AchievementInfo.settingSet(id, value)
|
|
|
|
AchievementInfo.savedVars[id] = value
|
|
|
|
end
|