diff --git a/config.json b/config.json index afbade21..f3b6e45c 100644 --- a/config.json +++ b/config.json @@ -22,7 +22,7 @@ }, "Lighting_path": "Lighting.json", "LuaScript": "require(\"core/Global\")", - "LuaScriptState": "", + "LuaScriptState": "[]", "MusicPlayer_path": "MusicPlayer.json", "Note": "", "ObjectStates_order": [ @@ -266,5 +266,5 @@ "Tags": [], "Turns_path": "Turns.json", "VersionNumber": "v13.2.2", - "XmlUI_path": "Root.xml" + "XmlUI": "" } diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 74758332..be3f299a 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -5,6 +5,9 @@ ENCOUNTER_DECK_POS = {-3.93, 1, 5.76} ENCOUNTER_DECK_DISCARD_POSITION = {-3.85, 1, 10.38} +-- optionPanel data +optionPanel = {} + -- GUID of data helper DATA_HELPER_GUID = "708279" @@ -125,10 +128,27 @@ local overallStats = { -- general code --------------------------------------------------------- -function onLoad() +-- saving state of optionPanel to restore later +function onSave() return JSON.encode(optionPanel) end + +function onLoad(savedData) + if savedData then + optionPanel = JSON.decode(savedData) + for id, enabled in pairs(optionPanel) do + if enabled then + self.UI.setAttribute("toggle" .. id, "isOn", true) + end + end + else + for i = 1, 8 do + optionPanel[i] = false + end + end + for _, guid in ipairs(NOT_INTERACTABLE) do getObjectFromGUID(guid).interactable = false end + math.randomseed(os.time()) end @@ -581,7 +601,6 @@ function onClick_defaultSettings() print("Dummy: Load default settings") end -local optionPanel = {} function onClick_toggleOption(_, id) local state = self.UI.getAttribute("toggle" .. id, "isOn") diff --git a/objects/Root.xml b/xml/Global.xml similarity index 100% rename from objects/Root.xml rename to xml/Global.xml