diff options
Diffstat (limited to 'views/script')
-rw-r--r-- | views/script/core_stats.js | 26 | ||||
-rw-r--r-- | views/script/menu_login.js | 10 | ||||
-rw-r--r-- | views/script/settings_global.js | 119 | ||||
-rw-r--r-- | views/script/settings_load.js | 2 |
4 files changed, 17 insertions, 140 deletions
diff --git a/views/script/core_stats.js b/views/script/core_stats.js index a49851d..c8d26df 100644 --- a/views/script/core_stats.js +++ b/views/script/core_stats.js @@ -1,31 +1,5 @@ const fs = require('fs'); const homedir = require('@electron/remote').getCurrentWindow().homedir; -const defaultStats = { - times: { - single: 0, - local: 0, - online: 0 - }, - results: { - wins: 0, - loses: 0 - }, - ingame: { - walls: 0, - laps: 0, - turns: 0 - } -} - -if (!fs.existsSync(homedir + "/.kartik/stats.json")) { - fs.writeFileSync(homedir + "/.kartik/stats.json", JSON.stringify(defaultStats)); -} else { - try { - JSON.parse(fs.readFileSync(homedir + "/.kartik/stats.json").toString()); - } catch (e) { - fs.writeFileSync(homedir + "/.kartik/stats.json", JSON.stringify(defaultStats)); - } -} session = null; timer = null; diff --git a/views/script/menu_login.js b/views/script/menu_login.js index b0a31e9..7f50101 100644 --- a/views/script/menu_login.js +++ b/views/script/menu_login.js @@ -53,7 +53,8 @@ function startLogin() { console.log(playerData); loggingIn = false; document.getElementById('loggingIn').style.display = "none"; - require('fs').writeFileSync(homedir + "/.kartik/authentication.json", JSON.stringify(playerData)); + currentNest.auth = playerData; + Nest.export(homedir + "/.kartik/current.kfn", currentNest); keysEnabled = false; require('electron').ipcRenderer.send('prefademusic', ""); $("#box").fadeOut(500); @@ -108,14 +109,14 @@ window.addEventListener('load', () => { }) function postOnlineMode() { - if (!require('fs').existsSync(homedir + "/.kartik/authentication.json") || !onlineMode) { + if (currentNest.auth === null || !onlineMode) { $(document).keydown(function(e) { if (e.keyCode === 76 && !loggingIn && onlineMode) { startLogin(); } }) } else { - authData = JSON.parse(require('fs').readFileSync(homedir + "/.kartik/authentication.json")); + authData = currentNest.auth; document.getElementById('loginIntro').style.display = "none"; document.getElementById('loginUser').style.display = "grid"; @@ -141,7 +142,8 @@ function postOnlineMode() { async: false, error: (e) => { throw e; } }).responseText.trim() - 1 + 1; - fs.writeFileSync(homedir + "/.kartik/authentication.json", JSON.stringify(authData)); + currentNest.auth = authData; + Nest.export(homedir + "/.kartik/current.kfn", currentNest); } document.getElementById('kto-picture').src = authData.picture; diff --git a/views/script/settings_global.js b/views/script/settings_global.js index f224ea9..e284585 100644 --- a/views/script/settings_global.js +++ b/views/script/settings_global.js @@ -45,73 +45,23 @@ $(document).keydown(function(e) { if (id === "musicb") { if (document.getElementById("setting-music").innerText === "1") { document.getElementById("setting-music").innerText = "0"; - require('fs').writeFileSync(homedir + "/.kartik/config/music.txt", "0"); + currentNest.config.music = false; + Nest.export(homedir + "/.kartik/current.kfn", currentNest); } else { document.getElementById("setting-music").innerText = "1"; - require('fs').writeFileSync(homedir + "/.kartik/config/music.txt", "1"); + currentNest.config.music = true; + Nest.export(homedir + "/.kartik/current.kfn", currentNest); } } if (id === "voice") { if (document.getElementById("setting-voice").innerText === "1") { document.getElementById("setting-voice").innerText = "0"; - require('fs').writeFileSync(homedir + "/.kartik/config/voice.txt", "0"); + currentNest.config.music = false; + Nest.export(homedir + "/.kartik/current.kfn", currentNest); } else { document.getElementById("setting-voice").innerText = "1"; - require('fs').writeFileSync(homedir + "/.kartik/config/voice.txt", "2"); - } - } - if (id === "zoom") { - zoom = document.getElementById("setting-zoom").innerText; - - switch (zoom) { - case "0.9": - document.getElementById("setting-zoom").innerText = "1"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1"); - break; - case "1": - document.getElementById("setting-zoom").innerText = "1.1"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.1"); - break; - case "1.1": - document.getElementById("setting-zoom").innerText = "1.2"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.2"); - break; - case "1.2": - document.getElementById("setting-zoom").innerText = "1.3"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.3"); - break; - case "1.3": - document.getElementById("setting-zoom").innerText = "1.4"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.4"); - break; - case "1.4": - document.getElementById("setting-zoom").innerText = "1.5"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.5"); - break; - case "1.5": - document.getElementById("setting-zoom").innerText = "1.6"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.6"); - break; - case "1.6": - document.getElementById("setting-zoom").innerText = "1.7"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.7"); - break; - case "1.7": - document.getElementById("setting-zoom").innerText = "1.8"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.8"); - break; - case "1.8": - document.getElementById("setting-zoom").innerText = "1.9"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.9"); - break; - case "1.9": - document.getElementById("setting-zoom").innerText = "2"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "2"); - break; - case "2": - document.getElementById("setting-zoom").innerText = "0.9"; - require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "0.9"); - break; + currentNest.config.music = true; + Nest.export(homedir + "/.kartik/current.kfn", currentNest); } } if (id === "lang") { @@ -135,59 +85,10 @@ $(document).keydown(function(e) { if (ci !== -1 && ni !== -1) { document.getElementById("setting-lang").innerText = slng[slst[ni]]; - require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", slst[ni]); + currentNest.config.lang = slst[ni]; + Nest.export(homedir + "/.kartik/current.kfn", currentNest); require('@electron/remote').getCurrentWindow().lp = slst[ni]; } - - /*switch (lang) { - case "Français": - document.getElementById("setting-lang").innerText = "English"; - require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "en"); - require('@electron/remote').getCurrentWindow().lp = "en"; - break; - - case "English": - document.getElementById("setting-lang").innerText = "Español"; - require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "es"); - require('@electron/remote').getCurrentWindow().lp = "es"; - break; - - case "Español": - document.getElementById("setting-lang").innerText = "中国人"; - require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "zh"); - require('@electron/remote').getCurrentWindow().lp = "zh"; - break; - - case "中国人": - document.getElementById("setting-lang").innerText = "日本語"; - require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "jp"); - require('@electron/remote').getCurrentWindow().lp = "jp"; - break; - - case "日本語": - document.getElementById("setting-lang").innerText = "русский"; - require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "ru"); - require('@electron/remote').getCurrentWindow().lp = "ru"; - break; - - case "русский": - document.getElementById("setting-lang").innerText = "Deutsche"; - require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "de"); - require('@electron/remote').getCurrentWindow().lp = "de"; - break; - - case "Deutsche": - document.getElementById("setting-lang").innerText = "Nederlands"; - require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "nl"); - require('@electron/remote').getCurrentWindow().lp = "nl"; - break; - - case "Nederlands": - document.getElementById("setting-lang").innerText = "Français"; - require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "fr"); - require('@electron/remote').getCurrentWindow().lp = "fr"; - break; - }*/ } } if (e.keyCode === 27 || e.keyCode === 8) { // esc diff --git a/views/script/settings_load.js b/views/script/settings_load.js index 030a7dd..b15b125 100644 --- a/views/script/settings_load.js +++ b/views/script/settings_load.js @@ -9,7 +9,7 @@ if (require('@electron/remote').getCurrentWindow().music) { document.getElementById("setting-music").innerText = "0"; } -if (require('fs').readFileSync(homedir + "/.kartik/config/voice.txt").toString() === "2") { +if (currentNest.config.voice === true) { document.getElementById("setting-voice").innerText = "1"; } else { document.getElementById("setting-voice").innerText = "0"; |