diff options
-rw-r--r-- | app.js | 143 | ||||
-rw-r--r-- | index.html | 28 | ||||
-rw-r--r-- | lang/loader.js | 28 | ||||
-rw-r--r-- | typescript/mainloader.js | 4 | ||||
-rw-r--r-- | views/loader.html | 13 | ||||
-rw-r--r-- | views/script/core_fullscreen.js | 60 | ||||
-rw-r--r-- | views/script/core_music.js | 187 | ||||
-rw-r--r-- | views/script/core_viewer.js | 7 | ||||
-rw-r--r-- | views/script/loader_global.js | 6 |
9 files changed, 255 insertions, 221 deletions
@@ -21,6 +21,7 @@ global.start = new Date(); global.KartikRoot = __dirname; global.shouldExitIfClosed = false; const { app, BrowserWindow } = require('electron'); +const fs = require("fs"); (async () => { process.on('uncaughtException', (error) => { @@ -179,47 +180,9 @@ const { app, BrowserWindow } = require('electron'); /* --------------------- */ - console.log(" * Checking channel"); require('@electron/remote/main').initialize(); function createWindow () { - if (require('./package.json').channel === "stable") { - logo = "logo/logo.png"; - channel = " "; - global.dimg = "official"; - global.dimga = "stable"; - global.dchan = "Kartik Stable"; - } else if (require('./package.json').channel === "beta") { - logo = "logo/logo-beta.png"; - channel = " Beta "; - global.dimg = "beta"; - global.dimga = "beta"; - global.dchan = "Kartik Beta"; - } else if (require('./package.json').channel === "nightly") { - logo = "logo/logo-nightly.png"; - channel = " Nightly "; - global.dimg = "nightly"; - global.dimga = "nightly"; - global.dchan = "Kartik Nightly"; - } else if (require('./package.json').channel === "eap") { - logo = "logo/logo-eap.png"; - channel = " EAP "; - global.dimg = "eap"; - global.dimga = "eap"; - global.dchan = "Kartik EAP"; - } else if (require('./package.json').channel === "git") { - logo = "logo/logo-git.png"; - channel = " Trunk "; - global.dimg = "git"; - global.dimga = "git"; - global.dchan = "Kartik Trunk"; - try { - pk = require('./package.json'); - pk.version = require('fs').readFileSync("./.git/refs/heads/trunk").toString().substr(0, 7); - fs.writeFileSync("./package.json", JSON.stringify(pk, 2)) - } catch (e) {} - } - console.log(" * Checking configuration"); lp = currentNest.config.lang @@ -227,30 +190,6 @@ const { app, BrowserWindow } = require('electron'); time = new Date() - start; console.log(" * Started successfully in " + Math.round(time/1000) + " seconds"); console.log(" * Why are you EVEN reading this?"); - try { load.close(); } catch (e) {} - console.log(" * Starting recovery procedure: E_PROMISE"); - global.win = new BrowserWindow({ - width: 1220, - height: 720, - minWidth: 720, - minHeight: 540, - resizeable: true, - resizable: true, - maximizable: true, - show: false, - enableLargerThanScreen: true, - icon: logo, - backgroundColor: "#000000", - title: "Kartik", - webPreferences: { - nodeIntegration: true, - contextIsolation: false, - enableRemoteModule: true, - webviewTag: true, - disableBlinkFeatures: "MediaSessionService", - } - }) - global.shouldExitIfClosed = true; console.log(" * Starting IPC engine"); @@ -289,10 +228,6 @@ const { app, BrowserWindow } = require('electron'); console.log(" * Starting Discord RPC"); require('./discord/client.js'); - console.log(" * Loading view"); - win.loadFile('./index.html') - win.setMenu(null); - if (win.debug) { console.log(" * *******************************************"); console.log(" * * KARTIK DEBUG MODE *"); @@ -300,6 +235,10 @@ const { app, BrowserWindow } = require('electron'); win.openDevTools(); } + setTimeout(() => { + win.webContents.send('ready', true); + }, 3000) + win.webContents.on('dom-ready', () => { musicIpc = require('electron').ipcMain; musicIpc.on('newmusic', (event, value) => { @@ -351,17 +290,57 @@ const { app, BrowserWindow } = require('electron'); } console.log(" * Starting splash screen"); - global.load = new BrowserWindow({ - width: 640, - height: 400, - resizeable: false, - resizable: false, - maximizable: false, - frame: false, + + console.log(" * Checking channel"); + if (require('./package.json').channel === "stable") { + logo = "logo/logo.png"; + channel = " "; + global.dimg = "official"; + global.dimga = "stable"; + global.dchan = "Kartik Stable"; + } else if (require('./package.json').channel === "beta") { + logo = "logo/logo-beta.png"; + channel = " Beta "; + global.dimg = "beta"; + global.dimga = "beta"; + global.dchan = "Kartik Beta"; + } else if (require('./package.json').channel === "nightly") { + logo = "logo/logo-nightly.png"; + channel = " Nightly "; + global.dimg = "nightly"; + global.dimga = "nightly"; + global.dchan = "Kartik Nightly"; + } else if (require('./package.json').channel === "eap") { + logo = "logo/logo-eap.png"; + channel = " EAP "; + global.dimg = "eap"; + global.dimga = "eap"; + global.dchan = "Kartik EAP"; + } else if (require('./package.json').channel === "git") { + logo = "logo/logo-git.png"; + channel = " Trunk "; + global.dimg = "git"; + global.dimga = "git"; + global.dchan = "Kartik Trunk"; + try { + pk = require('./package.json'); + pk.version = require('fs').readFileSync("./.git/refs/heads/trunk").toString().substr(0, 7); + fs.writeFileSync("./package.json", JSON.stringify(pk, 2)) + } catch (e) {} + } + + global.win = new BrowserWindow({ + width: 1220, + height: 720, + minWidth: 720, + minHeight: 540, + resizeable: true, + resizable: true, + maximizable: true, show: false, enableLargerThanScreen: true, - icon: "logo/logo.png", - backgroundColor: "#4b4e50", + icon: logo, + backgroundColor: "#000000", title: "Kartik", webPreferences: { nodeIntegration: true, @@ -371,10 +350,12 @@ const { app, BrowserWindow } = require('electron'); disableBlinkFeatures: "MediaSessionService", } }) - load.loadFile("./views/load.html"); - load.webContents.once('dom-ready', () => { + console.log(" * Loading view"); + win.loadFile('./index.html') + win.setMenu(null); + win.webContents.once('dom-ready', () => { console.log(" * Showing splash screen"); - load.show(); + win.show(); setTimeout(() => { console.log(" * Checking signatures"); @@ -396,7 +377,7 @@ const { app, BrowserWindow } = require('electron'); } processed++; - load.webContents.send('progress', (processed/total)*100); + win.webContents.send('progress', (processed/total)*100); } for (file in sigdb["v2"]) { if (fs.existsSync(file) && !invalidfiles.includes(file)) { @@ -411,7 +392,7 @@ const { app, BrowserWindow } = require('electron'); } processed++; - load.webContents.send('progress', (processed/total)*100); + win.webContents.send('progress', (processed/total)*100); } for (file in sigdb["v3"]) { if (fs.existsSync(file) && !invalidfiles.includes(file)) { @@ -426,7 +407,7 @@ const { app, BrowserWindow } = require('electron'); } processed++; - load.webContents.send('progress', (processed/total)*100); + win.webContents.send('progress', (processed/total)*100); } global.importedTypeScriptFiles = []; @@ -1,6 +1,20 @@ <!DOCTYPE html>
<html lang="en" style="background:#000000;margin:0;height:100%;width:100%;">
<head>
+ <script>
+ require('electron').ipcRenderer.on('ready', (e, a) => {
+ location.hash = "#ready";
+ location.reload();
+ })
+
+ require('electron').ipcRenderer.on('progress', (e, a) => {
+ document.getElementById("bar-inner").style.width = a + "%";
+
+ if (a >= 100) {
+ document.getElementById("bar-outer-outer").style.opacity = "0";
+ }
+ })
+ </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;require('@electron/remote').getCurrentWindow().log(" * Parsing view");}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};</script>
<meta charset="UTF-8">
<title>Kartik</title>
@@ -92,8 +106,14 @@ -webkit-box-orient: vertical;
"></span></div>
<script>if (!native) { document.getElementById('titlebar').style.display = "none"; }</script>
+ <webview id="wb" src="views/loader.html" style="border: 0;z-index:2;top:0;left:0;right:0;bottom:0;position:fixed;opacity:0;transition:opacity 500ms;" nodeintegration disablewebsecurity allowpopups webpreferences="nodeIntegration,contextIsolation=no"></webview>
<script>
- document.write(`<webview id="wb" src="views/loader.html" style="border: 0;z-index:2;top:0;left:0;right:0;bottom:0;position:fixed;" nodeintegration disablewebsecurity allowpopups webpreferences="nodeIntegration,contextIsolation=no"></webview>`);
+ setTimeout(() => {
+ document.getElementById("wb").style.opacity = "1";
+ if (location.hash !== "#ready") {
+ document.getElementById("bar-outer-outer").style.opacity = "1";
+ }
+ }, 1500)
</script>
<script src="./views/script/core_chart.js"></script>
<script src="./views/script/core_music.js"></script>
@@ -119,6 +139,12 @@ </style>
</div>
+ <div id="bar-outer-outer" style="z-index:99;position:fixed;inset:0;display:flex;justify-content: center;align-items: center;margin-top:120px;opacity:0;transition:opacity 500ms;">
+ <div id="bar-outer" style="background:#c2c2c2;width:256px;height:5px;border-radius:999px;">
+ <div id="bar-inner" style="background:#a0a0a0;width:0;height:5px;border-radius:999px;"></div>
+ </div>
+ </div>
+
<script src="./views/script/core_crash.js"></script>
</body>
</html>
diff --git a/lang/loader.js b/lang/loader.js index b28e004..205d898 100644 --- a/lang/loader.js +++ b/lang/loader.js @@ -35,12 +35,26 @@ if (typeof native === "boolean" && !native) { global.lang = JSON.parse(window.fetch("./lang/" + lp + ".json").toString());
}
} else {
- try {
- global.lp = require('electron').remote.getCurrentWindow().lp.trim();
- global.lang = JSON.parse(require('fs').readFileSync("./lang/" + lp + ".json").toString());
- } catch (e) {
- console.error(e);
- global.lp = "en";
- global.lang = JSON.parse(require('fs').readFileSync("./lang/" + lp + ".json").toString());
+ if (typeof webview !== "undefined") {
+ console.log("Delaying language files loading");
+ if (location.hash === "#ready") {
+ try {
+ global.lp = require('electron').remote.getCurrentWindow().lp.trim();
+ global.lang = JSON.parse(require('fs').readFileSync("./lang/" + lp + ".json").toString());
+ } catch (e) {
+ console.error(e);
+ global.lp = "en";
+ global.lang = JSON.parse(require('fs').readFileSync("./lang/" + lp + ".json").toString());
+ }
+ }
+ } else {
+ try {
+ global.lp = require('electron').remote.getCurrentWindow().lp.trim();
+ global.lang = JSON.parse(require('fs').readFileSync("./lang/" + lp + ".json").toString());
+ } catch (e) {
+ console.error(e);
+ global.lp = "en";
+ global.lang = JSON.parse(require('fs').readFileSync("./lang/" + lp + ".json").toString());
+ }
}
}
diff --git a/typescript/mainloader.js b/typescript/mainloader.js index 32c1144..317c95a 100644 --- a/typescript/mainloader.js +++ b/typescript/mainloader.js @@ -1,4 +1,4 @@ -window.addEventListener("load", () => {
+if (location.hash === "#ready") {
files = require('@electron/remote').getCurrentWindow().modsfiles;
global.HTML = window;
@@ -7,4 +7,4 @@ window.addEventListener("load", () => { script.src = "file://" + file.replaceAll("\\", "/");
document.head.appendChild(script)
}
-})
\ No newline at end of file +}
\ No newline at end of file diff --git a/views/loader.html b/views/loader.html index 25124bb..9cef2b5 100644 --- a/views/loader.html +++ b/views/loader.html @@ -24,11 +24,14 @@ </script>
<div id="banner-outer" style="display:flex;align-items:center;justify-content:center;inset: 0;height: 100%;background:#f4f3f4;overflow:hidden;">
- <img id="banner" src="../logo/full-alt.png" alt="" style="display:none;height:auto;width:380px;">
- <script>
- const $ = require('jquery');
- $("#banner").fadeIn(200);
- </script>
+ <img id="banner" src="../logo/full-alt.png" alt="" style="height:auto;width:380px;">
+ <div id="banner-decoration" style="width: 50px;height: 162px;position: relative;left: -452px;transform: rotate(-45deg);background: #f4f3f4;filter: blur(10px);animation-name: deco;animation-duration: 2s;animation-timing-function: linear;animation-iteration-count: infinite;opacity:.5;display:none;"></div>
+ <style>
+ @keyframes deco {
+ 0% { left: -472px; }
+ 100% { left: 1220px; }
+ }
+ </style>
</div>
<video style="display: none;position:fixed;inset:0;width: 100%;height: 100%;background: #f4f3f4;" id="intro-video">
<source src="intro.mp4">
diff --git a/views/script/core_fullscreen.js b/views/script/core_fullscreen.js index f2c540d..d45cccf 100644 --- a/views/script/core_fullscreen.js +++ b/views/script/core_fullscreen.js @@ -1,40 +1,42 @@ window.addEventListener("load", () => { require('@electron/remote').getCurrentWindow().show(); - const Nest = require("./nest/abi"); + if (location.hash === "#ready") { + const Nest = require("./nest/abi"); - $(document).keydown(function(e) { - if (e.keyCode === 122 || e.keyCode === 121 || e.keyCode === 112) { // 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); + $(document).keydown(function(e) { + if (e.keyCode === 122 || e.keyCode === 121 || e.keyCode === 112) { // 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); + } } - } - }) + }) - $(document).keydown(function(e) { - currentNest = Nest.load(homedir + "/.kartik/current.kfn"); + $(document).keydown(function(e) { + currentNest = Nest.load(homedir + "/.kartik/current.kfn"); - if (e.keyCode === 122 || e.keyCode === 121 || e.keyCode === 112) { - if (currentNest.config.fullscreen) { - currentNest.config.fullscreen = false; - Nest.export(homedir + "/.kartik/current.kfn", currentNest); - require('electron').ipcRenderer.send("reloadNest") - } else { - currentNest.config.fullscreen = true; - Nest.export(homedir + "/.kartik/current.kfn", currentNest); - require('electron').ipcRenderer.send("reloadNest"); + if (e.keyCode === 122 || e.keyCode === 121 || e.keyCode === 112) { + if (currentNest.config.fullscreen) { + currentNest.config.fullscreen = false; + Nest.export(homedir + "/.kartik/current.kfn", currentNest); + require('electron').ipcRenderer.send("reloadNest") + } else { + currentNest.config.fullscreen = true; + Nest.export(homedir + "/.kartik/current.kfn", currentNest); + require('electron').ipcRenderer.send("reloadNest"); + } } - } - }) + }) - currentNest = Nest.load(homedir + "/.kartik/current.kfn"); - if (currentNest.config.fullscreen) { - require('@electron/remote').getCurrentWindow().setFullScreen(true); - } else { - currentNest.config.fullscreen = false; - Nest.export(homedir + "/.kartik/current.kfn", currentNest); - require('electron').ipcRenderer.send("reloadNest") + currentNest = Nest.load(homedir + "/.kartik/current.kfn"); + if (currentNest.config.fullscreen) { + require('@electron/remote').getCurrentWindow().setFullScreen(true); + } else { + currentNest.config.fullscreen = false; + Nest.export(homedir + "/.kartik/current.kfn", currentNest); + require('electron').ipcRenderer.send("reloadNest") + } } })
\ No newline at end of file diff --git a/views/script/core_music.js b/views/script/core_music.js index 464fc85..99d5455 100644 --- a/views/script/core_music.js +++ b/views/script/core_music.js @@ -1,116 +1,115 @@ -/*global.csng = null; -global.csp1 = null; -global.csp2 = null; -global.cspn = 1;*/ -global.musicElement = new Audio(); -const musicIpc = require('electron').ipcRenderer; +if (location.hash === "#ready") { + global.musicElement = new Audio(); + const musicIpc = require('electron').ipcRenderer; -musicIpc.on('setmusic', (event, args) => { - musicElement.src = args; - musicElement.play(); - musicElement.volume = 1; - musicElement.loop = true; - /*if (!musicElement.paused) { - csi1 = setInterval(() => { - if (musicElement.volume <= 0.05) { - clearInterval(csi1); - musicElement.src = args; - musicElement.play(); - musicElement.volume = 0; + musicIpc.on('setmusic', (event, args) => { + musicElement.src = args; + musicElement.play(); + musicElement.volume = 1; + musicElement.loop = true; + /*if (!musicElement.paused) { + csi1 = setInterval(() => { + if (musicElement.volume <= 0.05) { + clearInterval(csi1); + musicElement.src = args; + musicElement.play(); + musicElement.volume = 0; + csi2 = setInterval(() => { + if (musicElement.volume >= 0.95) { + clearInterval(csi2); + return; + } + musicElement.volume = musicElement.volume + 0.05; + }, 100) + return; + } + musicElement.volume = musicElement.volume - 0.05; + }, 100) + } else { + musicElement.src = args; + musicElement.play(); + }*/ + /*try { csp1.volume = 0; } catch (e) {} + try { csp2.volume = 0; } catch (e) {} + song = args; + + if (song !== null && song !== "" && csng !== song) { + if (cspn === 1) { + if (csp1 !== null) { + csi1 = setInterval(() => { + if (csp1.volume <= 0.05) { + csp1.pause(); + csp1.volume = 0; + clearInterval(csi1); + return; + } + csp1.volume = csp1.volume - 0.05; + }, 100) + } + csp2 = new Audio(song); + csp2.volume = 0; + csp2.loop = true; + csp2.play(); csi2 = setInterval(() => { - if (musicElement.volume >= 0.95) { + if (csp2.volume >= 0.95) { clearInterval(csi2); return; } - musicElement.volume = musicElement.volume + 0.05; + csp2.volume = csp2.volume + 0.05; }, 100) - return; - } - musicElement.volume = musicElement.volume - 0.05; - }, 100) - } else { - musicElement.src = args; - musicElement.play(); - }*/ - /*try { csp1.volume = 0; } catch (e) {} - try { csp2.volume = 0; } catch (e) {} - song = args; - - if (song !== null && song !== "" && csng !== song) { - if (cspn === 1) { - if (csp1 !== null) { + csng = song; + cspn = 2; + } else { + if (csp2 !== null) { + csi2 = setInterval(() => { + if (csp2.volume <= 0.05) { + csp2.pause(); + csp2.volume = 0; + clearInterval(csi2); + return; + } + csp2.volume = csp2.volume - 0.05; + }, 100) + } + csp1 = new Audio(song); + csp1.volume = 0; + csp1.loop = true; + csp1.play(); csi1 = setInterval(() => { - if (csp1.volume <= 0.05) { - csp1.pause(); - csp1.volume = 0; + if (csp1.volume >= 0.95) { clearInterval(csi1); return; } - csp1.volume = csp1.volume - 0.05; + csp1.volume = csp1.volume + 0.05; }, 100) + csng = song; + cspn = 1; } - csp2 = new Audio(song); - csp2.volume = 0; - csp2.loop = true; - csp2.play(); - csi2 = setInterval(() => { - if (csp2.volume >= 0.95) { - clearInterval(csi2); + }*/ + }) + + musicIpc.on('fademusic', (event) => { + if (!musicElement.paused) { + csi1 = setInterval(() => { + if (musicElement.volume <= 0.3) { + clearInterval(csi1); return; } - csp2.volume = csp2.volume + 0.05; + musicElement.volume = musicElement.volume - 0.05; }, 100) - csng = song; - cspn = 2; - } else { - if (csp2 !== null) { - csi2 = setInterval(() => { - if (csp2.volume <= 0.05) { - csp2.pause(); - csp2.volume = 0; - clearInterval(csi2); - return; - } - csp2.volume = csp2.volume - 0.05; - }, 100) - } - csp1 = new Audio(song); - csp1.volume = 0; - csp1.loop = true; - csp1.play(); + } + }) + + musicIpc.on('unfademusic', (event) => { + if (!musicElement.paused) { csi1 = setInterval(() => { - if (csp1.volume >= 0.95) { + if (musicElement.volume >= 0.95) { clearInterval(csi1); return; } - csp1.volume = csp1.volume + 0.05; + musicElement.volume = musicElement.volume + 0.05; }, 100) - csng = song; - cspn = 1; } - }*/ -}) + }) -musicIpc.on('fademusic', (event) => { - if (!musicElement.paused) { - csi1 = setInterval(() => { - if (musicElement.volume <= 0.3) { - clearInterval(csi1); - return; - } - musicElement.volume = musicElement.volume - 0.05; - }, 100) - } -}) - -musicIpc.on('unfademusic', (event) => { - 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/views/script/core_viewer.js b/views/script/core_viewer.js index eac3766..a538b99 100644 --- a/views/script/core_viewer.js +++ b/views/script/core_viewer.js @@ -2,9 +2,14 @@ const webview = document.getElementById('wb'); try { webview.addEventListener('dom-ready', () => { - document.getElementById('dummyloader').style.display = "none"; + 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) { diff --git a/views/script/loader_global.js b/views/script/loader_global.js index 3a35d54..81b4dd7 100644 --- a/views/script/loader_global.js +++ b/views/script/loader_global.js @@ -1,4 +1,8 @@ -window.addEventListener('load', () => {
+const $ = require('jquery');
+
+require('electron').ipcRenderer.on('ready', (e, a) => {
+ document.getElementById("banner-decoration").style.display = "";
+
setTimeout(() => {
if (native) {
setTimeout(() => {
|