summaryrefslogtreecommitdiff
path: root/kartik/views/script
diff options
context:
space:
mode:
Diffstat (limited to 'kartik/views/script')
-rwxr-xr-xkartik/views/script/client_fullscreen.js9
-rwxr-xr-xkartik/views/script/core_chart.js74
-rwxr-xr-xkartik/views/script/core_compatlayer.js0
-rwxr-xr-xkartik/views/script/core_crash.js15
-rwxr-xr-xkartik/views/script/core_fullscreen.js0
-rwxr-xr-xkartik/views/script/core_head.js31
-rwxr-xr-xkartik/views/script/core_music.js35
-rwxr-xr-xkartik/views/script/core_notification.js12
-rwxr-xr-xkartik/views/script/core_viewer.js33
-rwxr-xr-xkartik/views/script/credits_global.js54
-rwxr-xr-xkartik/views/script/credits_libs.js0
-rwxr-xr-xkartik/views/script/credits_music.js2
-rwxr-xr-xkartik/views/script/credits_technical.js12
-rwxr-xr-xkartik/views/script/game_debug.js138
-rwxr-xr-xkartik/views/script/game_global.js45
-rwxr-xr-xkartik/views/script/game_music.js8
-rwxr-xr-xkartik/views/script/game_online.js9
-rwxr-xr-xkartik/views/script/game_select.js131
-rwxr-xr-xkartik/views/script/global_compatlayer.js0
-rwxr-xr-xkartik/views/script/global_levelsapi.js47
-rwxr-xr-xkartik/views/script/intro_global.js21
-rwxr-xr-xkartik/views/script/intro_media.js2
-rwxr-xr-xkartik/views/script/intro_message.js7
-rwxr-xr-xkartik/views/script/loader_global.js132
-rwxr-xr-xkartik/views/script/menu_copyright.js5
-rwxr-xr-xkartik/views/script/menu_global.js127
-rwxr-xr-xkartik/views/script/menu_gpuinfo.js0
-rwxr-xr-xkartik/views/script/menu_login.js1
-rwxr-xr-xkartik/views/script/menu_music.js5
-rwxr-xr-xkartik/views/script/menu_system.js33
-rwxr-xr-xkartik/views/script/online_play.js2
-rwxr-xr-xkartik/views/script/settings_global.js104
-rwxr-xr-xkartik/views/script/settings_load.js10
-rwxr-xr-xkartik/views/script/win_global.js22
-rwxr-xr-xkartik/views/script/win_message.js9
-rwxr-xr-xkartik/views/script/win_music.js2
-rwxr-xr-xkartik/views/script/win_play.js0
-rwxr-xr-xkartik/views/script/win_quit.js0
38 files changed, 1137 insertions, 0 deletions
diff --git a/kartik/views/script/client_fullscreen.js b/kartik/views/script/client_fullscreen.js
new file mode 100755
index 0000000..80d745c
--- /dev/null
+++ b/kartik/views/script/client_fullscreen.js
@@ -0,0 +1,9 @@
+document.addEventListener('keydown', function(e) {
+ if (e.key === "F1" || e.key === "F10" || e.key === "F11") { // F11/F1/F10
+ if (!require('@electron/remote').getCurrentWindow().fullScreen && require('@electron/remote').getCurrentWindow().fullScreenable) {
+ require('@electron/remote').getCurrentWindow().setFullScreen(true);
+ } else {
+ require('@electron/remote').getCurrentWindow().setFullScreen(false);
+ }
+ }
+}) \ No newline at end of file
diff --git a/kartik/views/script/core_chart.js b/kartik/views/script/core_chart.js
new file mode 100755
index 0000000..2f8a521
--- /dev/null
+++ b/kartik/views/script/core_chart.js
@@ -0,0 +1,74 @@
+setInterval(() => {
+ try {
+ currentMemory = process.memoryUsage().rss;
+ currentMemoryMib = (((currentMemory)/1024)/1024).toFixed(2);
+ if ((((currentMemory)/1024)/1024) > ((require('os').totalmem() / 1000000) / 4)) {
+ throw new Error("Out of memory");
+ }
+
+ file = webview.getURL().split("/")[webview.getURL().split("/").length - 1];
+ activity = lang.discord.game[0];
+ enableActivity = false;
+ eaid = "";
+
+ switch (file) {
+ case "game.html?online":
+ enableActivity = true;
+ activity = lang.online.discord;
+ break;
+ case "game.html?sp":
+ enableActivity = true;
+ activity = lang.discord.game[1];
+ break;
+ case "game.html":
+ enableActivity = true;
+ activity = lang.discord.game[2];
+ break;
+ case "intro.html":
+ enableActivity = true;
+ activity = lang.discord.intro[1];
+ break;
+ case "settings.html":
+ case "stats.html":
+ enableActivity = true;
+ activity = lang.discord.settings[1];
+ break;
+ case "credits.html":
+ enableActivity = true;
+ activity = lang.discord.credits[1];
+ break;
+ case "online.html":
+ enableActivity = true;
+ activity = lang.online.discord2;
+ break;
+ case "menu.html":
+ case "win.html":
+ enableActivity = true;
+ activity = lang.discord.credits[0];
+ break;
+ case "loader.html":
+ enableActivity = false;
+ break;
+ }
+
+ if (file.includes("online.html")) {
+ activity = lang.online.discord2;
+ }
+
+ if (enableActivity) {
+ eaid = " - " + activity;
+ } else {
+ eaid = "";
+ }
+
+ if (require('./package.json').channel === "git") {
+ document.title="Kartik Trunk " +require('./package.json').version;
+ } else {
+ document.title="Kartik"+require('@electron/remote').getCurrentWindow().channel+require('./package.json').version + eaid;
+ }
+ } catch (e) {
+ if (e.message === "Out of memory") {
+ throw e;
+ }
+ }
+}, 1000) \ No newline at end of file
diff --git a/kartik/views/script/core_compatlayer.js b/kartik/views/script/core_compatlayer.js
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/kartik/views/script/core_compatlayer.js
diff --git a/kartik/views/script/core_crash.js b/kartik/views/script/core_crash.js
new file mode 100755
index 0000000..cc68b18
--- /dev/null
+++ b/kartik/views/script/core_crash.js
@@ -0,0 +1,15 @@
+global.gameCrashed = false;
+crashSound = new Audio("./sfx/gamecrash.wav");
+
+function destroy() {
+ global.gameCrashed = true;
+ crashSound.play();
+ document.getElementById("wb").outerHTML = "";
+ try { musicElement.pause(); } catch (e) {}
+}
+
+function spawnError(crashReport) {
+ document.getElementById("error-outer").style.display = "flex";
+ document.getElementById("crash-dump").value = crashReport;
+ destroy();
+} \ No newline at end of file
diff --git a/kartik/views/script/core_fullscreen.js b/kartik/views/script/core_fullscreen.js
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/kartik/views/script/core_fullscreen.js
diff --git a/kartik/views/script/core_head.js b/kartik/views/script/core_head.js
new file mode 100755
index 0000000..be27c87
--- /dev/null
+++ b/kartik/views/script/core_head.js
@@ -0,0 +1,31 @@
+if (native) {global.$ = require('jquery');} else {var script = document.createElement('script');script.src = './webinit/jquery.js';script.type = 'text/javascript';document.getElementsByTagName('head')[0].appendChild(script);}
+
+if (native && require('@electron/remote').getCurrentWindow().debug) {
+ document.write('<link rel="stylesheet" href="' + atob("Li92aWV3cy9jb21tb24vZGVidWcuY3Nz") + '">');
+}
+
+if (native) {
+ var ipcRenderer = require('electron').ipcRenderer;
+ ipcRenderer.on('scenario', function (event,obj) {
+ try {
+ console.log(kresources.scenario.voice[obj.lang] + "/" + obj.namespace + obj.id + ".mp3");
+ a = new Audio(kresources.scenario.voice[obj.lang] + "/" + obj.namespace + obj.id + ".mp3");
+ a.onended = () => {
+ setTimeout(() => {
+ $("#message").fadeOut(200);
+ if (typeof obj.cb == "function") {
+ obj.cb();
+ }
+ }, 3000)
+ }
+ a.play();
+ } catch (e) {
+ console.error(e);
+ obj.cb();
+ }
+
+ document.getElementById('message-text').innerText = obj.message;
+ document.getElementById('message-character-inner').src = kresources.scenario.averi[obj.emote];
+ $("#message").fadeIn(200);
+ });
+}
diff --git a/kartik/views/script/core_music.js b/kartik/views/script/core_music.js
new file mode 100755
index 0000000..b35f5db
--- /dev/null
+++ b/kartik/views/script/core_music.js
@@ -0,0 +1,35 @@
+if (location.hash === "#ready") {
+ global.musicElement = new Audio();
+
+ global.musicManager = {
+ setMusic: (args) => {
+ musicElement.src = args;
+ musicElement.play();
+ musicElement.volume = 1;
+ musicElement.loop = true;
+ },
+ fadeMusic: () => {
+ if (!musicElement.paused) {
+ csi1 = setInterval(() => {
+ if (musicElement.volume <= 0.3) {
+ clearInterval(csi1);
+ return;
+ }
+ musicElement.volume = musicElement.volume - 0.05;
+ }, 100)
+ }
+ },
+ unfadeMusic: () => {
+ if (!musicElement.paused) {
+ csi1 = setInterval(() => {
+ if (musicElement.volume >= 0.95) {
+ clearInterval(csi1);
+ return;
+ }
+ musicElement.volume = musicElement.volume + 0.05;
+ }, 100)
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/kartik/views/script/core_notification.js b/kartik/views/script/core_notification.js
new file mode 100755
index 0000000..e720006
--- /dev/null
+++ b/kartik/views/script/core_notification.js
@@ -0,0 +1,12 @@
+global.notification = (data) => {
+ document.getElementById("notification-title").innerText = data.title;
+ document.getElementById("notification-message").innerText = data.message;
+ document.getElementById("notification").style.right = "20px";
+ document.getElementById("notification").style.opacity = "1";
+ new Audio("./sfx/notification.mp3").play();
+
+ setTimeout(() => {
+ document.getElementById("notification").style.right = "-300px";
+ document.getElementById("notification").style.opacity = "0";
+ }, 5000)
+}; \ No newline at end of file
diff --git a/kartik/views/script/core_viewer.js b/kartik/views/script/core_viewer.js
new file mode 100755
index 0000000..a538b99
--- /dev/null
+++ b/kartik/views/script/core_viewer.js
@@ -0,0 +1,33 @@
+const webview = document.getElementById('wb');
+
+try {
+ webview.addEventListener('dom-ready', () => {
+ setTimeout(() => {
+ document.getElementById('dummyloader').style.display = "none";
+ }, 5000)
+ require('@electron/remote').getCurrentWindow().log(" * " + webview.getURL());
+ require('@electron/remote').getCurrentWindow().focus();
+ if (location.hash === "#ready") {
+ require('@electron/remote').webContents.fromId(webview.getWebContentsId()).send("ready", true);
+ }
+ webview.focus();
+ try {
+ if (require('@electron/remote').getCurrentWindow().debug) {
+ info("MainWindow", "Opening debugging tools...");
+ webview.openDevTools();
+ }
+ } catch (e) {}
+ })
+
+ webview.addEventListener('dom-ready', () => {
+ setInterval(() => {
+ try {
+ if (webview.isCrashed() && !gameCrashed) {
+ require('@electron/remote').getCurrentWindow().log(" * Compositing engine crashed!");
+ error("MainWindow", "Subcontainer crashed");
+ crash(new Error("Webview crashed"));
+ }
+ } catch (e) {}
+ }, 2000)
+ })
+} catch (e) {} \ No newline at end of file
diff --git a/kartik/views/script/credits_global.js b/kartik/views/script/credits_global.js
new file mode 100755
index 0000000..393293d
--- /dev/null
+++ b/kartik/views/script/credits_global.js
@@ -0,0 +1,54 @@
+let menuOpen = true;
+
+if (native) {global.$ = require('jquery');} else {var script = document.createElement('script');script.src = '../webinit/jquery.js';script.type = 'text/javascript';document.getElementsByTagName('head')[0].appendChild(script);}
+
+keysEnabled = true;
+$(document).keydown(function(e) {
+ if (keysEnabled) {
+ if (e.keyCode === 13 || e.keyCode === 88 || e.keyCode === 32 || e.keyCode === 27 || e.keyCode === 8 || e.keyCode === 16) { // enter/esc
+ keysEnabled = false;
+ Sound.click();
+ window.parent.musicManager.fadeMusic();
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("GWinWindow", "Switching control to MenuWindow");
+ location.href = "menu.html";
+ }, 1000)
+ }
+ }
+})
+
+var currentpos=0,alt=1,curpos1=0,curpos2=-1
+function initialize(){
+ $("#box").fadeIn(500);
+ startit()
+}
+function scrollwindow(){
+ if (document.all)
+ temp=document.body.scrollTop
+ else
+ temp=window.pageYOffset
+ if (alt===0)
+ alt=1
+ else
+ alt=0
+ if (alt===0)
+ curpos1=temp
+ else
+ curpos2=temp
+ if (curpos1!==curpos2){
+ if (document.all)
+ currentpos=document.body.scrollTop+1
+ else
+ currentpos=window.pageYOffset+1
+ window.scroll(0,currentpos)
+ }
+ else{
+ currentpos=0
+ window.scroll(0,currentpos)
+ }
+}
+function startit(){
+ setInterval("scrollwindow()",20)
+}
+window.onload=initialize
diff --git a/kartik/views/script/credits_libs.js b/kartik/views/script/credits_libs.js
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/kartik/views/script/credits_libs.js
diff --git a/kartik/views/script/credits_music.js b/kartik/views/script/credits_music.js
new file mode 100755
index 0000000..7d2f69c
--- /dev/null
+++ b/kartik/views/script/credits_music.js
@@ -0,0 +1,2 @@
+info("MusicMgr", "Playing settings.mp3");
+window.parent.musicManager.setMusic(kresources.music['credits'].file); \ No newline at end of file
diff --git a/kartik/views/script/credits_technical.js b/kartik/views/script/credits_technical.js
new file mode 100755
index 0000000..fda1998
--- /dev/null
+++ b/kartik/views/script/credits_technical.js
@@ -0,0 +1,12 @@
+document.write("Kartik: A New Start");
+document.write(" on " + navigator.userAgent + "<br>")
+if (navigator.hardwareConcurrency > 1 || navigator.hardwareConcurrency === 0) {
+ document.write(navigator.hardwareConcurrency + " processors, ");
+} else {
+ document.write(navigator.hardwareConcurrency + " processor, ");
+}
+if (navigator.maxTouchPoints > 1 || navigator.maxTouchPoints === 0) {
+ document.write(navigator.maxTouchPoints + " touch points<br>");
+} else {
+ document.write(navigator.maxTouchPoints + " touch point<br>");
+} \ No newline at end of file
diff --git a/kartik/views/script/game_debug.js b/kartik/views/script/game_debug.js
new file mode 100755
index 0000000..9d311b3
--- /dev/null
+++ b/kartik/views/script/game_debug.js
@@ -0,0 +1,138 @@
+global.debugshow = false;
+
+function oil(id) {
+ return "\nO" + id +": " + document.getElementById('oil' + id + '').style.left.split("px")[0] + " " + document.getElementById('oil' + id + '').style.top.split("px")[0] + " / " + document.getElementById('oil' + id + '').style.transform.split("rotate(")[1].split("deg)")[0];
+}
+
+$(document).keydown((e) => {
+ if (e.keyCode === 114) { // F3
+ if (debugshow) {
+ global.debugshow = false;
+ document.getElementById("debug").style.display = "none";
+ } else {
+ global.debugshow = true;
+ document.getElementById("debug").style.display = "";
+ }
+ }
+})
+
+gpuperct = 100;
+
+pubver = "prod";
+pvpart = pubver.split(".");
+if (pvpart.length === 3) {
+ intver = pvpart[0] + "." + pvpart[1];
+} else {
+ intver = "unknown";
+}
+
+release = "official";
+
+if (gpuperct < 25) {
+ perf = "fast";
+} else if (gpuperct < 50) {
+ perf = "fancy";
+} else {
+ perf = "fabulous";
+}
+
+if (location.search === "") {
+ game = "Local multiplayer game";
+} else if (location.search === "?sp") {
+ game = "Singleplayer game";
+} else if (location.search === "?online") {
+ game = "Online multiplayer game";
+}
+
+tps = -1;
+cping = -1;
+changedDataLeft = "playing: %false%"
+changedDataRight = ""
+immutableDataLeft = "Kartik " + pubver + " (" + intver + "/trunk+" + release + ")\n%tps% tps T:" + perf + ";vsync\n" + game + " @ %ping% ms ticks";
+immutableDataRight = "Browser: " + navigator.userAgent;
+
+credits = "Debug: start runtime with debug argument\nFor help: https://arcade.minteck.org/kartik"
+
+setInterval(() => {
+ if (!debugshow) { return; }
+
+
+ leftparts = (immutableDataLeft + "\n" + changedDataLeft + "\n\n" + credits).split("\n");
+ lefttext = "<span style='background:rgba(101,101,101,0.75);font-family: &apos;Source Code Pro&apos;, &apos;JetBrains Mono&apos;, &apos;Ubuntu Mono&apos;, &apos;Consolas&apos;, &apos;Lucida Console&apos;, &apos;Courier New&apos;, monospace;padding:1px;'>" + leftparts.join("</span><br><span style='background:rgba(101,101,101,0.75);font-family: &apos;Source Code Pro&apos;, &apos;JetBrains Mono&apos;, &apos;Ubuntu Mono&apos;, &apos;Consolas&apos;, &apos;Lucida Console&apos;, &apos;Courier New&apos;, monospace;padding:1px;'>") + "</span>";
+
+ rightparts = (immutableDataRight + "\n" + changedDataRight).split("\n");
+ righttext = "<span style='background:rgba(101,101,101,0.75);font-family: &apos;Source Code Pro&apos;, &apos;JetBrains Mono&apos;, &apos;Ubuntu Mono&apos;, &apos;Consolas&apos;, &apos;Lucida Console&apos;, &apos;Courier New&apos;, monospace;padding:1px;'>" + rightparts.join("</span><br><span style='background:rgba(101,101,101,0.75);font-family: &apos;Source Code Pro&apos;, &apos;JetBrains Mono&apos;, &apos;Ubuntu Mono&apos;, &apos;Consolas&apos;, &apos;Lucida Console&apos;, &apos;Courier New&apos;, monospace;padding:1px;'>") + "</span>";
+
+ document.getElementById("debug-left").innerHTML = lefttext.replaceAll("%tps%", tps).replaceAll("%ping%", cping).replaceAll("%false%", "<span style='color:red;font-family: &apos;Source Code Pro&apos;, &apos;JetBrains Mono&apos;, &apos;Ubuntu Mono&apos;, &apos;Consolas&apos;, &apos;Lucida Console&apos;, &apos;Courier New&apos;, monospace;'>false</span>").replaceAll("%true%", "<span style='color:green;font-family: &apos;Source Code Pro&apos;, &apos;JetBrains Mono&apos;, &apos;Ubuntu Mono&apos;, &apos;Consolas&apos;, &apos;Lucida Console&apos;, &apos;Courier New&apos;, monospace;'>true</span>");
+ document.getElementById("debug-right").innerHTML = righttext;
+}, 100)
+
+var filterStrength = 20;
+var frameTime = 0, lastLoop = new Date, thisLoop;
+
+setInterval(() => {
+ if (!debugshow) { return; }
+
+ var thisFrameTime = (thisLoop=new Date) - lastLoop;
+ frameTime+= (thisFrameTime - frameTime) / filterStrength;
+ lastLoop = thisLoop;
+}, 50)
+
+setInterval(() => {
+ if (!debugshow) { return; }
+
+ tps = (1000/frameTime).toFixed(1);
+
+ if (typeof ping === "number") {
+ cping = ping;
+ } else {
+ cping = 0;
+ }
+
+ if (started) {
+ changedDataLeft = "playing: %true%";
+ changedDataLeft += "\n\n0$: XY: " + document.getElementById('car0').style.left.split("px")[0] + " / " + document.getElementById('car0').style.top.split("px")[0]
+
+ c0rotate = document.getElementById('car0').style.transform.split("rotate(")[1].split("deg)")[0];
+ if (c0rotate === "90") {
+ changedDataLeft += "\n0$: Facing: south (Towards negative Y)";
+ } else if (c0rotate === "-90") {
+ changedDataLeft += "\n0$: Facing: north (Towards negative Y)";
+ } else if (c0rotate === "0") {
+ changedDataLeft += "\n0$: Facing: east (Towards positive X)";
+ } else if (c0rotate === "180") {
+ changedDataLeft += "\n0$: Facing: west (Towards negative X)";
+ }
+
+ changedDataLeft += "\n0$: Speed: A: " + car0cspeed.toFixed(2) + " R: " + (car0speed - car0cspeed).toFixed(2) + " M: " + car0speed.toFixed(2);
+
+ changedDataLeft += "\n0$: Laps: " + document.getElementById('laps-car0').innerText + "/5";
+ changedDataLeft += "\n0$: Model: " + selectedModel0;
+ changedDataLeft += "\n0$: Collision: " + (car0collisionon ? "%true%" : "%false%");
+
+ changedDataLeft += "\n\n1$: XY: " + document.getElementById('car1').style.left.split("px")[0] + " / " + document.getElementById('car1').style.top.split("px")[0]
+
+ c0rotate = document.getElementById('car1').style.transform.split("rotate(")[1].split("deg)")[0];
+ if (c0rotate === "90") {
+ changedDataLeft += "\n1$: Facing: south (Towards negative Y)";
+ } else if (c0rotate === "-90") {
+ changedDataLeft += "\n1$: Facing: north (Towards negative Y)";
+ } else if (c0rotate === "0") {
+ changedDataLeft += "\n1$: Facing: east (Towards positive X)";
+ } else if (c0rotate === "180") {
+ changedDataLeft += "\n1$: Facing: west (Towards negative X)";
+ }
+
+ changedDataLeft += "\n1$: Speed: A: " + car1cspeed.toFixed(2) + " R: " + (car1speed - car1cspeed).toFixed(2) + " M: " + car1speed.toFixed(2);
+
+ changedDataLeft += "\n1$: Laps: " + document.getElementById('laps-car1').innerText + "/5";
+ changedDataLeft += "\n1$: Model: " + selectedModel1;
+ changedDataLeft += "\n1$: Collision: " + (car1collisionon ? "%true%" : "%false%");
+ changedDataLeft += "\n" + oil(0) + oil(1) + oil(2) + oil(3) + oil(4);
+ changedDataLeft += "\n\nMusic: " + i;
+ changedDataLeft += "\nCircuit: " + rand;
+
+ } else {
+ changedDataLeft = "playing: %false%"
+ }
+},100); \ No newline at end of file
diff --git a/kartik/views/script/game_global.js b/kartik/views/script/game_global.js
new file mode 100755
index 0000000..4e6de21
--- /dev/null
+++ b/kartik/views/script/game_global.js
@@ -0,0 +1,45 @@
+$("#box").fadeOut(0);
+$("#bg").fadeOut(0);
+setTimeout(() => {
+ $("#box").fadeIn(500);
+ $("#bg").fadeIn(500);
+}, 200)
+
+global.startgame = () => {
+ keysEnabled = true;
+ $("#credits").fadeOut(200)
+ Sound.intro();
+
+ setTimeout(() => {
+ started = true;
+ }, 1700)
+
+ setTimeout(() => {
+ if (location.search === "?sp") {
+ enableAI();
+ }
+ }, 1200)
+}
+
+startHooks.push(() => {
+ global.hitshow = false;
+ global.started = false;
+ keysEnabled = false;
+
+ $("body").focus();
+
+ if (!online) {
+ setTimeout(startgame, 7000)
+ }
+
+ if (online && role === "host") {
+ setTimeout(() => {
+ clientWriter(JSON.stringify({
+ _type: "ipc",
+ action: "gameIsReady",
+ message: null
+ }) + "|")
+ startgame();
+ }, 7000)
+ }
+}) \ No newline at end of file
diff --git a/kartik/views/script/game_music.js b/kartik/views/script/game_music.js
new file mode 100755
index 0000000..9739cc3
--- /dev/null
+++ b/kartik/views/script/game_music.js
@@ -0,0 +1,8 @@
+startHooks.push(() => {
+ info("MusicMgr", "Playing game" + i + ".mp3");
+ window.parent.musicManager.setMusic(kresources.music['game' + i].file);
+})
+
+if (location.search === "?online") {
+ window.parent.musicManager.setMusic(kresources.music['prepare'].file);
+}
diff --git a/kartik/views/script/game_online.js b/kartik/views/script/game_online.js
new file mode 100755
index 0000000..e379708
--- /dev/null
+++ b/kartik/views/script/game_online.js
@@ -0,0 +1,9 @@
+if (location.search === "?online") {
+ document.getElementById('online-login').style.display = "";
+ document.write(`<` + `script src="../online/global.js"></` + `script>`);
+} else {
+ startHooks.forEach((hook) => {
+ hook(this);
+ })
+ document.getElementById('ping').style.display = "none";
+} \ No newline at end of file
diff --git a/kartik/views/script/game_select.js b/kartik/views/script/game_select.js
new file mode 100755
index 0000000..a3896d4
--- /dev/null
+++ b/kartik/views/script/game_select.js
@@ -0,0 +1,131 @@
+if (native) {global.$ = require('jquery');} else {var script = document.createElement('script');script.src = '../webinit/jquery.js';script.type = 'text/javascript';document.getElementsByTagName('head')[0].appendChild(script);}
+
+startHooks.push(() => {
+ function ranint(min, max) { // min and max included
+ return Math.floor(Math.random() * (max - min + 1) + min);
+ }
+
+ circuits = Object.keys(kresources.races);
+ rand = circuits[Math.floor(Math.random()*circuits.length)];
+
+ if (online && role === "host") {
+ setInterval(() => {
+ clientWriter(JSON.stringify({
+ _type: "ipc",
+ action: "RaceData:circuit",
+ message: rand
+ }) + "|");
+ }, 100)
+ }
+
+ if (online && role === "guest") {
+ rand = guestInfo.circuit;
+ }
+
+ info("GameWindow", "Selected circuit " + rand);
+ document.getElementById('circuit').style.backgroundImage = "url('." + kresources.races[rand].substr(0, kresources.races[rand].length - 5).split("'").join("\\'") + ".png')";
+ document.getElementById('circuit').innerHTML = $.ajax("/kartik/" + kresources.races[rand], { async: false }).responseText.toString();
+
+ inf = JSON.parse(document.getElementsByTagName("circuit")[0].innerText);
+ if (typeof inf.name[lp] === "undefined") {
+ document.getElementById('race-title').innerText = inf.name.en;
+ } else {
+ document.getElementById('race-title').innerText = inf.name[lp];
+ }
+ document.getElementById('race-author').innerText = inf.author;
+
+ i = ranint(1, 9);
+
+ if (online && role === "host") {
+ setInterval(() => {
+ clientWriter(JSON.stringify({
+ _type: "ipc",
+ action: "RaceData:music",
+ message: i
+ }) + "|");
+ }, 200)
+ }
+
+ if (online && role === "guest") {
+ i = guestInfo.music;
+ }
+
+ global.spreadOil = (oil) => {
+ rx = ranint(0, 680);
+ ry = ranint(0, 490);
+ rd = ranint(0, 360);
+ rh = ranint(0, 360);
+
+ oil.style.top = ry + "px";
+ oil.style.left = rx + "px";
+ oil.style.transform = "rotate(" + rd + "deg)";
+ oil.style.filter = "hue-rotate(" + rd + "deg)";
+ }
+
+ Array.from(document.getElementById('oil').children).forEach((item) => {
+ spreadOil(item);
+ })
+
+ modelsAvailable = Object.keys(kresources.cars);
+
+ selectedModel0I = Math.floor(Math.random() * modelsAvailable.length);
+ selectedModel0 = modelsAvailable[selectedModel0I];
+ modelsAvailable.splice(selectedModel0I, 1);
+
+ selectedModel1I = Math.floor(Math.random() * modelsAvailable.length);
+ selectedModel1 = modelsAvailable[selectedModel1I];
+
+ if (online && role === "host") {
+ setInterval(() => {
+ clientWriter(JSON.stringify({
+ _type: "ipc",
+ action: "RaceData:hostCar",
+ message: selectedModel0
+ }) + "|");
+ }, 300)
+ setInterval(() => {
+ clientWriter(JSON.stringify({
+ _type: "ipc",
+ action: "RaceData:guestCar",
+ message: selectedModel1
+ }) + "|");
+ }, 400)
+ }
+
+ if (online && role === "guest") {
+ selectedModel0 = guestInfo.guestCar;
+ selectedModel1 = guestInfo.hostCar;
+ }
+
+ document.getElementById("car0-img").src = kresources.cars[selectedModel0];
+ document.getElementById("cars-p1-inner").src = kresources.cars[selectedModel0];
+ document.getElementById("car1-img").src = kresources.cars[selectedModel1];
+ document.getElementById("cars-p2-inner").src = kresources.cars[selectedModel1];
+})
+
+startHooks.push(() => {
+ setInterval(() => {
+ if (online) {
+ clientWriter(JSON.stringify({
+ _type: "ipc",
+ action: "posTop",
+ message: document.getElementById("car0").style.top
+ }) + "|")
+ clientWriter(JSON.stringify({
+ _type: "ipc",
+ action: "posLeft",
+ message: document.getElementById("car0").style.left
+ }) + "|")
+ clientWriter(JSON.stringify({
+ _type: "ipc",
+ action: "posRot",
+ message: document.getElementById("car0").style.transform
+ }) + "|")
+ clientWriter(JSON.stringify({
+ _type: "ipc",
+ action: "progressLaps",
+ message: document.getElementById("laps-car0").innerText
+ }) + "|")
+ }
+ }, 50)
+})
diff --git a/kartik/views/script/global_compatlayer.js b/kartik/views/script/global_compatlayer.js
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/kartik/views/script/global_compatlayer.js
diff --git a/kartik/views/script/global_levelsapi.js b/kartik/views/script/global_levelsapi.js
new file mode 100755
index 0000000..ebd969d
--- /dev/null
+++ b/kartik/views/script/global_levelsapi.js
@@ -0,0 +1,47 @@
+module.exports = class LevelsAPI {
+
+ associates;
+
+ constructor() {
+
+ let assocs_raw;
+ let assocs_lines;
+ let assocs_base;
+ let assocs;
+ let score;
+ let cline;
+ let line;
+ let clvl;
+
+ assocs_raw = require('fs').readFileSync("./online/levels.txt");
+ assocs_lines = assocs_raw.toString().split("\n");
+ assocs_base = {};
+
+ for (line of assocs_lines) {
+ cline = line.split(":");
+ assocs_base[cline[1].trim()] = cline[0].trim() - 1 + 1;
+ }
+
+ assocs = {};
+
+ clvl = 0;
+ for (let c = 0; c <= 5051; c++) {
+ if (assocs_base[c.toString()] !== undefined) {
+ clvl = assocs_base[c.toString()];
+ }
+ assocs[c.toString()] = clvl.toString()
+ }
+
+ this.associates = assocs;
+
+ }
+
+ correspond(score, god) {
+ if (score <= 5051) {
+ return this.associates[score].toString();
+ } else {
+ return god;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/kartik/views/script/intro_global.js b/kartik/views/script/intro_global.js
new file mode 100755
index 0000000..b6bf033
--- /dev/null
+++ b/kartik/views/script/intro_global.js
@@ -0,0 +1,21 @@
+if (native) {global.$ = require('jquery');} else {var script = document.createElement('script');script.src = '../webinit/jquery.js';script.type = 'text/javascript';document.getElementsByTagName('head')[0].appendChild(script);}
+$("#box").fadeOut(0);
+window.addEventListener('load', () => {
+ setTimeout(() => {
+ $("#box").fadeIn(500);
+ }, 1000)
+})
+
+keysEnabled = true;
+$(document).keydown(function(e) {
+ if (keysEnabled) {
+ if (e.keyCode === 13 || e.keyCode === 88 || e.keyCode === 32 || e.keyCode === 27 || e.keyCode === 8 || e.keyCode === 16) { // enter/esc
+ kesyEnabled = false;
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("GWinWindow", "Switching control to MenuWindow");
+ location.href = "menu.html?noreset";
+ }, 1000)
+ }
+ }
+}) \ No newline at end of file
diff --git a/kartik/views/script/intro_media.js b/kartik/views/script/intro_media.js
new file mode 100755
index 0000000..a6be835
--- /dev/null
+++ b/kartik/views/script/intro_media.js
@@ -0,0 +1,2 @@
+info("MusicMgr", "Playing title.mp3");
+window.parent.musicManager.setMusic(kresources.music['title'].file); \ No newline at end of file
diff --git a/kartik/views/script/intro_message.js b/kartik/views/script/intro_message.js
new file mode 100755
index 0000000..6ab8d95
--- /dev/null
+++ b/kartik/views/script/intro_message.js
@@ -0,0 +1,7 @@
+setInterval(() => {
+ if (require('@electron/remote').getCurrentWindow().controllerAttached) {
+ document.getElementById('progress').innerText = lang.intro[1];
+ } else {
+ document.getElementById('progress').innerText = lang.intro[0];
+ }
+}, 100) \ No newline at end of file
diff --git a/kartik/views/script/loader_global.js b/kartik/views/script/loader_global.js
new file mode 100755
index 0000000..9844f1e
--- /dev/null
+++ b/kartik/views/script/loader_global.js
@@ -0,0 +1,132 @@
+window.addEventListener("load", () => {
+ document.getElementById("banner-decoration").style.display = "";
+ document.getElementById("banner-outer").style.backgroundImage = "";
+ document.getElementById("banner-outer").style.backgroundColor = "#042349";
+ document.getElementById("banner-contrast").style.display = "none";
+
+ setTimeout(() => {
+ if (native) {
+ setTimeout(() => {
+ setTimeout(() => {
+
+ $("#progress").fadeOut(500);
+ setTimeout(() => {
+ window.fetch("https://kartik.hopto.org/latest.php?v=" + require('@electron/remote').getCurrentWindow().update).then((data) => {
+ data.blob().then((a) => {
+ a.text().then((b) => {
+ if (require('@electron/remote').getCurrentWindow().update === "git") {
+ document.getElementById('updates').style.backgroundColor = "lightsalmon";
+ document.getElementById('updates').innerText = lang.updates.git;
+ } else {
+ console.log(b);
+ console.log(require('../package.json').version);
+ if (b === require('../package.json').version) {
+ document.getElementById('updates').style.backgroundColor = "lightgreen";
+ document.getElementById('updates').innerText = lang.updates.ok;
+ } else {
+ require('@electron/remote').getCurrentWindow().webContents.send("notification", {title: lang.updates.warn[0], message: lang.updates.warn[1]});
+ document.getElementById('updates').style.backgroundColor = "lightyellow";
+ document.getElementById('updates').innerText = lang.updates.available;
+ }
+ }
+ setTimeout(() => {
+ $("#banner-outer").fadeOut(200);
+ $("#intro-video").fadeIn(200);
+ setTimeout(() => {
+ introsfx = document.getElementById("intro-video");
+ introsfx.play()
+ introsfx.onended = () => {
+ $("body").fadeOut(500);
+ setTimeout(() => {
+ info("LoadWindow", "Switching control to MenuWindow");
+ location.href = "intro.html";
+ }, 1000)
+ }
+ }, 200)
+ }, 2000)
+ }).catch((e) => {
+ console.warn(e);
+ document.getElementById('updates').style.backgroundColor = "lightcoral";
+ document.getElementById('updates').innerText = lang.updates.error;
+ require('@electron/remote').getCurrentWindow().webContents.send("notification", {title: lang.polymer.updateError[0], message: lang.polymer.updateError[1]});
+ setTimeout(() => {
+ $("#banner-outer").fadeOut(200);
+ $("#intro-video").fadeIn(200);
+ setTimeout(() => {
+ introsfx = document.getElementById("intro-video");
+ introsfx.play()
+ introsfx.onended = () => {
+ $("body").fadeOut(500);
+ setTimeout(() => {
+ info("LoadWindow", "Switching control to MenuWindow");
+ location.href = "intro.html";
+ }, 1000)
+ }
+ }, 200)
+ }, 2000)
+ });
+ }).catch((e) => {
+ console.warn(e);
+ document.getElementById('updates').style.backgroundColor = "lightcoral";
+ document.getElementById('updates').innerText = lang.updates.error;
+ require('@electron/remote').getCurrentWindow().webContents.send("notification", {title: lang.polymer.updateError[0], message: lang.polymer.updateError[1]});
+ setTimeout(() => {
+ $("#banner-outer").fadeOut(200);
+ $("#intro-video").fadeIn(200);
+ setTimeout(() => {
+ introsfx = document.getElementById("intro-video");
+ introsfx.play()
+ introsfx.onended = () => {
+ $("body").fadeOut(500);
+ setTimeout(() => {
+ info("LoadWindow", "Switching control to MenuWindow");
+ location.href = "intro.html";
+ }, 1000)
+ }
+ }, 200)
+ }, 2000)
+ });
+ }).catch((e) => {
+ console.warn(e);
+ document.getElementById('updates').style.backgroundColor = "lightcoral";
+ document.getElementById('updates').innerText = lang.updates.error;
+ require('@electron/remote').getCurrentWindow().webContents.send("notification", {title: lang.polymer.updateError[0], message: lang.polymer.updateError[1]});
+ setTimeout(() => {
+ $("#banner-outer").fadeOut(200);
+ $("#intro-video").fadeIn(200);
+ setTimeout(() => {
+ introsfx = document.getElementById("intro-video");
+ introsfx.play()
+ introsfx.onended = () => {
+ $("body").fadeOut(500);
+ setTimeout(() => {
+ info("LoadWindow", "Switching control to MenuWindow");
+ location.href = "intro.html";
+ }, 1000)
+ }
+ }, 200)
+ }, 2000)
+ });
+ }, 2000)
+ }, 3000)
+ }, 1000)
+ } else {
+
+ setTimeout(() => {
+ $("#banner-outer").fadeOut(200);
+ $("#intro-video").fadeIn(200);
+ setTimeout(() => {
+ introsfx = document.getElementById("intro-video");
+ introsfx.play()
+ introsfx.onended = () => {
+ $("body").fadeOut(500);
+ setTimeout(() => {
+ info("LoadWindow", "Switching control to MenuWindow");
+ location.href = "intro.html";
+ }, 1000)
+ }
+ }, 200)
+ }, 5000)
+ }
+ }, 2000)
+}) \ No newline at end of file
diff --git a/kartik/views/script/menu_copyright.js b/kartik/views/script/menu_copyright.js
new file mode 100755
index 0000000..2b38844
--- /dev/null
+++ b/kartik/views/script/menu_copyright.js
@@ -0,0 +1,5 @@
+if (new Date().getFullYear() === 2021) {
+ document.write(new Date().getFullYear() + " Minteck");
+} else {
+ document.write("2021-" + new Date().getFullYear() + " Minteck");
+} \ No newline at end of file
diff --git a/kartik/views/script/menu_global.js b/kartik/views/script/menu_global.js
new file mode 100755
index 0000000..811e525
--- /dev/null
+++ b/kartik/views/script/menu_global.js
@@ -0,0 +1,127 @@
+let menuOpen = true;
+
+if (native) {global.$ = require('jquery');} else {var script = document.createElement('script');script.src = '../webinit/jquery.js';script.type = 'text/javascript';document.getElementsByTagName('head')[0].appendChild(script);}
+$("#box").fadeOut(0);
+window.addEventListener('load', () => {
+ setTimeout(() => {
+ $("#box").fadeIn(500);
+ }, 1000)
+})
+
+$("body").focus();
+keysEnabled = true;
+$(document).keydown(function(e) {
+ if (loggingIn) { return; }
+
+ if (keysEnabled) {
+ if (e.ctrlKey && e.keyCode === 13) { // ctrl+enter
+ throw new RangeError("Manually initiated crash");
+ }
+ if (e.keyCode === 13 || e.keyCode === 88 || e.keyCode === 32) { // enter
+ if ($(".services").is(":visible")) {
+ selectOption();
+ } else {
+ $(".services").show();
+ }
+ menuOpen = !menuOpen;
+ }
+ if (e.keyCode === 38 || e.keyCode === 90) { // up
+ Sound.menu();
+ var selected = $(".selected");
+ $(".services li").removeClass("selected");
+ if (selected.prev().length === 0) {
+ selected.siblings().last().addClass("selected");
+ } else {
+ selected.prev().addClass("selected");
+ }
+ }
+ if (e.keyCode === 40 || e.keyCode === 83) { // down
+ Sound.menu();
+ var selected = $(".selected");
+ $(".services li").removeClass("selected");
+ if (selected.next().length === 0) {
+ selected.siblings().first().addClass("selected");
+ } else {
+ selected.next().addClass("selected");
+ }
+ }
+ if (e.keyCode === 27 || e.keyCode === 8) { // esc
+ keysEnabled = false;
+ Sound.click();
+ setTimeout(() => {
+ require('@electron/remote').getCurrentWindow().close();
+ }, 250)
+ }
+ }
+});
+
+function selectOption() {
+ item = document.querySelector(".selected a").id;
+ Sound.click();
+
+ switch (item) {
+ case 'single':
+ scenar("start", "happy");
+ keysEnabled = false;
+ window.parent.musicManager.fadeMusic();
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("MenuWindow", "Switching control to GameWindow");
+ location.href = "game.html?sp";
+ }, 1000)
+ break;
+ case 'online':
+ keysEnabled = false;
+ window.parent.musicManager.fadeMusic();
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("MenuWindow", "Switching control to GameWindow");
+ location.href = "game.html?online";
+ }, 1000)
+ break;
+ case 'play':
+ keysEnabled = false;
+ window.parent.musicManager.fadeMusic();
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("MenuWindow", "Switching control to GameWindow");
+ location.href = "game.html";
+ }, 1000)
+ break;
+ case 'settings':
+ keysEnabled = false;
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("MenuWindow", "Switching control to OptnWindow");
+ location.href = "settings.html";
+ }, 1000)
+ break;
+ case 'stats':
+ keysEnabled = false;
+ window.parent.musicManager.fadeMusic();
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("MenuWindow", "Switching control to OptnWindow");
+ location.href = "stats.html";
+ }, 1000)
+ break;
+ case 'credits':
+ keysEnabled = false;
+ window.parent.musicManager.fadeMusic();
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("MenuWindow", "Switching control to OptnWindow");
+ location.href = "credits.html";
+ }, 1000)
+ break;
+ case 'quit':
+ keysEnabled = false;
+ window.parent.musicManager.fadeMusic();
+ info("MenuWindow", "Quitting game");
+ Sound.click();
+ setTimeout(() => {
+ window.parent.location.href = "/";
+ }, 250)
+ break;
+ }
+} \ No newline at end of file
diff --git a/kartik/views/script/menu_gpuinfo.js b/kartik/views/script/menu_gpuinfo.js
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/kartik/views/script/menu_gpuinfo.js
diff --git a/kartik/views/script/menu_login.js b/kartik/views/script/menu_login.js
new file mode 100755
index 0000000..8e071eb
--- /dev/null
+++ b/kartik/views/script/menu_login.js
@@ -0,0 +1 @@
+global.loggingIn = false;
diff --git a/kartik/views/script/menu_music.js b/kartik/views/script/menu_music.js
new file mode 100755
index 0000000..5d26af0
--- /dev/null
+++ b/kartik/views/script/menu_music.js
@@ -0,0 +1,5 @@
+if (location.search !== "?noreset") {
+ console.log("back");
+ window.parent.musicManager.setMusic(kresources.music['title'].file);
+}
+info("MenuWindow", "Menu opened");
diff --git a/kartik/views/script/menu_system.js b/kartik/views/script/menu_system.js
new file mode 100755
index 0000000..947699f
--- /dev/null
+++ b/kartik/views/script/menu_system.js
@@ -0,0 +1,33 @@
+
+switch (require('os').platform()) {
+ case "win32":
+ document.write("Windows");
+ break
+ case "aix":
+ document.write("AIX");
+ break
+ case "android":
+ document.write("Android");
+ break
+ case "cygwin":
+ document.write("Cygwin");
+ break
+ case "darwin":
+ document.write("macOS");
+ break
+ case "freebsd":
+ document.write("FreeBSD");
+ break
+ case "linux":
+ document.write("GNU/Linux");
+ break
+ case "netbsd":
+ document.write("NetBSD");
+ break
+ case "openbsd":
+ document.write("OpenBSD");
+ break
+ case "sunos":
+ document.write("Solaris");
+ break
+}
diff --git a/kartik/views/script/online_play.js b/kartik/views/script/online_play.js
new file mode 100755
index 0000000..0c1eb91
--- /dev/null
+++ b/kartik/views/script/online_play.js
@@ -0,0 +1,2 @@
+require('@electron/remote').getCurrentWindow().dstate = lang.online.discord2;
+require('@electron/remote').getCurrentWindow().ddetails = lang.online.discord; \ No newline at end of file
diff --git a/kartik/views/script/settings_global.js b/kartik/views/script/settings_global.js
new file mode 100755
index 0000000..64c9b64
--- /dev/null
+++ b/kartik/views/script/settings_global.js
@@ -0,0 +1,104 @@
+let menuOpen = true;
+
+if (native) {global.$ = require('jquery');} else {var script = document.createElement('script');script.src = '../webinit/jquery.js';script.type = 'text/javascript';document.getElementsByTagName('head')[0].appendChild(script);}
+$("#box").fadeOut(0);
+setTimeout(() => {
+ $("#box").fadeIn(500);
+}, 200)
+
+$("body").focus();
+keysEnabled = true;
+$(document).keydown(function(e) {
+ if (keysEnabled) {
+ if (e.keyCode === 13 || e.keyCode === 88 || e.keyCode === 32) { // enter
+ if ($(".services").is(":visible")) {
+ selectOption();
+ } else {
+ $(".services").show();
+ }
+ }
+ if (e.keyCode === 38 || e.keyCode === 90) { // up
+ Sound.menu();
+ var selected = $(".selected");
+ $(".services li").removeClass("selected");
+ if (selected.prev().length === 0) {
+ selected.siblings().last().addClass("selected");
+ } else {
+ selected.prev().addClass("selected");
+ }
+ }
+ if (e.keyCode === 40 || e.keyCode === 83) { // down
+ Sound.menu();
+ var selected = $(".selected");
+ $(".services li").removeClass("selected");
+ if (selected.next().length === 0) {
+ selected.siblings().first().addClass("selected");
+ } else {
+ selected.next().addClass("selected");
+ }
+ }
+ if (e.keyCode === 68 || e.keyCode === 39 || e.keyCode === 81 || e.keyCode === 37) { // right/left
+ Sound.menu();
+ var selected = $(".selected");
+ var id = $(".selected")[0].children[0].children[0].id;
+
+ if (id === "lang") {
+ lang = document.getElementById("setting-lang").innerText;
+ slng = JSON.parse($.ajax('../lang/languages.json', { async: false }).responseText);
+ slst = Object.keys(slng);
+ maxl = slst.length - 1;
+
+ ci = -1;
+ ni = -1;
+ slst.forEach((key, index) => {
+ if (slng[key] === lang) {
+ ci = index;
+ if (index + 1 > maxl) {
+ ni = 0;
+ } else {
+ ni = index + 1;
+ }
+ }
+ })
+
+ if (ci !== -1 && ni !== -1) {
+ document.cookie = "kartik_lang=" + slst[ni] + "; path=/";
+ document.getElementById("setting-lang").innerText = slng[slst[ni]];
+ window.parent.lp = lp = slst[ni];
+ }
+ }
+ }
+ if (e.keyCode === 27 || e.keyCode === 8) { // esc
+ keysEnabled = false;
+ Sound.click();
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("OptnWindow", "Switching control to MenuWindow");
+ location.href = "menu.html";
+ }, 1000)
+ }
+ }
+});
+
+function selectOption() {
+ item = document.querySelector(".selected a").id;
+ Sound.click();
+
+ switch (item) {
+ case 'back':
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("OptnWindow", "Switching control to MenuWindow");
+ location.href = "menu.html?noreset";
+ }, 1000)
+ break;
+ case 'credits':
+ window.parent.musicManager.fadeMusic();
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("OptnWindow", "Switching control to MenuWindow");
+ location.href = "credits.html";
+ }, 1000)
+ break;
+ }
+}
diff --git a/kartik/views/script/settings_load.js b/kartik/views/script/settings_load.js
new file mode 100755
index 0000000..c57329f
--- /dev/null
+++ b/kartik/views/script/settings_load.js
@@ -0,0 +1,10 @@
+info("OptnWindow", "Restoring settings...");
+
+slang = lp;
+langs = JSON.parse($.ajax('../lang/languages.json', { async: false }).responseText);
+
+if (Object.keys(langs).includes(slang)) {
+ document.getElementById("setting-lang").innerText = langs[slang];
+} else {
+ document.getElementById("setting-lang").innerText = slang;
+}
diff --git a/kartik/views/script/win_global.js b/kartik/views/script/win_global.js
new file mode 100755
index 0000000..7448375
--- /dev/null
+++ b/kartik/views/script/win_global.js
@@ -0,0 +1,22 @@
+if (native) {global.$ = require('jquery');} else {var script = document.createElement('script');script.src = '../webinit/jquery.js';script.type = 'text/javascript';document.getElementsByTagName('head')[0].appendChild(script);}
+$("#box").fadeOut(0);
+setTimeout(() => {
+ $("#box").fadeIn(500);
+}, 200)
+
+keysEnabled = true;
+$(document).keydown(function(e) {
+ if (keysEnabled) {
+ if (e.keyCode === 13 || e.keyCode === 88 || e.keyCode === 32 || e.keyCode === 27 || e.keyCode === 8 || e.keyCode === 16) { // enter/esc
+ Sound.click();
+ window.parent.musicManager.fadeMusic();
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("GWinWindow", "Switching control to MenuWindow");
+ location.href = "menu.html";
+ }, 3000)
+ }
+ }
+})
+
+info("GWinWindow", "Rendered!"); \ No newline at end of file
diff --git a/kartik/views/script/win_message.js b/kartik/views/script/win_message.js
new file mode 100755
index 0000000..fd01c22
--- /dev/null
+++ b/kartik/views/script/win_message.js
@@ -0,0 +1,9 @@
+if (location.search === "?sp") {
+ if ((location.hash.substr(4) - 1 + 2) == 1) {
+ document.write(lang.win.solo.win);
+ } else {
+ document.write(lang.win.solo.lose);
+ }
+} else {
+ document.write(lang.win.versus.replace("0", (location.hash.substr(4) - 1 + 2)));
+} \ No newline at end of file
diff --git a/kartik/views/script/win_music.js b/kartik/views/script/win_music.js
new file mode 100755
index 0000000..6220bb8
--- /dev/null
+++ b/kartik/views/script/win_music.js
@@ -0,0 +1,2 @@
+info("MusicMgr", "Playing win.mp3");
+window.parent.musicManager.setMusic(kresources.music['win'].file); \ No newline at end of file
diff --git a/kartik/views/script/win_play.js b/kartik/views/script/win_play.js
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/kartik/views/script/win_play.js
diff --git a/kartik/views/script/win_quit.js b/kartik/views/script/win_quit.js
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/kartik/views/script/win_quit.js