diff options
-rw-r--r-- | index.html | 4 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | race/cars/car1.js | 180 | ||||
-rw-r--r-- | race/pause.js | 2 | ||||
-rw-r--r-- | views/common/blur.css | 3 | ||||
-rw-r--r-- | views/common/compatibilityMode.css | 10 | ||||
-rw-r--r-- | views/common/fonts.css | 2 | ||||
-rw-r--r-- | views/credits.html | 2 | ||||
-rw-r--r-- | views/game.html | 2 | ||||
-rw-r--r-- | views/intro.html | 2 | ||||
-rw-r--r-- | views/loader.html | 3 | ||||
-rw-r--r-- | views/menu.html | 24 | ||||
-rw-r--r-- | views/online.html | 2 | ||||
-rw-r--r-- | views/script/core_chart.js | 19 | ||||
-rw-r--r-- | views/script/core_compatlayer.js | 89 | ||||
-rw-r--r-- | views/script/core_music.js | 1 | ||||
-rw-r--r-- | views/script/global_compatlayer.js | 89 | ||||
-rw-r--r-- | views/script/menu_gpuinfo.js | 115 | ||||
-rw-r--r-- | views/settings.html | 2 | ||||
-rw-r--r-- | views/stats.html | 2 | ||||
-rw-r--r-- | views/win.html | 2 |
21 files changed, 442 insertions, 115 deletions
@@ -9,6 +9,7 @@ <link rel="stylesheet" href="./views/common/fonts.css"> <link rel="stylesheet" href="./views/common/index.css"> <script src="./views/script/core_head.js"></script> + <script src="./views/script/core_compatlayer.js"></script> <script src="./views/script/core_fullscreen.js"></script> <script> if (native) { @@ -85,9 +86,6 @@ <script>if (!native) { document.getElementById('titlebar').style.display = "none"; }</script> <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>`); - if (require('@electron/remote').getCurrentWindow().update !== "stable") { - document.write(`<div style="position: fixed;top: 10px;left: 10px;right: 10px;height: auto;font-size: 10px;background: rgba(255, 0, 0, .5);z-index: 9;text-align: center;color: white;border-radius: 999px;">Experimental Build:${require('@electron/remote').getCurrentWindow().channel}${require('./package.json').version}, do not use in production | SKU: <span style="font-family:monospace;font-size:12px;" id="experimental-sku">KRTK-1@${require('./package.json').serial}</span> | Mem: <span style="font-family:monospace;font-size:12px;" id="experimental-ramusage">NaN</span> MiB</div>`); - } </script> </div> <script src="./views/script/core_chart.js"></script> diff --git a/package.json b/package.json index 14ff2aa..234368b 100644 --- a/package.json +++ b/package.json @@ -1 +1 @@ -{"name":"kartik","version":"f296180","channel":"git","description":"A multiplatform 2D karting game","main":"app.js","dependencies":{"@electron/remote":"^1.0.4","discord-rpc":"^3.2.0","electron":"^12.0.1","ini":"^1.3.8","jquery":"^3.6.0","os-locale":"^5.0.0","uuid":"^8.3.2","yaml":"^1.10.2"},"scripts":{"test":"node_modules\\electron\\dist\\electron.exe app.js"},"author":"Minteck Projects","license":"GPL-3.0-or-later","serial":"XXX99999999999"}
\ No newline at end of file +{"name":"kartik","version":"ce99cfa","channel":"git","description":"A multiplatform 2D karting game","main":"app.js","dependencies":{"@electron/remote":"^1.0.4","discord-rpc":"^3.2.0","electron":"^12.0.1","ini":"^1.3.8","jquery":"^3.6.0","os-locale":"^5.0.0","systeminformation":"^5.7.7","uuid":"^8.3.2","yaml":"^1.10.2"},"scripts":{"test":"node_modules\\electron\\dist\\electron.exe app.js"},"author":"Minteck Projects","license":"GPL-3.0-or-later","serial":"XXX99999999999"}
\ No newline at end of file diff --git a/race/cars/car1.js b/race/cars/car1.js index 0c4c9f0..448008c 100644 --- a/race/cars/car1.js +++ b/race/cars/car1.js @@ -8,11 +8,7 @@ startHooks.push(() => { car1startx = 388.9; car1starty = 79.4; } - if (online) { - car1collisionon = false; - } else { - car1collisionon = true; - } + car1collisionon = !online; car1enableOOBChecker = false; // Collision Manager @@ -20,7 +16,7 @@ startHooks.push(() => { if (!keysEnabled) { return; } if (started) { - carshb = document.getElementById("car0").getBoundingClientRect(); + carshb = document.getElementById("car1").getBoundingClientRect(); hitbox = document.getElementById("barrier").getBoundingClientRect(); var overlap = !(carshb.right < hitbox.left || @@ -28,12 +24,16 @@ startHooks.push(() => { carshb.bottom < hitbox.top || carshb.top > hitbox.bottom) - if (overlap) { - info("CarManager:car0", "Reversal prevented at X " + document.getElementById("car0").style.left + ", Y " + document.getElementById("car0").style.top); - document.getElementById("car0").style.left = car0startx + "px"; - document.getElementById("car0").style.top = car0starty + "px"; - document.getElementById("car0").style.transform = "rotate(0deg)"; - car0cspeed = 0; + if (overlap && car1collisionon) { + info("CarManager:car0", "Reversal prevented at X " + document.getElementById("car1").style.left + ", Y " + document.getElementById("car1").style.top); + car1collisionon = false; + document.getElementById("car1").style.left = car1startx + "px"; + document.getElementById("car1").style.top = car1starty + "px"; + document.getElementById("car1").style.transform = "rotate(0deg)"; + car1cspeed = 0; + setTimeout(() => { + car1collisionon = true; + }, 500) } } @@ -55,14 +55,18 @@ startHooks.push(() => { if (location.search === "?sp") { scenar("wall2", "angry"); } - Sound.crash() + car1collisionon = false; + Sound.crash(); document.getElementById("car1").style.left = car1startx + "px"; document.getElementById("car1").style.top = car1starty + "px"; + document.getElementById("car1").style.transform = "rotate(0deg)"; Array.from(document.getElementById('oil').children).forEach((item) => { spreadOil(item); }) - document.getElementById("car1").style.transform = "rotate(0deg)"; car1cspeed = 0; + setTimeout(() => { + car1collisionon = true; + }, 500) } }) @@ -76,79 +80,11 @@ startHooks.push(() => { carshb.top > hitbox.bottom) if (overlap) { - car1cspeed = 7; + car1cspeed = 5; } }) carshb = document.getElementById("car1").getBoundingClientRect(); - hitbox = document.getElementById("arrival").getBoundingClientRect(); - - var overlap = !(carshb.right < hitbox.left || - carshb.left > hitbox.right || - carshb.bottom < hitbox.top || - carshb.top > hitbox.bottom) - - if (overlap && started) { - started = false; - if ((document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1) < 4) { - info("CarManager:car1", "New lap"); - Array.from(document.getElementById('oil').children).forEach((item) => { - spreadOil(item); - }) - if ((document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1) < 3) { - Sound.pass() - } else { - Sound.last() - } - document.getElementById('laps-car1').innerText = (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 2).toString(); - if (location.search === "?sp") { - if ((document.getElementById('laps-car0').innerText.split("/")[0] - 1 + 1) > (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1)) { - scenar("ahead1", "angry"); - } else { - scenar("ahead2", "happy"); - } - } - } else { - info("CarManager:car1", "Car won the game"); - if (location.search === "?sp") { - scenar("won2", "happy"); - } - require('electron').ipcRenderer.send('addstats', { catalog: "results", key: "loses", add: 1 }); - try { document.getElementById('music').src = "about:blank"; } catch (e) { console.error(e); } - Sound.win(); - keysEnabled = false; - car1cspeed = 0; - car1speed = 0; - document.getElementById('laps-car1').innerText = (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 2).toString(); - $("#box").fadeOut(500); - setTimeout(() => { - setTimeout(() => { - if (location.search === "?sp" || (online && role === "guest")) { - if (online) {} else { - location.href = "win.html?sp#car1"; - } - } else { - location.href = "win.html#car1"; - } - }, 3500) - }, 3000) - } - document.getElementById("car1").style.left = car1startx + "px"; - document.getElementById("car1").style.top = car1starty + "px"; - Array.from(document.getElementById('oil').children).forEach((item) => { - spreadOil(item); - }) - document.getElementById("car1").style.transform = "rotate(0deg)"; - Array.from(document.getElementById('oil').children).forEach((item) => { - spreadOil(item); - }) - car1cspeed = 0; - setTimeout(() => { - started = true; - }, 150) - } - - carshb = document.getElementById("car1").getBoundingClientRect(); hitbox = document.getElementById("car0").getBoundingClientRect(); var overlap = !(carshb.right < hitbox.left || @@ -160,6 +96,7 @@ startHooks.push(() => { if (location.search === "?sp") { scenar("wall2", "angry"); } + car1collisionon = false; Sound.crash(); document.getElementById("car1").style.left = car1startx + "px"; document.getElementById("car1").style.top = car1starty + "px"; @@ -168,6 +105,9 @@ startHooks.push(() => { spreadOil(item); }) car1cspeed = 0; + setTimeout(() => { + car1collisionon = true; + }, 500) } } @@ -222,4 +162,78 @@ startHooks.push(() => { } }, 200) + setInterval(() => { + if (!car1collisionon) { return; } + + carshb = document.getElementById("car1").getBoundingClientRect(); + hitbox = document.getElementById("arrival").getBoundingClientRect(); + + var overlap = !(carshb.right < hitbox.left || + carshb.left > hitbox.right || + carshb.bottom < hitbox.top || + carshb.top > hitbox.bottom) + + if (overlap && started) { + started = false; + if ((document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1) < 4) { + info("CarManager:car1", "New lap"); + Array.from(document.getElementById('oil').children).forEach((item) => { + spreadOil(item); + }) + if ((document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1) < 3) { + Sound.pass() + } else { + Sound.last() + } + document.getElementById('laps-car1').innerText = (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 2).toString(); + if (location.search === "?sp") { + if ((document.getElementById('laps-car0').innerText.split("/")[0] - 1 + 1) > (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 1)) { + scenar("ahead1", "angry"); + } else { + scenar("ahead2", "happy"); + } + } + } else { + info("CarManager:car1", "Car won the game"); + if (location.search === "?sp") { + scenar("won2", "happy"); + } + require('electron').ipcRenderer.send('addstats', { catalog: "results", key: "loses", add: 1 }); + try { document.getElementById('music').src = "about:blank"; } catch (e) { console.error(e); } + Sound.win(); + keysEnabled = false; + car1cspeed = 0; + car1speed = 0; + document.getElementById('laps-car1').innerText = (document.getElementById('laps-car1').innerText.split("/")[0] - 1 + 2).toString(); + $("#box").fadeOut(500); + setTimeout(() => { + setTimeout(() => { + if (location.search === "?sp" || (online && role === "guest")) { + if (online) {} else { + location.href = "win.html?sp#car1"; + } + } else { + location.href = "win.html#car1"; + } + }, 3500) + }, 3000) + } + car1collisionon = false; + Sound.crash(); + document.getElementById("car1").style.left = car1startx + "px"; + document.getElementById("car1").style.top = car1starty + "px"; + document.getElementById("car1").style.transform = "rotate(0deg)"; + Array.from(document.getElementById('oil').children).forEach((item) => { + spreadOil(item); + }) + car1cspeed = 0; + setTimeout(() => { + car1collisionon = true; + }, 500) + setTimeout(() => { + started = true; + }, 150) + } + }, 20) + })
\ No newline at end of file diff --git a/race/pause.js b/race/pause.js index d1ee002..92a78a6 100644 --- a/race/pause.js +++ b/race/pause.js @@ -27,7 +27,6 @@ startHooks.push(() => { paused = true; document.getElementById('box').classList.add('paused'); $("#paused").show(); - $("#credits").show(); } else { if (location.search === "?sp") { require('@electron/remote').getCurrentWindow().dstate = lang.discord.game[0]; @@ -53,7 +52,6 @@ startHooks.push(() => { paused = false; document.getElementById('box').classList.remove('paused'); $("#paused").hide(); - $("#credits").hide(); } } diff --git a/views/common/blur.css b/views/common/blur.css new file mode 100644 index 0000000..f904c12 --- /dev/null +++ b/views/common/blur.css @@ -0,0 +1,3 @@ +#intro, #laps-inner-car0, #laps-inner-car1, #paused, #credits, #gpuinfo, #warning { + backdrop-filter: blur(10px); +}
\ No newline at end of file diff --git a/views/common/compatibilityMode.css b/views/common/compatibilityMode.css new file mode 100644 index 0000000..a436549 --- /dev/null +++ b/views/common/compatibilityMode.css @@ -0,0 +1,10 @@ +*:not(#gpuinfo-outer):not(#gpuinfo-inner) { + backdrop-filter: none !important; + transition: none !important; + opacity: 1 !important; + animation: none !important; +} + +.rain { + display: none !important; +}
\ No newline at end of file diff --git a/views/common/fonts.css b/views/common/fonts.css index 190dd75..5aa99e0 100644 --- a/views/common/fonts.css +++ b/views/common/fonts.css @@ -14,7 +14,7 @@ font-family: "Comfortaa", -apple-system, sans-serif; } -#gpuinfo, #gpuinfo * { +#gpuinfo-inner, #gpuinfo-inner * { font-family: monospace !important; } diff --git a/views/credits.html b/views/credits.html index edd4a2d..ece63a3 100644 --- a/views/credits.html +++ b/views/credits.html @@ -6,9 +6,11 @@ <script src="../scenario/client.js"></script> <meta charset="UTF-8"> <link rel="stylesheet" href="common/fonts.css"> + <link rel="stylesheet" href="common/blur.css"> <link rel="stylesheet" href="menu.css"> <title>Kartik</title> <script src="../crash/client.js"></script> + <script src="./script/global_compatlayer.js"></script> <script src="../sfx/sfx.js"></script> <script> require('@electron/remote').getCurrentWindow().dstate = lang.discord.credits[0]; diff --git a/views/game.html b/views/game.html index 023e547..f40b777 100644 --- a/views/game.html +++ b/views/game.html @@ -6,9 +6,11 @@ <script src="../scenario/client.js"></script> <meta charset="UTF-8"> <link rel="stylesheet" href="common/fonts.css"> + <link rel="stylesheet" href="common/blur.css"> <link rel="stylesheet" href="game.css"> <title>Kartik</title> <script src="../crash/client.js"></script> + <script src="./script/global_compatlayer.js"></script> <script src="../sfx/sfx.js"></script> <script> require('@electron/remote').getCurrentWindow().dstate = lang.discord.game[0]; diff --git a/views/intro.html b/views/intro.html index f298cb7..6d4b721 100644 --- a/views/intro.html +++ b/views/intro.html @@ -7,8 +7,10 @@ <meta charset="UTF-8"> <title>Kartik</title> <link rel="stylesheet" href="common/fonts.css"> + <link rel="stylesheet" href="common/blur.css"> <link rel="stylesheet" href="intro.css"> <script src="../crash/client.js"></script> + <script src="./script/global_compatlayer.js"></script> <script> require('@electron/remote').getCurrentWindow().dstate = lang.discord.intro[0]; require('@electron/remote').getCurrentWindow().ddetails = lang.discord.intro[1]; diff --git a/views/loader.html b/views/loader.html index 9e100bb..df008d4 100644 --- a/views/loader.html +++ b/views/loader.html @@ -7,6 +7,7 @@ <meta charset="UTF-8"> <title>Kartik</title> <link rel="stylesheet" href="common/fonts.css"> + <link rel="stylesheet" href="common/blur.css"> <script> if (!require('@electron/remote').getCurrentWindow().debug) { document.write('<link rel="stylesheet" href="common/mouse.css">'); @@ -28,7 +29,7 @@ <script> document.write(`<div style="position: fixed;bottom: 20px;right: 20px;font-size: 12px;padding: 10px 20px;background: lightblue;border-radius: 5px;transition: all 200ms;display:none;" id="updates">${lang.updates.wait}</div>`); </script> - <div id="warning" style="opacity:0;transition:opacity 200ms;position: fixed;background: darkred;color: white;padding: 20px 10px;max-width: 40vw;text-align: center;border-radius: 10px;left: 20vw;top: 30vh;"><h2><script>document.write(lang.updates.warn[0]);</script></h2><p><script>document.write(lang.updates.warn[1]);</script></p></div> + <div id="warning" style="opacity:0;transition:opacity 200ms;position: fixed;background: rgba(139,0,0,0.5);color: white;padding: 20px 10px;max-width: 40vw;text-align: center;border-radius: 10px;left: 20vw;top: 30vh;"><h2><script>document.write(lang.updates.warn[0]);</script></h2><p><script>document.write(lang.updates.warn[1]);</script></p></div> <script src="./script/loader_global.js"></script> <script>info("LoadWindow", "Launching start-up procedure");</script> diff --git a/views/menu.html b/views/menu.html index 661d397..d00107c 100644 --- a/views/menu.html +++ b/views/menu.html @@ -6,9 +6,11 @@ <script src="../scenario/client.js"></script> <meta charset="UTF-8"> <link rel="stylesheet" href="common/fonts.css"> + <link rel="stylesheet" href="common/blur.css"> <link rel="stylesheet" href="menu.css"> <title>Kartik</title> <script src="../crash/client.js"></script> + <script src="./script/global_compatlayer.js"></script> <script src="../sfx/sfx.js"></script> <link rel="stylesheet" href="rain/rainstyle.css"> <script> @@ -55,16 +57,26 @@ </div> </div> - <div style="font-family:monospace;position: fixed;right: 16px;top: 16px;color: white;font-size: 10px;text-align:left;z-index:999999999;" id="gpuinfo"> - <b><u>GPU Supported Features:</u></b><br> - <div id="gpuinfo-outer">Hold Shift to view</div> - <div id="gpuinfo-inner" style="opacity:0;"> - <script src="./script/menu_gpuinfo.js"></script> + <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"> + <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> </div> + <span id="gpusupportperc" style="display: block;text-align: center;">0%</span> + <div id="gpuinfo-model" style="opacity: .25;padding-top: 5px;text-align: center;">Generic GPU</div> + <div id="gpuinfo-vram" style="opacity: .25;padding-top: 5px;text-align: center;">0 MiB VRAM</div> + <span id="gpuinfo-details" style="border-top:1px solid rgba(255, 255, 255, .25);"> + <div id="gpuinfo-outer" style="opacity: .25;padding-top: 5px;text-align: center;">↓ Hold Shift for details</div> + <div id="gpuinfo-inner" style="font-family:monospace;opacity:0;height:0;"> + <script src="./script/menu_gpuinfo.js"></script> + </div> + </span> <script> if (require('@electron/remote').getCurrentWindow().update === "stable") { - document.getElementById('gpuinfo').style.display = "none"; + document.getElementById('gpuinfo-outer').style.display = "none"; + document.getElementById('gpuinfo-inner').style.display = "none"; + document.getElementById('gpuinfo-details').style.display = "none"; } </script> diff --git a/views/online.html b/views/online.html index ab8e61d..ac90e7e 100644 --- a/views/online.html +++ b/views/online.html @@ -7,7 +7,9 @@ <meta charset="UTF-8"> <title>Kartik</title> <link rel="stylesheet" href="common/fonts.css"> + <link rel="stylesheet" href="common/blur.css"> <script src="../crash/client.js"></script> + <script src="./script/global_compatlayer.js"></script> <script src="../sfx/sfx.js"></script> <script> if (!require('@electron/remote').getCurrentWindow().debug) { diff --git a/views/script/core_chart.js b/views/script/core_chart.js index d34ce21..059c818 100644 --- a/views/script/core_chart.js +++ b/views/script/core_chart.js @@ -62,24 +62,9 @@ setInterval(() => { } if (require('./package.json').channel === "git") { - if (currentMemory < 100) { - document.getElementById('experimental-ramusage').innerText = "0" + currentMemoryMib; - } else { - document.getElementById('experimental-ramusage').innerText = currentMemoryMib; - } - buff = Buffer.from(activity, 'utf-8').toString("hex"); - document.title="Kartik Trunk " +require('./package.json').version + "-" + require('./package.json').serial.toLowerCase() + "-debugkeys - <Debugging On>"; + document.title="Kartik Trunk " +require('./package.json').version; } else { - if (require('./package.json').channel !== "stable") { - if (currentMemory < 100) { - document.getElementById('experimental-ramusage').innerText = "0" + currentMemoryMib; - } else { - document.getElementById('experimental-ramusage').innerText = currentMemoryMib; - } - document.title="Kartik"+require('@electron/remote').getCurrentWindow().channel+require('./package.json').version + eaid; - } else { - document.title="Kartik"+require('@electron/remote').getCurrentWindow().channel+require('./package.json').version + eaid; - } + document.title="Kartik"+require('@electron/remote').getCurrentWindow().channel+require('./package.json').version + eaid; } } catch (e) {} }, 1000)
\ No newline at end of file diff --git a/views/script/core_compatlayer.js b/views/script/core_compatlayer.js new file mode 100644 index 0000000..206aa28 --- /dev/null +++ b/views/script/core_compatlayer.js @@ -0,0 +1,89 @@ +window.addEventListener("load", () => { + if (require('os').platform !== "darwin") { + gpuinfo = require('@electron/remote').app.getGPUFeatureStatus(); + gpuscore = 0; + maxscore = 10; + if (gpuinfo['2d_canvas'].startsWith("enabled")) { + if (gpuinfo['2d_canvas'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['gpu_compositing'].startsWith("enabled")) { + if (gpuinfo['gpu_compositing'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['video_decode'].startsWith("enabled")) { + if (gpuinfo['video_decode'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['multiple_raster_threads'].startsWith("enabled")) { + if (gpuinfo['multiple_raster_threads'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['oop_rasterization'].startsWith("enabled")) { + if (gpuinfo['oop_rasterization'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['rasterization'].startsWith("enabled")) { + if (gpuinfo['rasterization'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['opengl'].startsWith("enabled")) { + if (gpuinfo['opengl'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['skia_renderer'].startsWith("enabled")) { + if (gpuinfo['skia_renderer'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['vulkan'].startsWith("enabled")) { + if (gpuinfo['vulkan'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['webgl'].startsWith("enabled")) { + if (gpuinfo['webgl'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + + gpuperct = (gpuscore / maxscore) * 100; + + if (gpuperct < 50) { + console.warn("Bad GPU support, disabling GPU-accelerated content"); + var head = document.getElementsByTagName('HEAD')[0]; + var link = document.createElement('link'); + link.rel = 'stylesheet'; + link.type = 'text/css'; + link.href = './views/common/compatibilityMode.css'; + head.appendChild(link); + } + } +})
\ No newline at end of file diff --git a/views/script/core_music.js b/views/script/core_music.js index a35d329..464fc85 100644 --- a/views/script/core_music.js +++ b/views/script/core_music.js @@ -9,6 +9,7 @@ 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) { diff --git a/views/script/global_compatlayer.js b/views/script/global_compatlayer.js new file mode 100644 index 0000000..8545a29 --- /dev/null +++ b/views/script/global_compatlayer.js @@ -0,0 +1,89 @@ +window.addEventListener("load", () => { + if (require('os').platform !== "darwin") { + gpuinfo = require('@electron/remote').app.getGPUFeatureStatus(); + gpuscore = 0; + maxscore = 10; + if (gpuinfo['2d_canvas'].startsWith("enabled")) { + if (gpuinfo['2d_canvas'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['gpu_compositing'].startsWith("enabled")) { + if (gpuinfo['gpu_compositing'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['video_decode'].startsWith("enabled")) { + if (gpuinfo['video_decode'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['multiple_raster_threads'].startsWith("enabled")) { + if (gpuinfo['multiple_raster_threads'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['oop_rasterization'].startsWith("enabled")) { + if (gpuinfo['oop_rasterization'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['rasterization'].startsWith("enabled")) { + if (gpuinfo['rasterization'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['opengl'].startsWith("enabled")) { + if (gpuinfo['opengl'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['skia_renderer'].startsWith("enabled")) { + if (gpuinfo['skia_renderer'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['vulkan'].startsWith("enabled")) { + if (gpuinfo['vulkan'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['webgl'].startsWith("enabled")) { + if (gpuinfo['webgl'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + + gpuperct = (gpuscore / maxscore) * 100; + + if (gpuperct < 50) { + console.warn("Bad GPU support, disabling GPU-accelerated content"); + var head = document.getElementsByTagName('HEAD')[0]; + var link = document.createElement('link'); + link.rel = 'stylesheet'; + link.type = 'text/css'; + link.href = './common/compatibilityMode.css'; + head.appendChild(link); + } + } +})
\ No newline at end of file diff --git a/views/script/menu_gpuinfo.js b/views/script/menu_gpuinfo.js index 4177cfc..accf318 100644 --- a/views/script/menu_gpuinfo.js +++ b/views/script/menu_gpuinfo.js @@ -1,3 +1,95 @@ +if (require('os').platform === "darwin") { + document.getElementById("gpuinfo").style.display = "none"; +} + +if (require('os').platform !== "darwin") { + gpuinfo = require('@electron/remote').app.getGPUFeatureStatus(); + gpuscore = 0; + maxscore = 10; + if (gpuinfo['2d_canvas'].startsWith("enabled")) { + if (gpuinfo['2d_canvas'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['gpu_compositing'].startsWith("enabled")) { + if (gpuinfo['gpu_compositing'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['video_decode'].startsWith("enabled")) { + if (gpuinfo['video_decode'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['multiple_raster_threads'].startsWith("enabled")) { + if (gpuinfo['multiple_raster_threads'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['oop_rasterization'].startsWith("enabled")) { + if (gpuinfo['oop_rasterization'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['rasterization'].startsWith("enabled")) { + if (gpuinfo['rasterization'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['opengl'].startsWith("enabled")) { + if (gpuinfo['opengl'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['skia_renderer'].startsWith("enabled")) { + if (gpuinfo['skia_renderer'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['vulkan'].startsWith("enabled")) { + if (gpuinfo['vulkan'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + if (gpuinfo['webgl'].startsWith("enabled")) { + if (gpuinfo['webgl'] === "enabled") { + gpuscore++; + } else { + gpuscore += 0.5; + } + } + + gpuperct = (gpuscore/maxscore)*100; + document.getElementById("gpusupportperc").innerText = gpuperct + "%"; + + document.getElementById("gpuinfo_progressbar").style.width = gpuperct + "%"; + if (gpuperct < 50) { + document.getElementById("gpuinfo_progressbar").style.background = "rgba(128, 0, 0, .5)"; + } else if (gpuperct < 75) { + document.getElementById("gpuinfo_progressbar").style.background = "rgba(128, 128, 0, .5)"; + } else { + document.getElementById("gpuinfo_progressbar").style.background = "rgba(0, 128, 0, .5)"; + } +} + if (require('os').platform !== "darwin") { gpuinfo = require('@electron/remote').app.getGPUFeatureStatus(); document.write("kartik<br>"); @@ -39,6 +131,11 @@ if (require('os').platform !== "darwin") { } else { document.write(" ├ <span style='color:lightcoral;'>kartik.renderer.OpenGL</span><br>"); } + if (gpuinfo['webgl'].startsWith("enabled")) { + document.write(" ├ <span style='color:lightgreen;'>kartik.renderer.WebGL</span><br>"); + } else { + document.write(" ├ <span style='color:lightcoral;'>kartik.renderer.WebGL</span><br>"); + } if (gpuinfo['skia_renderer'].startsWith("enabled")) { document.write(" ├ <span style='color:lightgreen;'>kartik.renderer.Skia</span><br>"); } else { @@ -56,14 +153,30 @@ if (require('os').platform !== "darwin") { document.onkeydown = (e) => { if (e.shiftKey) { document.getElementById('gpuinfo-inner').style.opacity = "1"; + document.getElementById('gpuinfo-inner').style.height = "max-content"; document.getElementById('gpuinfo-outer').style.display = "none"; } else { document.getElementById('gpuinfo-inner').style.opacity = "0"; + document.getElementById('gpuinfo-inner').style.height = "0"; document.getElementById('gpuinfo-outer').style.display = ""; } } document.onkeyup = (e) => { document.getElementById('gpuinfo-inner').style.opacity = "0"; + document.getElementById('gpuinfo-inner').style.height = "0"; document.getElementById('gpuinfo-outer').style.display = ""; -}
\ No newline at end of file +} + +require('systeminformation').graphics().then((data) => { + document.getElementById("gpuinfo-model").innerText = data.controllers[0].model; + vram = data.controllers[0].vram; + + if (vram > 1024) { + vrams = (vram/1024).toFixed(1) + " GiB"; + } else { + vrams = (vram).toFixed(1) + " MiB"; + } + + document.getElementById("gpuinfo-vram").innerText = vrams + " VRAM"; +})
\ No newline at end of file diff --git a/views/settings.html b/views/settings.html index 4409ed9..1759d25 100644 --- a/views/settings.html +++ b/views/settings.html @@ -6,9 +6,11 @@ <script src="../scenario/client.js"></script> <meta charset="UTF-8"> <link rel="stylesheet" href="common/fonts.css"> + <link rel="stylesheet" href="common/blur.css"> <link rel="stylesheet" href="menu.css"> <title>Kartik</title> <script src="../crash/client.js"></script> + <script src="./script/global_compatlayer.js"></script> <script src="../sfx/sfx.js"></script> <script> if (!require('@electron/remote').getCurrentWindow().debug) { diff --git a/views/stats.html b/views/stats.html index 4d6d01c..dcb4275 100644 --- a/views/stats.html +++ b/views/stats.html @@ -7,7 +7,9 @@ <meta charset="UTF-8"> <title>Kartik</title> <link rel="stylesheet" href="common/fonts.css"> + <link rel="stylesheet" href="common/blur.css"> <script src="../crash/client.js"></script> + <script src="./script/global_compatlayer.js"></script> <script src="../sfx/sfx.js"></script> <script> if (!require('@electron/remote').getCurrentWindow().debug) { diff --git a/views/win.html b/views/win.html index 1739098..a3cdfb5 100644 --- a/views/win.html +++ b/views/win.html @@ -7,7 +7,9 @@ <meta charset="UTF-8"> <title>Kartik</title> <link rel="stylesheet" href="common/fonts.css"> + <link rel="stylesheet" href="common/blur.css"> <script src="../crash/client.js"></script> + <script src="./script/global_compatlayer.js"></script> <script src="../sfx/sfx.js"></script> <script> if (!require('@electron/remote').getCurrentWindow().debug) { |