expose default config so MCM can access

This commit is contained in:
Lilian Jónsdóttir 2021-08-11 10:02:45 -07:00
parent 83d01ec04a
commit be297bb586
3 changed files with 17 additions and 9 deletions

View file

@ -1,6 +1,8 @@
local common = require("celediel.ASinkingFeeling.common") local common = require("celediel.ASinkingFeeling.common")
local defaultConfig = { local this = {}
this.defaultConfig = {
enabled = true, enabled = true,
debug = false, debug = false,
playerOnly = false, playerOnly = false,
@ -12,6 +14,11 @@ local defaultConfig = {
mode = common.modes.equippedArmour.value mode = common.modes.equippedArmour.value
} }
local config = mwse.loadConfig(common.configString, defaultConfig) local currentConfig
return config this.getConfig = function()
currentConfig = currentConfig or mwse.loadConfig(common.configString, this.defaultConfig)
return currentConfig
end
return this

View file

@ -1,4 +1,4 @@
local config = require("celediel.ASinkingFeeling.config") local config = require("celediel.ASinkingFeeling.config").getConfig()
local common = require("celediel.ASinkingFeeling.common") local common = require("celediel.ASinkingFeeling.common")
-- Helper Functions -- Helper Functions

View file

@ -1,7 +1,8 @@
local common = require("celediel.ASinkingFeeling.common") local common = require("celediel.ASinkingFeeling.common")
local config = require("celediel.ASinkingFeeling.config") local config = require("celediel.ASinkingFeeling.config")
local currentConfig = config.getConfig()
local function createTableVar(id) return mwse.mcm.createTableVariable({id = id, table = config}) end local function createTableVar(id) return mwse.mcm.createTableVariable({id = id, table = currentConfig}) end
local function createDescriptions() local function createDescriptions()
local description = "Formula used to calculate down-pull amount.\n\nOptions are: " local description = "Formula used to calculate down-pull amount.\n\nOptions are: "
@ -37,7 +38,7 @@ local function createOptions()
end end
local template = mwse.mcm.createTemplate(common.modName) local template = mwse.mcm.createTemplate(common.modName)
template:saveOnClose(common.configString, config) template:saveOnClose(common.configString, currentConfig)
local page = template:createSideBarPage({ local page = template:createSideBarPage({
label = "Sidebar Page???", label = "Sidebar Page???",
@ -65,12 +66,12 @@ category:createDropdown({
variable = createTableVar("mode") variable = createTableVar("mode")
}) })
for name, _ in pairs(config.multipliers) do for name, _ in pairs(config.defaultConfig.multipliers) do
local title = common.camelCaseToWords(name) local title = common.camelCaseToWords(name)
category:createSlider({ category:createSlider({
label = title .. " multiplier", label = title .. " multiplier",
description = "Multiplier used for " .. title .." formula. Default value: 100", description = "Multiplier used for " .. title .." formula. Default value: " .. config.defaultConfig.multipliers[name],
variable = mwse.mcm.createTableVariable({id = name, table = config.multipliers}), variable = mwse.mcm.createTableVariable({id = name, table = currentConfig.multipliers}),
min = 0, min = 0,
max = 300, max = 300,
step = 1, step = 1,