diff --git a/js/components.js b/js/components.js index 9e1259d..b5d1893 100644 --- a/js/components.js +++ b/js/components.js @@ -137,7 +137,7 @@ function loadVue() { Vue.component('challenge', { props: ['layer', 'data'], template: ` -





@@ -558,6 +558,7 @@ function loadVue() { data: { player, tmp, + options, Decimal, format, formatWhole, diff --git a/js/game.js b/js/game.js index e799201..c8c2b0c 100644 --- a/js/game.js +++ b/js/game.js @@ -224,7 +224,7 @@ function doReset(layer, force=false) { if (row >= layers[layerResetting].row && (!force || layerResetting != layer)) completeChallenge(layerResetting) } - prevOnReset = {...player} //Deep Copy + prevOnReset = {...player} player.points = (row == 0 ? decimalZero : getStartPoints()) for (let x = row; x >= 0; x--) rowReset(x, layer) @@ -336,7 +336,7 @@ function gameLoop(diff) { if (isNaN(diff)) diff = 0 if (gameEnded && !player.keepGoing) { diff = 0 - player.tab = "gameEnded" + //player.tab = "gameEnded" clearParticles() } diff --git a/js/technical/displays.js b/js/technical/displays.js index c79634b..e982494 100644 --- a/js/technical/displays.js +++ b/js/technical/displays.js @@ -52,7 +52,7 @@ function achievementStyle(layer, id){ function updateWidth() { let screenWidth = window.innerWidth let splitScreen = screenWidth >= 1024 - if (player.forceOneTab) splitScreen = false + if (options.forceOneTab) splitScreen = false if (player.navTab == "none") splitScreen = true tmp.other.screenWidth = screenWidth tmp.other.screenHeight = window.innerHeight diff --git a/js/technical/systemComponents.js b/js/technical/systemComponents.js index 9fc4f18..61f6c3c 100644 --- a/js/technical/systemComponents.js +++ b/js/technical/systemComponents.js @@ -153,22 +153,22 @@ var systemComponents = { - + - + - - + + - - + +
` }, @@ -187,10 +187,10 @@ var systemComponents = { }, 'node-mark': { - props: ['layer', 'data', 'offset', 'scale'], + props: {'layer': {}, data: {}, offset: {default: 0}, scale: {default: 1}}, template: `
-
-
+
+
` }, @@ -211,7 +211,7 @@ var systemComponents = { 'bg': { props: ['layer'], - template: `
+ template: `
` } diff --git a/js/utils.js b/js/utils.js index ff7adc2..d3d5bb2 100644 --- a/js/utils.js +++ b/js/utils.js @@ -233,13 +233,7 @@ function subtabResetNotify(layer, family, id) { } function nodeShown(layer) { - if (layerShown(layer)) return true - switch (layer) { - case "idk": - return player.idk.unlocked - break; - } - return false + return layerShown(layer) } function layerunlocked(layer) { @@ -250,7 +244,6 @@ function layerunlocked(layer) { function keepGoing() { player.keepGoing = true; needCanvasUpdate = true; - showTab(player.lastSafeTab) } function toNumber(x) { diff --git a/js/utils/options.js b/js/utils/options.js index ca8d8ad..5361011 100644 --- a/js/utils/options.js +++ b/js/utils/options.js @@ -1,9 +1,26 @@ // ************ Options ************ + +let options = {} + +function getStartOptions() { + return { + autosave: true, + msDisplay: "always", + theme: null, + hqTree: false, + offlineProd: true, + hideChallenges: false, + showStory: true, + forceOneTab: false, + oldStyle: false, + } +} + function toggleOpt(name) { if (name == "oldStyle" && styleCooldown > 0) return; - player[name] = !player[name]; + options[name] = !options[name]; if (name == "hqTree") changeTreeQuality(); if (name == "oldStyle") @@ -13,11 +30,11 @@ var styleCooldown = 0; function updateStyle() { styleCooldown = 1; let css = document.getElementById("styleStuff"); - css.href = player.oldStyle ? "oldStyle.css" : "style.css"; + css.href = options.oldStyle ? "oldStyle.css" : "style.css"; needCanvasUpdate = true; } function changeTreeQuality() { - var on = player.hqTree; + var on = options.hqTree; document.body.style.setProperty('--hqProperty1', on ? "2px solid" : "4px solid"); document.body.style.setProperty('--hqProperty2a', on ? "-4px -4px 4px rgba(0, 0, 0, 0.25) inset" : "-4px -4px 4px rgba(0, 0, 0, 0) inset"); document.body.style.setProperty('--hqProperty2b', on ? "0px 0px 20px var(--background)" : ""); @@ -33,13 +50,13 @@ const MS_DISPLAYS = ["ALL", "LAST, AUTO, INCOMPLETE", "AUTOMATION, INCOMPLETE", const MS_SETTINGS = ["always", "last", "automation", "incomplete", "never"]; function adjustMSDisp() { - player.msDisplay = MS_SETTINGS[(MS_SETTINGS.indexOf(player.msDisplay) + 1) % 5]; + options.msDisplay = MS_SETTINGS[(MS_SETTINGS.indexOf(options.msDisplay) + 1) % 5]; } function milestoneShown(layer, id) { complete = player[layer].milestones.includes(id); auto = layers[layer].milestones[id].toggles; - switch (player.msDisplay) { + switch (options.msDisplay) { case "always": return true; break; diff --git a/js/utils/save.js b/js/utils/save.js index 0892a33..d7dc728 100644 --- a/js/utils/save.js +++ b/js/utils/save.js @@ -2,27 +2,22 @@ function save() { if (NaNalert) return localStorage.setItem(modInfo.id, btoa(unescape(encodeURIComponent(JSON.stringify(player))))); + localStorage.setItem(modInfo.id+"_options", btoa(unescape(encodeURIComponent(JSON.stringify(options))))); + } function startPlayerBase() { return { tab: layoutInfo.startTab, navTab: (layoutInfo.showTree ? layoutInfo.startNavTab : "none"), time: Date.now(), - autosave: true, notify: {}, - msDisplay: "always", - theme: null, - hqTree: false, - offlineProd: true, versionType: modInfo.id, version: VERSION.num, beta: VERSION.beta, timePlayed: 0, keepGoing: false, hasNaN: false, - hideChallenges: false, - showStory: true, - forceOneTab: false, + points: modInfo.initialStartPoints, subtabs: {}, lastSafeTab: (readData(layoutInfo.showTree) ? "none" : layoutInfo.startTab) @@ -190,11 +185,16 @@ function fixData(defaultData, newData) { } function load() { let get = localStorage.getItem(modInfo.id); - if (get === null || get === undefined) + + if (get === null || get === undefined) { player = getStartPlayer(); - else + options = getStartOptions(); + } + else { player = Object.assign(getStartPlayer(), JSON.parse(decodeURIComponent(escape(atob(get))))); - fixSave(); + fixSave(); + loadOptions(); + } if (player.offlineProd) { if (player.offTime === undefined) @@ -214,6 +214,17 @@ function load() { updateTabFormats() loadVue(); } + +function loadOptions() { + let get2 = localStorage.getItem(modInfo.id+"_options"); + if (get2) + options = Object.assign(getStartOptions(), JSON.parse(decodeURIComponent(escape(atob(get2))))); + else + options = getStartOptions() + + +} + function setupModInfo() { modInfo.changelog = changelog; modInfo.winText = winText ? winText : `Congratulations! You have reached the end and beaten this game, but for now...`; @@ -297,6 +308,6 @@ var saveInterval = setInterval(function () { return; if (gameEnded && !player.keepGoing) return; - if (player.autosave) + if (options.autosave) save(); }, 5000); diff --git a/js/utils/themes.js b/js/utils/themes.js index ab82456..ed28f9e 100644 --- a/js/utils/themes.js +++ b/js/utils/themes.js @@ -6,8 +6,8 @@ const theme_names = { aqua: "Aqua" }; function changeTheme() { - let aqua = player.theme == "aqua"; - colors_theme = colors[player.theme || "default"]; + let aqua = options.theme == "aqua"; + colors_theme = colors[options.theme || "default"]; document.body.style.setProperty('--background', aqua ? "#001f3f" : "#0f0f0f"); document.body.style.setProperty('--background_tooltip', aqua ? "rgba(0, 15, 31, 0.75)" : "rgba(0, 0, 0, 0.75)"); document.body.style.setProperty('--color', aqua ? "#bfdfff" : "#dfdfdf"); @@ -15,15 +15,15 @@ function changeTheme() { document.body.style.setProperty("--locked", aqua ? "#c4a7b3" : "#bf8f8f"); } function getThemeName() { - return player.theme ? theme_names[player.theme] : "Default"; + return options.theme ? theme_names[options.theme] : "Default"; } function switchTheme() { - if (player.theme === null) - player.theme = themes[1]; + if (options.theme === null) + options.theme = themes[1]; else { - player.theme = themes[Object.keys(themes)[player.theme] + 1]; - if (!player.theme) - player.theme = null; + options.theme = themes[Object.keys(themes)[options.theme] + 1]; + if (!options.theme) + options.theme = null; } changeTheme(); resizeCanvas();