aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinteck <46352972+Minteck@users.noreply.github.com>2021-07-14 01:12:14 +0200
committerMinteck <46352972+Minteck@users.noreply.github.com>2021-07-14 01:12:14 +0200
commit0f0e3de9353c06dfaabc00682b4c2fd9c5f48924 (patch)
treeaef2474d205aea7865f7c9a4f17ffee474bbe7bc
parentc3b756f987ffd8ca981c1e6f23435c74aad36aea (diff)
downloadkartik-client-0f0e3de9353c06dfaabc00682b4c2fd9c5f48924.tar.gz
kartik-client-0f0e3de9353c06dfaabc00682b4c2fd9c5f48924.tar.bz2
kartik-client-0f0e3de9353c06dfaabc00682b4c2fd9c5f48924.zip
Kartik Fox Nest!
-rw-r--r--app.js95
-rw-r--r--converted.kfnbin0 -> 5509 bytes
-rw-r--r--crash/wrapper.js4
-rw-r--r--default.kfn2
-rw-r--r--nest/abi.js86
-rw-r--r--test.kfnbin0 -> 40 bytes
-rw-r--r--views/credits.html2
-rw-r--r--views/game.html2
-rw-r--r--views/intro.html2
-rw-r--r--views/loader.html2
-rw-r--r--views/menu.html2
-rw-r--r--views/online.html2
-rw-r--r--views/script/core_stats.js26
-rw-r--r--views/script/menu_login.js10
-rw-r--r--views/script/settings_global.js119
-rw-r--r--views/script/settings_load.js2
-rw-r--r--views/settings.html2
-rw-r--r--views/stats.html4
-rw-r--r--views/win.html2
19 files changed, 167 insertions, 197 deletions
diff --git a/app.js b/app.js
index 30b2439..be9900e 100644
--- a/app.js
+++ b/app.js
@@ -49,6 +49,18 @@ const { app, BrowserWindow } = require('electron');
dlp = "en";
}
+ if (!require('fs').existsSync(require('os').userInfo().homedir + "/.kartik")) {
+ require('fs').mkdirSync(require('os').userInfo().homedir + "/.kartik")
+ }
+
+ if (!require('fs').existsSync(require('os').userInfo().homedir + "/.kartik/crashes")) {
+ require('fs').mkdirSync(require('os').userInfo().homedir + "/.kartik/crashes")
+ }
+
+ if (!require('fs').existsSync(require('os').userInfo().homedir + "/.kartik/mods")) {
+ require('fs').mkdirSync(require('os').userInfo().homedir + "/.kartik/mods")
+ }
+
process.on('uncaughtException', (error) => {
console.log(" * Starting recovery procedure: E_ERROR");
id = new Date().toISOString().replaceAll(":", "-");
@@ -84,8 +96,9 @@ const { app, BrowserWindow } = require('electron');
console.log(" * Creating configuration");
const fs = require('fs');
+ const Nest = require('./nest/abi');
- if (!fs.existsSync(homedir + "/.kartik")) {
+ /*if (!fs.existsSync(homedir + "/.kartik")) {
fs.mkdirSync(homedir + "/.kartik");
}
if (!fs.existsSync(homedir + "/.kartik/config")) {
@@ -118,8 +131,24 @@ const { app, BrowserWindow } = require('electron');
}
if (!fs.existsSync(homedir + "/.kartik/config/voice.txt")) {
fs.writeFileSync(homedir + "/.kartik/config/voice.txt", "0");
+ }*/
+
+ if (fs.existsSync(homedir + "/.kartik/config") && fs.existsSync(homedir + "/.kartik/config/voice.txt") && fs.existsSync(homedir + "/.kartik/config/online.txt") && fs.existsSync(homedir + "/.kartik/config/music.txt") && fs.existsSync(homedir + "/.kartik/config/lang.txt") && fs.existsSync(homedir + "/.kartik/stats.json")) {
+ console.log(" * Found complete Config V1, migrating to Kartik Fox Nest...");
+ Nest.convert(homedir + "/.kartik/current.kfn", homedir + "/.kartik");
+ } else {
+ if (!fs.existsSync(homedir + "/.kartik/current.kfn")) {
+ console.log(" * No Kartik Fox Nest found, generating one...");
+ Nest.generate(homedir + "/.kartik/current.kfn");
+ }
}
+ global.currentNest = Nest.load(homedir + "/.kartik/current.kfn");
+ console.log(" * Kartik Fox Nest loaded, " + fs.readFileSync(homedir + "/.kartik/current.kfn").toString().length + " bytes, last loaded in Kartik " + currentNest._version);
+
+ currentNest._version = require('./package.json').version;
+ Nest.export(homedir + "/.kartik/current.kfn", currentNest);
+
/* --------------------- */
console.log(" * Checking channel");
@@ -165,29 +194,7 @@ const { app, BrowserWindow } = require('electron');
console.log(" * Checking configuration");
- scale = fs.readFileSync(homedir + "/.kartik/config/scale.txt").toString().trim() - 1 + 1
- lp = fs.readFileSync(homedir + "/.kartik/config/lang.txt").toString().trim()
-
- if (fs.readFileSync(homedir + "/.kartik/config/online.txt").toString().trim() === "0") {
- fs.writeFileSync(homedir + "/.kartik/config/online.txt", "1");
- }
-
- if (scale !== 1
- && scale !== 0.9
- && scale !== 1.1
- && scale !== 1.2
- && scale !== 1.3
- && scale !== 1.4
- && scale !== 1.5
- && scale !== 1.6
- && scale !== 1.7
- && scale !== 1.8
- && scale !== 1.9
- && scale !== 2
- ) {
- fs.writeFileSync(homedir + "/.kartik/config/scale.txt", "1.2");
- scale = 1;
- }
+ lp = currentNest.config.lang
time = new Date() - start;
console.log(" * Started successfully in " + Math.round(time/1000) + " seconds");
@@ -195,10 +202,10 @@ const { app, BrowserWindow } = require('electron');
load.close();
console.log(" * Starting recovery procedure: E_PROMISE");
global.win = new BrowserWindow({
- width: Math.round(720 * scale),
- height: Math.round(540 * scale),
- minWidth: Math.round(720 * scale),
- minHeight: Math.round(540 * scale),
+ width: 1220,
+ height: 720,
+ minWidth: 720,
+ minHeight: 540,
resizeable: true,
resizable: true,
maximizable: true,
@@ -218,14 +225,14 @@ const { app, BrowserWindow } = require('electron');
global.shouldExitIfClosed = true;
-
console.log(" * Starting IPC engine");
- win.pwidth = Math.round(720 * scale);
- win.pheight = Math.round(540 * scale);
+ win.pwidth = 720;
+ win.pheight = 540;
win.log = console.log;
win.debug = process.argv[2] === "d";
win.channel = channel;
+ win.scale = 1.2;
win.update = dimga;
win.gamepads = [];
win.controllerAttached = false;
@@ -236,12 +243,12 @@ const { app, BrowserWindow } = require('electron');
win.homedir = homedir;
- win.scale = scale;
win.lp = lp;
- win.music = fs.readFileSync(homedir + "/.kartik/config/music.txt").toString().trim() === "1";
- win.voice = fs.readFileSync(homedir + "/.kartik/config/voice.txt").toString().trim() === "2";
+ win.music = currentNest.config.music;
+ win.voice = currentNest.config.voice;
- win.online = fs.readFileSync(homedir + "/.kartik/config/online.txt").toString().trim() === "1";
+ win.online = currentNest.config.online;
+ win.nest = currentNest;
win.resources = resources;
global.currentSongValue = null;
@@ -273,18 +280,18 @@ const { app, BrowserWindow } = require('electron');
const LevelsAPI = require('./views/script/global_levelsapi');
const lvl = new LevelsAPI();
- stats = require(homedir + "/.kartik/stats.json");
+ stats = currentNest.stats;
musicIpc.on('addstats', (event, value) => {
- stats[value.catalog][value.key] = stats[value.catalog][value.key] + value.add;
- fs.writeFile(homedir + "/.kartik/stats.json", JSON.stringify(stats), () => {});
+ currentNest.stats[value.catalog][value.key] = currentNest.stats[value.catalog][value.key] + value.add;
+ Nest.export(homedir + "/.kartik/current.kfn", currentNest);
if (value.key === "laps" && fs.existsSync(homedir + "/.kartik/authentication.json")) {
- auth = JSON.parse(fs.readFileSync(homedir + "/.kartik/authentication.json").toString());
- level = lvl.correspond(stats["ingame"]["laps"], "256") - 1 + 1;
+ auth = currentNest.auth;
+ level = lvl.correspond(currentNest.stats["ingame"]["laps"], "256") - 1 + 1;
if (level !== auth.level) {
- auth.level = level
- fs.writeFileSync(homedir + "/.kartik/authentication.json", JSON.stringify(auth));
+ currentNest.auth.level = level
+ Nest.export(homedir + "/.kartik/current.kfn", currentNest);
if (level < 200) {
win.webContents.send("notification", {title: lang.polymer.levelup[0], message: lang.polymer.levelup[1] + " " + level + " " + lang.polymer.levelup[2]});
} else {
@@ -294,8 +301,8 @@ const { app, BrowserWindow } = require('electron');
}
})
musicIpc.on('addstatsandclose', (event, value) => {
- stats[value.catalog][value.key] = stats[value.catalog][value.key] + value.add;
- fs.writeFile(homedir + "/.kartik/stats.json", JSON.stringify(stats), () => {});
+ currentNest.stats[value.catalog][value.key] = currentNest.stats[value.catalog][value.key] + value.add;
+ Nest.export(homedir + "/.kartik/current.kfn", currentNest);
win.destroy();
})
})
diff --git a/converted.kfn b/converted.kfn
new file mode 100644
index 0000000..18f7f1a
--- /dev/null
+++ b/converted.kfn
Binary files differ
diff --git a/crash/wrapper.js b/crash/wrapper.js
index ba5a8b9..16ecfd9 100644
--- a/crash/wrapper.js
+++ b/crash/wrapper.js
@@ -1,8 +1,6 @@
const { app, BrowserWindow } = require('electron')
-if (require('fs').existsSync(require('os').userInfo().homedir + "/.kartik/config/lang.txt")) {
- lp = require('fs').readFileSync(require('os').userInfo().homedir + "/.kartik/config/lang.txt").toString();
-}
+lp = "en";
function createWindow () {
const win = new BrowserWindow({
diff --git a/default.kfn b/default.kfn
new file mode 100644
index 0000000..ca27412
--- /dev/null
+++ b/default.kfn
@@ -0,0 +1,2 @@
+xEKs0R3.\)8IG.fi 74Z_.9ߑ5n;kNj٤9 HҥR2#oKn(Ri? /٦]Əٵ){Zv]y'ŜʵP8{ae vb ݰ#]4OT까V͝"'di>
+yеhV#AK7$Xo "~z \ No newline at end of file
diff --git a/nest/abi.js b/nest/abi.js
new file mode 100644
index 0000000..b72f964
--- /dev/null
+++ b/nest/abi.js
@@ -0,0 +1,86 @@
+const fs = require('fs');
+var zlib = require('zlib');
+
+module.exports = {
+ export(file, obj) {
+ fs.writeFileSync(file, zlib.deflateSync(Buffer.from(Buffer.from(JSON.stringify(obj)).toString("base64")).toString("base64")))
+ },
+
+ load(file) {
+ data = fs.readFileSync(file)
+ uncomp = zlib.inflateSync(data);
+
+ b1 = Buffer.from(uncomp, "base64").toString("utf-8");
+ b2 = Buffer.from(b1, "base64").toString("utf-8");
+
+ item = Buffer.from(b2, "base64").toString("utf-8");
+ decoded = JSON.parse(item);
+
+ return decoded;
+ },
+
+ async generate(file) {
+ o = {
+ "_version": "<unknown>",
+ "stats": {
+ "times": {
+ "single": 0,
+ "local": 0,
+ "online": 0
+ },
+ "results": {
+ "wins": 0,
+ "loses": 0
+ },
+ "ingame": {
+ "walls": 0,
+ "laps": 0,
+ "turns": 0
+ }
+ },
+ "auth": null,
+ "config": {
+ "lang": null,
+ "music": true,
+ "online": true,
+ "voice": false
+ }
+ }
+
+ slpm = require('os-locale');
+ slpw = await slpm();
+ slpo = slpw.substr(0, 2);
+ slng = require('../lang/languages.json');
+ if (Object.keys(slng).includes(slpo)) {
+ dlp = slpo;
+ } else {
+ dlp = "en";
+ }
+
+ o.config.lang = dlp;
+
+ this.export(file, o);
+ },
+
+ convert(file, dotkartik) {
+ if (fs.existsSync(dotkartik + "/authentication.json")) {
+ auth = JSON.parse(fs.readFileSync(dotkartik + "/authentication.json"));
+ } else {
+ auth = null;
+ }
+
+ o = {
+ "_version": "<unknown>",
+ "stats": JSON.parse(fs.readFileSync(dotkartik + "/stats.json").toString()),
+ "auth": auth,
+ "config": {
+ "lang": fs.readFileSync(dotkartik + "/config/lang.txt").toString().trim(),
+ "music": fs.readFileSync(dotkartik + "/config/music.txt").toString().trim() === "1",
+ "online": fs.readFileSync(dotkartik + "/config/online.txt").toString().trim() === "1",
+ "voice": fs.readFileSync(dotkartik + "/config/voice.txt").toString().trim() === "1"
+ }
+ }
+
+ this.export(file, o);
+ }
+} \ No newline at end of file
diff --git a/test.kfn b/test.kfn
new file mode 100644
index 0000000..a307fda
--- /dev/null
+++ b/test.kfn
Binary files differ
diff --git a/views/credits.html b/views/credits.html
index ece63a3..b045ed4 100644
--- a/views/credits.html
+++ b/views/credits.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};</script>
+ <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};const Nest = require("../nest/abi");currentNest = require('@electron/remote').getCurrentWindow().nest;</script>
<script src="../lang/loader.js"></script>
<script src="../scenario/client.js"></script>
<meta charset="UTF-8">
diff --git a/views/game.html b/views/game.html
index ca402a5..cefd720 100644
--- a/views/game.html
+++ b/views/game.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};</script>
+ <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};const Nest = require("../nest/abi");currentNest = require('@electron/remote').getCurrentWindow().nest;</script>
<script src="../lang/loader.js"></script>
<script src="../scenario/client.js"></script>
<meta charset="UTF-8">
diff --git a/views/intro.html b/views/intro.html
index 6d4b721..d09ee15 100644
--- a/views/intro.html
+++ b/views/intro.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en" style="background:#000000;margin:0;height:100%;width:100%;">
<head>
- <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};</script>
+ <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};const Nest = require("../nest/abi");currentNest = require('@electron/remote').getCurrentWindow().nest;</script>
<script src="../lang/loader.js"></script>
<script src="../scenario/client.js"></script>
<meta charset="UTF-8">
diff --git a/views/loader.html b/views/loader.html
index df008d4..f18edd4 100644
--- a/views/loader.html
+++ b/views/loader.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en" style="background:#000000;margin:0;height:100%;width:100%;">
<head>
- <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};</script>
+ <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};const Nest = require("../nest/abi");currentNest = require('@electron/remote').getCurrentWindow().nest;</script>
<script src="../lang/loader.js"></script>
<script src="../scenario/client.js"></script>
<meta charset="UTF-8">
diff --git a/views/menu.html b/views/menu.html
index 26e79db..b2a0129 100644
--- a/views/menu.html
+++ b/views/menu.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};</script>
+ <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};const Nest = require("../nest/abi");currentNest = require('@electron/remote').getCurrentWindow().nest;</script>
<script src="../lang/loader.js"></script>
<script src="../scenario/client.js"></script>
<meta charset="UTF-8">
diff --git a/views/online.html b/views/online.html
index ac90e7e..cd1cff5 100644
--- a/views/online.html
+++ b/views/online.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en" style="background:#000000;margin:0;height:100%;width:100%;">
<head>
- <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};</script>
+ <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};const Nest = require("../nest/abi");currentNest = require('@electron/remote').getCurrentWindow().nest;</script>
<script src="../lang/loader.js"></script>
<script src="../scenario/client.js"></script>
<meta charset="UTF-8">
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";
diff --git a/views/settings.html b/views/settings.html
index 1759d25..4799527 100644
--- a/views/settings.html
+++ b/views/settings.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};</script>
+ <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};const Nest = require("../nest/abi");currentNest = require('@electron/remote').getCurrentWindow().nest;</script>
<script src="../lang/loader.js"></script>
<script src="../scenario/client.js"></script>
<meta charset="UTF-8">
diff --git a/views/stats.html b/views/stats.html
index 018e164..92183ab 100644
--- a/views/stats.html
+++ b/views/stats.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en" style="background:#000000;margin:0;height:100%;width:100%;">
<head>
- <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};</script>
+ <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};const Nest = require("../nest/abi");currentNest = require('@electron/remote').getCurrentWindow().nest;</script>
<script src="../lang/loader.js"></script>
<script src="../scenario/client.js"></script>
<meta charset="UTF-8">
@@ -29,7 +29,7 @@
<div id="box" style="display: none;background:#222;position:fixed;top:0;left:0;right:0;bottom:0;">
<div style="position:fixed;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center;">
<div style="text-align: center;">
- <h2><script>let homedir = require('@electron/remote').getCurrentWindow().homedir;document.write(lang.stats.title);stats=require(homedir + "/.kartik/stats.json")</script></h2>
+ <h2><script>let homedir = require('@electron/remote').getCurrentWindow().homedir;document.write(lang.stats.title);stats=currentNest.stats</script></h2>
<div style="display:grid;grid-template-columns: 1fr 1fr;">
<div style="padding:10px;text-align:left;"><b><script>document.write(lang.stats.items['times.single'])</script></b></div>
diff --git a/views/win.html b/views/win.html
index a3cdfb5..9b0cafb 100644
--- a/views/win.html
+++ b/views/win.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en" style="background:#000000;margin:0;height:100%;width:100%;">
<head>
- <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};</script>
+ <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};const Nest = require("../nest/abi");currentNest = require('@electron/remote').getCurrentWindow().nest;</script>
<script src="../lang/loader.js"></script>
<script src="../scenario/client.js"></script>
<meta charset="UTF-8">