store clean up helper settings
This commit is contained in:
parent
58dd1e79af
commit
1cbb7e2aa7
@ -177,6 +177,14 @@ function importFromToken()
|
||||
end
|
||||
end
|
||||
|
||||
-- restore Clean Up Helper state
|
||||
if importData["CleanUpHelperState"] then
|
||||
local cleanUpHelper = guidReferenceApi.getObjectByOwnerAndType("Mythos", "CleanUpHelper")
|
||||
if cleanUpHelper ~= nil then
|
||||
cleanUpHelper.call("loadData", importData["CleanUpHelperState"])
|
||||
end
|
||||
end
|
||||
|
||||
-- restore Navigation Overlay state
|
||||
if importData["NavigationOverlayState"] then
|
||||
navigationOverlayApi.loadData(importData["NavigationOverlayState"])
|
||||
@ -291,6 +299,12 @@ function exportToToken()
|
||||
dataToSave.slotData[matColor] = slotData
|
||||
end
|
||||
|
||||
-- get Clean Up Helper settings
|
||||
local cleanUpHelper = guidReferenceApi.getObjectByOwnerAndType("Mythos", "CleanUpHelper")
|
||||
if cleanUpHelper ~= nil then
|
||||
dataToSave.CleanUpHelperState = cleanUpHelper.call("getSaveData", {})
|
||||
end
|
||||
|
||||
-- get Navigation Overlay settings
|
||||
dataToSave.NavigationOverlayState = navigationOverlayApi.getSaveData()
|
||||
|
||||
|
@ -22,8 +22,8 @@ local RESET_VALUES = {}
|
||||
local loadingFailedBefore = false
|
||||
local optionsVisible = false
|
||||
local options = {
|
||||
["importTrauma"] = true,
|
||||
["tidyPlayermats"] = true,
|
||||
["importTrauma"] = true,
|
||||
["tidyPlayermats"] = true,
|
||||
["removeDrawnLines"] = false
|
||||
}
|
||||
local removeIgnoreLater = {}
|
||||
@ -45,18 +45,28 @@ buttonParameters.function_owner = self
|
||||
-- option loading and GUI setup
|
||||
---------------------------------------------------------
|
||||
|
||||
function onSave()
|
||||
return JSON.encode({ options = options })
|
||||
function getSaveData()
|
||||
return { options = options }
|
||||
end
|
||||
|
||||
function updateSave()
|
||||
self.script_state = JSON.encode(getSaveData())
|
||||
end
|
||||
|
||||
-- loads data and updates the UI to match
|
||||
function loadData(loadedData)
|
||||
if not loadedData then return end
|
||||
|
||||
options = loadedData.options
|
||||
|
||||
for id, state in pairs(options) do
|
||||
self.UI.setAttribute(id, "image", state and "option_on" or "option_off")
|
||||
end
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
if savedData ~= nil then
|
||||
local loadedData = JSON.decode(savedData)
|
||||
options = loadedData.options
|
||||
-- update UI to match saved state
|
||||
for id, state in pairs(options) do
|
||||
self.UI.setAttribute(id, "image", state and "option_on" or "option_off")
|
||||
end
|
||||
if savedData ~= nil and savedData ~= "" then
|
||||
loadData(JSON.decode(savedData))
|
||||
end
|
||||
|
||||
-- index 0: button as label
|
||||
@ -98,6 +108,7 @@ function optionButtonClick(_, id)
|
||||
local newState = (currentState and "option_off" or "option_on")
|
||||
options[id] = not currentState
|
||||
self.UI.setAttribute(id, "image", newState)
|
||||
updateSave()
|
||||
end
|
||||
|
||||
-- shows or hides the option panel
|
||||
|
Loading…
Reference in New Issue
Block a user