aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
Diffstat (limited to 'views')
-rw-r--r--views/loader.svg4
-rw-r--r--views/loader/back.pngbin0 -> 67643 bytes
-rw-r--r--views/loader/logo.pngbin0 -> 165369 bytes
-rw-r--r--views/menu.css70
-rw-r--r--views/menu.html34
-rw-r--r--views/script/core_compatlayer.js4
-rw-r--r--views/script/global_compatlayer.js4
-rw-r--r--views/script/global_levelsapi.js47
-rw-r--r--views/script/loader_global.js7
-rw-r--r--views/script/menu_global.js2
-rw-r--r--views/script/menu_login.js155
-rw-r--r--views/stats.html2
12 files changed, 315 insertions, 14 deletions
diff --git a/views/loader.svg b/views/loader.svg
index 77a496e..042b338 100644
--- a/views/loader.svg
+++ b/views/loader.svg
@@ -115,7 +115,7 @@
<glyph unicode="&#xA0;" horiz-adv-x="300"/>
</font>
- <image style="overflow:visible;" width="787" height="443" xlink:href="C:\Users\Minteck\Desktop\loader.png" transform="matrix(0.9974 0 0 0.9977 1 1)">
+ <image style="overflow:visible;" width="787" height="443" xlink:href="./loader/back.png" transform="matrix(0.9974 0 0 0.9977 1 1)">
</image>
<text transform="matrix(1 0 0 1 59.7305 138.855)" class="st0 st1 st2">Kartik</text>
<text transform="matrix(1 0 0 1 61.7622 159.8193)" class="st0 st1 st3">%version%</text>
@@ -123,6 +123,6 @@
<rect x="638" y="0" class="st4" width="43.4" height="443"/>
<rect x="-709.8" y="0" class="st4" width="711.8" height="443"/>
<rect x="-42" y="-441" class="st4" width="711.8" height="443"/>
-<image style="overflow:visible;" width="1080" height="1080" xlink:href="C:\Users\Minteck\Desktop\1.png" transform="matrix(4.612159e-02 0 0 4.612159e-02 540.8679 295.5552)">
+<image style="overflow:visible;" width="1080" height="1080" xlink:href="./loader/logo.png" transform="matrix(4.612159e-02 0 0 4.612159e-02 540.8679 295.5552)">
</image>
</svg>
diff --git a/views/loader/back.png b/views/loader/back.png
new file mode 100644
index 0000000..4d268cc
--- /dev/null
+++ b/views/loader/back.png
Binary files differ
diff --git a/views/loader/logo.png b/views/loader/logo.png
new file mode 100644
index 0000000..09112ca
--- /dev/null
+++ b/views/loader/logo.png
Binary files differ
diff --git a/views/menu.css b/views/menu.css
index 2c2b94f..ca90e93 100644
--- a/views/menu.css
+++ b/views/menu.css
@@ -151,4 +151,74 @@
.item-icon {
filter: invert(1);
vertical-align: middle;
+}
+
+div.services.home {
+ top: 115px;
+ padding: 0;
+ display: flex;
+ align-items: center;
+ bottom: 70px;
+ z-index: 9999;
+}
+
+div.services.home > div.items > ul > li > span.item {
+ width: 216px;
+ border-radius: 0;
+}
+
+div.services.home > div.items > ul > li > span.item > a {
+ margin-left: 10px;
+ margin-right: 10px;
+ width: 100%;
+ display: inline-block;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+}
+
+div.services.home > div.items {
+ width: 256px;
+}
+
+div.services.home > div.items > ul {
+ padding: 0;
+}
+
+div.services.home > div.items > ul > li {
+ list-style: none;
+}
+
+div.services.home > div.items > ul > li > span.item {
+ margin-left: 10vw;
+ transition: none;
+}
+
+img[alt="full-logo"] {
+ margin-left: calc(10vw + 37.5px) !important;
+ margin-top: 55px !important;
+ height: 56px !important;
+ z-index: 99999;
+ position: fixed;
+}
+
+span#copyright {
+ bottom: 46px;
+ left: 10vw;
+ z-index: 9999;
+ color: rgba(255, 255, 255, 0.75);
+ right: unset;
+ width: 227px;
+ text-align: center;
+}
+
+#services-background {
+ position: fixed;
+ top: 0;
+ bottom: 0;
+ width: 227px;
+ z-index: 9;
+ backdrop-filter: blur(10px);
+ background: rgba(0, 0, 0, 0.5);
+ left: 10vw;
} \ No newline at end of file
diff --git a/views/menu.html b/views/menu.html
index d00107c..26e79db 100644
--- a/views/menu.html
+++ b/views/menu.html
@@ -11,6 +11,7 @@
<title>Kartik</title>
<script src="../crash/client.js"></script>
<script src="./script/global_compatlayer.js"></script>
+ <script src="./script/menu_login.js"></script>
<script src="../sfx/sfx.js"></script>
<link rel="stylesheet" href="rain/rainstyle.css">
<script>
@@ -29,14 +30,16 @@
</script>
<div id="box" style="display: none;background:#222;position:fixed;top:0;left:0;right:0;bottom:0;">
+ <div id="loggingIn" style="position: fixed;color: white;background: rgba(0, 0, 0, .5);z-index: 999999999999;top: 0;left: 0;right: 0;bottom: 0;display: none;align-items: center;justify-content: center;backdrop-filter: blur(10px);"><script>document.write(lang.polymer.logging);</script></div>
+
<div class="rain front-row"></div>
<div class="rain back-row"></div>
- <div style="width: 100%;height: 100%;background-color: #001743;background-image: url('./menu.jpg');background-size: cover;position: fixed;z-index: -1;">
- <img alt="full-logo" src="../logo/full.png" style="margin-left: 50px;margin-top: 30px;height: 96px;">
- </div>
+ <div style="width: 100%;height: 100%;background-color: #001743;background-image: url('./menu.jpg');background-size: cover;position: fixed;z-index: -1;"></div>
+ <img alt="full-logo" src="../logo/full.png" style="margin-left: 50px;margin-top: 30px;height: 96px;">
+ <div id="services-background"></div>
- <div class="services">
+ <div class="services home">
<div class="items">
<ul>
<li class="selected"><span class="item"><a href="#" id="single"><img class="item-icon" src="../icons/singleplayer.svg"> <script>document.write(lang.menu.titles[0])</script></a></span></li>
@@ -57,7 +60,7 @@
</div>
</div>
- <div style="position: fixed;right: 16px;top: 16px;color: white;background: rgba(0, 0, 0, .5);font-size: 10px;text-align:left;z-index:999999999;padding: 10px;border-radius: 10px;width: 189px;" id="gpuinfo">
+ <div style="position: fixed;right: 16px;top: 79px;color: white;background: rgba(0, 0, 0, .5);font-size: 10px;text-align:left;z-index:999999999;padding: 10px;border-radius: 10px;width: 189px;" id="gpuinfo">
<span style="text-align:center;display:block;font-weight: bold;margin-bottom: 5px;">GPU Support Status</span>
<div style="margin-bottom: 10px;height: 16px;width: 100%;background: rgba(47, 47, 47, .5);border-radius: 999px;">
<div style="height: 16px;background: rgba(128, 0, 0, .5);border-radius: 999px;width: 0;" id="gpuinfo_progressbar"></div>
@@ -82,6 +85,27 @@
</script>
</div>
+ <div style="position: fixed;right: 16px;top: 16px;height:28px;color: white;backdrop-filter:blur(10px);background: rgba(0, 0, 0, .5);font-size: 10px;z-index:999999999;padding: 10px;border-radius: 10px;width: 189px;text-align:center;" id="loginIntro-outer">
+ <span id="loginIntro" style="padding-top: 10px;display: inline-block;"><script>document.write(lang.polymer.loginIntro);</script></span>
+ </div>
+
+ <div style="position: fixed;right: 16px;top: 16px;color: white;background: rgba(0, 0, 0, .5);font-size: 10px;z-index:999999999;padding-left: 10px;border-radius: 10px;width: 199px;text-align:center;display: none;backdrop-filter: blur(10px);grid-template-columns: 1fr 48px;" id="loginUser"><div style="
+ text-align: left;
+ padding-top: 13px;
+ padding-left: 5px;
+ font-size: 14px;
+"><b id="kto-username">Username</b><br><span><script>document.write(lang.polymer.ktoLevel)</script> <span id="kto-level">0</span></span></div><img style="
+ border-bottom-right-radius: 10px;
+ height: 48px;
+ background: rgba(0, 0, 0, .25);
+ display: inline-block;
+ width: 48px;
+ border: none;
+ border-top-right-radius: 10px;
+ outline: none;
+" alt=" " id="kto-picture">
+ </div>
+
<span id="copyright">© <script src="./script/menu_copyright.js"></script></span>
</div>
diff --git a/views/script/core_compatlayer.js b/views/script/core_compatlayer.js
index 206aa28..c6794f3 100644
--- a/views/script/core_compatlayer.js
+++ b/views/script/core_compatlayer.js
@@ -76,7 +76,7 @@ window.addEventListener("load", () => {
gpuperct = (gpuscore / maxscore) * 100;
- if (gpuperct < 50) {
+ if (gpuperct < 30) {
console.warn("Bad GPU support, disabling GPU-accelerated content");
var head = document.getElementsByTagName('HEAD')[0];
var link = document.createElement('link');
@@ -86,4 +86,4 @@ window.addEventListener("load", () => {
head.appendChild(link);
}
}
-}) \ No newline at end of file
+})
diff --git a/views/script/global_compatlayer.js b/views/script/global_compatlayer.js
index 8545a29..7431cea 100644
--- a/views/script/global_compatlayer.js
+++ b/views/script/global_compatlayer.js
@@ -76,7 +76,7 @@ window.addEventListener("load", () => {
gpuperct = (gpuscore / maxscore) * 100;
- if (gpuperct < 50) {
+ if (gpuperct < 30) {
console.warn("Bad GPU support, disabling GPU-accelerated content");
var head = document.getElementsByTagName('HEAD')[0];
var link = document.createElement('link');
@@ -86,4 +86,4 @@ window.addEventListener("load", () => {
head.appendChild(link);
}
}
-}) \ No newline at end of file
+})
diff --git a/views/script/global_levelsapi.js b/views/script/global_levelsapi.js
new file mode 100644
index 0000000..ebd969d
--- /dev/null
+++ b/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/views/script/loader_global.js b/views/script/loader_global.js
index 7c89d0f..db70d3b 100644
--- a/views/script/loader_global.js
+++ b/views/script/loader_global.js
@@ -9,13 +9,13 @@ window.addEventListener('load', () => {
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") {
+ 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) {
+ if (b === require('../package.json').version) {
document.getElementById('updates').style.backgroundColor = "lightgreen";
document.getElementById('updates').innerText = lang.updates.ok;
} else {
@@ -42,6 +42,7 @@ window.addEventListener('load', () => {
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(() => {
document.getElementById('banner').style.width = "380px";
document.getElementById('banner').style.height = "auto";
@@ -61,6 +62,7 @@ window.addEventListener('load', () => {
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(() => {
document.getElementById('banner').style.width = "380px";
document.getElementById('banner').style.height = "auto";
@@ -80,6 +82,7 @@ window.addEventListener('load', () => {
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(() => {
document.getElementById('banner').style.width = "380px";
document.getElementById('banner').style.height = "auto";
diff --git a/views/script/menu_global.js b/views/script/menu_global.js
index 3713591..8561fe3 100644
--- a/views/script/menu_global.js
+++ b/views/script/menu_global.js
@@ -11,6 +11,8 @@ window.addEventListener('load', () => {
$("body").focus();
keysEnabled = true;
$(document).keydown(function(e) {
+ if (loggingIn) { return; }
+
if (keysEnabled) {
if (e.keyCode === 13 || e.keyCode === 88 || e.keyCode === 32) { // enter
if ($(".services").is(":visible")) {
diff --git a/views/script/menu_login.js b/views/script/menu_login.js
new file mode 100644
index 0000000..b0a31e9
--- /dev/null
+++ b/views/script/menu_login.js
@@ -0,0 +1,155 @@
+global.loggingIn = false;
+homedir = require('@electron/remote').getCurrentWindow().homedir;
+
+function startLogin() {
+ loggingIn = true;
+
+ document.getElementById('loggingIn').style.display = "flex";
+ var http = require('http');
+
+ reqid = 0;
+
+ var server = http.createServer(function (req, res) {
+
+ const queryObject = require('querystring').parse(req.url,true);
+ token = queryObject[Object.keys(queryObject)[0]];
+ res.end(lang.polymer.loginClose);
+ reqid++;
+
+ if (reqid === 1) {
+ document.getElementById("loggingIn").innerText = lang.polymer.gatheringLogin
+ require('@electron/remote').getCurrentWindow().focus();
+ server.close();
+
+ playerData = {
+ "picture": null,
+ "name": null,
+ "level": -1,
+ "token": token
+ };
+
+ playerData.picture = $.ajax({
+ type: "GET",
+ url: 'https://kartik.hopto.org/online/ingame/api/profile.picture.php?kartik_online_token=' + token,
+ async: false,
+ error: (e) => { throw e; }
+ }).responseText.trim();
+
+ playerData.name = $.ajax({
+ type: "GET",
+ url: 'https://kartik.hopto.org/online/ingame/api/profile.name.php?kartik_online_token=' + token,
+ async: false,
+ error: (e) => { throw e; }
+ }).responseText.trim();
+
+ playerData.level = $.ajax({
+ type: "GET",
+ url: 'https://kartik.hopto.org/online/ingame/api/profile.level.php?kartik_online_token=' + token,
+ async: false,
+ error: (e) => { throw e; }
+ }).responseText.trim() - 1 + 1;
+
+ if (playerData.level >= 0 && playerData.name !== null && playerData.picture !== null) {
+ console.log(playerData);
+ loggingIn = false;
+ document.getElementById('loggingIn').style.display = "none";
+ require('fs').writeFileSync(homedir + "/.kartik/authentication.json", JSON.stringify(playerData));
+ keysEnabled = false;
+ require('electron').ipcRenderer.send('prefademusic', "");
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ location.href = "menu.html";
+ }, 1000)
+ } else {
+ throw new Error("Incomplete information received");
+ }
+ }
+
+ });
+
+ server.listen(14552);
+
+ console.log('Waiting for login requests on port 14552')
+ require('open')("https://kartik.hopto.org/online/ingame");
+}
+
+window.addEventListener('load', () => {
+ onlineMode = false;
+
+ window.fetch("https://kartik.hopto.org/latest.php?v=" + require('@electron/remote').getCurrentWindow().update).then((data) => {
+ data.blob().then((a) => {
+ a.text().then((b) => {
+ onlineMode = true;
+ postOnlineMode();
+ }).catch((e) => {
+ require('@electron/remote').getCurrentWindow().webContents.send("notification", {title: lang.polymer.error[0], message: lang.polymer.error[1]});
+ console.error(e);
+ onlineMode = false;
+ postOnlineMode();
+ document.getElementById("loginIntro").innerText = lang.polymer.error[2];
+ document.getElementById("online").parentElement.parentElement.outerHTML = "";
+ })
+ }).catch((e) => {
+ require('@electron/remote').getCurrentWindow().webContents.send("notification", {title: lang.polymer.error[0], message: lang.polymer.error[1]});
+ console.error(e);
+ onlineMode = false;
+ postOnlineMode();
+ document.getElementById("loginIntro").innerText = lang.polymer.error[2];
+ document.getElementById("online").parentElement.parentElement.outerHTML = "";
+ })
+ }).catch((e) => {
+ require('@electron/remote').getCurrentWindow().webContents.send("notification", {title: lang.polymer.error[0], message: lang.polymer.error[1]});
+ console.error(e);
+ onlineMode = false;
+ postOnlineMode();
+ document.getElementById("loginIntro").innerText = lang.polymer.error[2];
+ document.getElementById("online").parentElement.parentElement.outerHTML = "";
+ })
+})
+
+function postOnlineMode() {
+ if (!require('fs').existsSync(homedir + "/.kartik/authentication.json") || !onlineMode) {
+ $(document).keydown(function(e) {
+ if (e.keyCode === 76 && !loggingIn && onlineMode) {
+ startLogin();
+ }
+ })
+ } else {
+ authData = JSON.parse(require('fs').readFileSync(homedir + "/.kartik/authentication.json"));
+
+ document.getElementById('loginIntro').style.display = "none";
+ document.getElementById('loginUser').style.display = "grid";
+
+ olevel = $.ajax({
+ type: "GET",
+ url: 'https://kartik.hopto.org/online/ingame/api/profile.level.php?kartik_online_token=' + authData.token,
+ async: false,
+ error: (e) => { throw e; }
+ }).responseText.trim() - 1 + 1;
+
+ if (authData.level > olevel) {
+ $.ajax({
+ type: "GET",
+ url: 'https://kartik.hopto.org/online/ingame/api/set.level.php?kartik_online_token=' + authData.token + "&level=" + authData.level,
+ async: false,
+ error: (e) => { throw e; }
+ });
+ } else if (authData.level < olevel) {
+ authData.level = $.ajax({
+ type: "GET",
+ url: 'https://kartik.hopto.org/online/ingame/api/profile.level.php?kartik_online_token=' + authData.token,
+ async: false,
+ error: (e) => { throw e; }
+ }).responseText.trim() - 1 + 1;
+ fs.writeFileSync(homedir + "/.kartik/authentication.json", JSON.stringify(authData));
+ }
+
+ document.getElementById('kto-picture').src = authData.picture;
+ document.getElementById('kto-username').innerText = authData.name;
+ if (authData.level < 200) {
+ document.getElementById('kto-level').innerText = authData.level;
+ } else {
+ document.getElementById('kto-level').innerText = lang.polymer.ktoMaxLevel;
+ }
+ }
+} \ No newline at end of file
diff --git a/views/stats.html b/views/stats.html
index dcb4275..018e164 100644
--- a/views/stats.html
+++ b/views/stats.html
@@ -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>const 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=require(homedir + "/.kartik/stats.json")</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>