diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js index 98c055f5ecc990493b593ae4b9861d2dacc0c1bd..09f145ab71e04ef6895034bf73c7e0c0a0a50e8c 100644 --- a/js/003-data/gameVariableData.js +++ b/js/003-data/gameVariableData.js @@ -178,7 +178,6 @@ App.Data.defaultGameStateVariables = { useTabs: 0, verboseDescriptions: 0, verticalizeArcologyLinks: 0, - theme: 0, weightAffectsAssets: 1, curativeSideEffects: 1, disableTiredness: 1, diff --git a/src/gui/theming.js b/src/gui/theming.js index 08bf7e627f8175d8e1be77badcc6279bf2febc44..ceb8e641d968cf3655ab60bc3996d26a0132a6f4 100644 --- a/src/gui/theming.js +++ b/src/gui/theming.js @@ -6,16 +6,18 @@ App.UI.Theme = (function() { let devTheme = null; // reload theme on page reload - $(document).on(":passagestart", () => { - if (currentThemeElement === null && V.theme !== 0 && V.theme !== undefined) { - load(V.theme); + $(document).on(":storyready", () => { + if (currentThemeElement === null) { + const file = SugarCube.storage.get("theme"); + if (file !== null) { + load(file); + } } }); return { selector: selector, devTheme: reloadDevTheme, - onLoad: onLoad }; /** @@ -44,7 +46,7 @@ App.UI.Theme = (function() { * @param {string} filename or filepath relative to the HTML file. */ function load(filename) { - V.theme = filename; + SugarCube.storage.set("theme", filename); currentThemeElement = newTheme(filename); } @@ -52,7 +54,7 @@ App.UI.Theme = (function() { if (currentThemeElement !== null) { document.head.removeChild(currentThemeElement); currentThemeElement = null; - V.theme = 0; + SugarCube.storage.delete("theme"); } } @@ -86,13 +88,4 @@ App.UI.Theme = (function() { document.head.appendChild(theme); return theme; } - - /** - * @param {object} V - */ - function onLoad(V) { - if (V.theme !== 0) { - load(V.theme); - } - } })(); diff --git a/src/js/eventHandlers.js b/src/js/eventHandlers.js index 4e3a7fc73e4e128f3d3566970828a0492aa020ef..f14431042abe44d14087718351f99e04421f7c82 100644 --- a/src/js/eventHandlers.js +++ b/src/js/eventHandlers.js @@ -13,8 +13,6 @@ App.EventHandlers = function() { if (v.releaseID === App.Version.release) { App.UI.SlaveSummary.settingsChanged(v); } - - App.UI.Theme.onLoad(v); } /**