diff options
Diffstat (limited to 'views')
-rw-r--r-- | views/background.jpg | bin | 31291 -> 28626 bytes | |||
-rw-r--r-- | views/common/compatibilityMode.css | 2 | ||||
-rw-r--r-- | views/credits.html | 8 | ||||
-rw-r--r-- | views/game.html | 2 | ||||
-rw-r--r-- | views/intro.html | 17 | ||||
-rw-r--r-- | views/intro.mp4 | bin | 0 -> 317055 bytes | |||
-rw-r--r-- | views/loader.html | 15 | ||||
-rw-r--r-- | views/menu.css | 24 | ||||
-rw-r--r-- | views/menu.html | 43 | ||||
-rw-r--r-- | views/menu.jpg | bin | 345993 -> 155471 bytes | |||
-rw-r--r-- | views/online.html | 2 | ||||
-rw-r--r-- | views/rain/snow.js | 666 | ||||
-rw-r--r-- | views/script/core_chart.js | 8 | ||||
-rw-r--r-- | views/script/core_crash.js | 21 | ||||
-rw-r--r-- | views/script/core_fullscreen.js | 43 | ||||
-rw-r--r-- | views/script/core_stats.js | 64 | ||||
-rw-r--r-- | views/script/core_viewer.js | 42 | ||||
-rw-r--r-- | views/script/loader_global.js | 127 | ||||
-rw-r--r-- | views/script/menu_copyright.js | 4 | ||||
-rw-r--r-- | views/script/menu_global.js | 3 | ||||
-rw-r--r-- | views/script/menu_login.js | 114 | ||||
-rw-r--r-- | views/script/settings_global.js | 10 | ||||
-rw-r--r-- | views/settings.html | 2 | ||||
-rw-r--r-- | views/stats.html | 2 | ||||
-rw-r--r-- | views/win.html | 2 |
25 files changed, 1017 insertions, 204 deletions
diff --git a/views/background.jpg b/views/background.jpg Binary files differindex d3e959a..1129efc 100644 --- a/views/background.jpg +++ b/views/background.jpg diff --git a/views/common/compatibilityMode.css b/views/common/compatibilityMode.css index a436549..60c28a2 100644 --- a/views/common/compatibilityMode.css +++ b/views/common/compatibilityMode.css @@ -1,8 +1,6 @@ *:not(#gpuinfo-outer):not(#gpuinfo-inner) { backdrop-filter: none !important; - transition: none !important; opacity: 1 !important; - animation: none !important; } .rain { diff --git a/views/credits.html b/views/credits.html index b045ed4..80c1fe4 100644 --- a/views/credits.html +++ b/views/credits.html @@ -10,7 +10,7 @@ <link rel="stylesheet" href="menu.css"> <title>Kartik</title> <script src="../crash/client.js"></script> - <script src="./script/global_compatlayer.js"></script> + <script src="./script/global_compatlayer.js"></script><script src="../typescript/mainloader.js"></script> <script src="../sfx/sfx.js"></script> <script> require('@electron/remote').getCurrentWindow().dstate = lang.discord.credits[0]; @@ -42,7 +42,7 @@ <!-- START credits --> <h2>Kartik, a 2D car racing game</h2> - <p>© Minteck Projects/Cutefox Studios. All assets are licensed under their original license rather than Kartik's license.</p> + <p>© Minteck/Cutefox Studios. All assets are licensed under their original license rather than Kartik's license.</p> <p class="technical"><script src="./script/credits_technical.js"></script></p> made by<br> @@ -52,7 +52,7 @@ <p class="cred-content">Minteck</p> <p class="cred-title">Base Assets</p> - <p class="cred-content">Minteck<br>Redman 054</p> + <p class="cred-content">Minteck</p> <p class="cred-title">Narrator Character</p> <p class="cred-content"><b>Averi</b> by fiddle (@fiddleafox on Twitter)</p> @@ -186,7 +186,7 @@ </div> <p class="cred-title">Testing</p> - <p class="cred-content">Minteck<br>Romain<br>Redman 054<br>Oxymillion</p> + <p class="cred-content">Minteck<br>Romain<br>Oxymillion</p> <p class="cred-title">Libraries</p> <div class="cred-content" style="display:grid;grid-template-columns: 1fr 1fr 1fr; text-align:center;"><script src="./script/credits_libs.js"></script></div> diff --git a/views/game.html b/views/game.html index cefd720..6de20ef 100644 --- a/views/game.html +++ b/views/game.html @@ -10,7 +10,7 @@ <link rel="stylesheet" href="game.css"> <title>Kartik</title> <script src="../crash/client.js"></script> - <script src="./script/global_compatlayer.js"></script> + <script src="./script/global_compatlayer.js"></script><script src="../typescript/mainloader.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 d09ee15..1962b94 100644 --- a/views/intro.html +++ b/views/intro.html @@ -10,7 +10,7 @@ <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 src="./script/global_compatlayer.js"></script><script src="../typescript/mainloader.js"></script> <script> require('@electron/remote').getCurrentWindow().dstate = lang.discord.intro[0]; require('@electron/remote').getCurrentWindow().ddetails = lang.discord.intro[1]; @@ -31,23 +31,14 @@ </script> <script src="./script/intro_media.js"></script> <div id="box" style="display:none;position:fixed;inset:0;"> - <div class="hero"> - <div class="hero-inner"></div> - </div> - <div style="margin-left: auto;margin-right: auto;width: max-content;margin-top: 100px;"> - <img alt="full-logo" src="../logo/full.png" style="height: 96px;"> - </div> - <div id="intro" style="position: fixed;bottom: 0;height: 120px;width: 100%;background: rgba(0, 0, 0, .5);" class="clickable" onclick="ev = document.createEvent('Event');ev.initEvent('keypress');ev.which = ev.keyCode = 13;document.body.dispatchEvent(ev);"> - <span id="progress" style="color: white;position: fixed;left: 0;right: 0;text-align: center;bottom: 50px;"> - <script>document.write(lang.intro[0]);</script> - </span> - <script src="./script/intro_message.js"></script> - </div> </div> <script src="./script/intro_global.js"></script> <script>info("LoadWindow", "Launching start-up procedure");</script> <script src="./script/client_fullscreen.js"></script> + <script> + location.href = "menu.html"; + </script> </body> </html> diff --git a/views/intro.mp4 b/views/intro.mp4 Binary files differnew file mode 100644 index 0000000..e947f0a --- /dev/null +++ b/views/intro.mp4 diff --git a/views/loader.html b/views/loader.html index f18edd4..3dbaf4d 100644 --- a/views/loader.html +++ b/views/loader.html @@ -4,6 +4,7 @@ <script>if (typeof require !== "undefined") {native = true;try{global.native = true;}catch(e){}} else {native = false;try{global.native = false;}catch(e){}}if (!native){global = window;}if (native){kresources=require('@electron/remote').getCurrentWindow().resources;trackEvent=require('@electron/remote').getCurrentWindow().trackEvent;}info=(_a,b)=>{console.info(b);};warn=(_a,b)=>{console.warn(b);};error=(_a,b)=>{console.error(b);};const Nest = require("../nest/abi");currentNest = require('@electron/remote').getCurrentWindow().nest;</script> <script src="../lang/loader.js"></script> <script src="../scenario/client.js"></script> + <script src="./script/global_compatlayer.js"></script><script src="../typescript/mainloader.js"></script> <meta charset="UTF-8"> <title>Kartik</title> <link rel="stylesheet" href="common/fonts.css"> @@ -14,7 +15,7 @@ } </script> </head> -<body style="background:#000000;margin:0;height:100%;width:100%;"> +<body style="background:#f4f3f4;margin:0;height:100%;width:100%;"> <script>info("MainWindow", "Rendering initial frame..."); if (native) { @@ -22,10 +23,16 @@ } </script> - <img id="imgpreload" src="common/banner.gif" style="height:100%;width:auto;opacity:0;position:fixed;pointer-events:none;"> - <div style="display:flex;align-items:center;justify-content:center;inset: 0;height: 100%;background:#fed1ae;overflow:hidden;"> - <img id="banner" src="../logo/itch/banner.jpg" style="height:100%;width:auto;"> + <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> </div> + <video style="display: none;position:fixed;inset:0;width: 100%;height: 100%;background: #f4f3f4;" id="intro-video"> + <source src="intro.mp4"> + </video> <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> diff --git a/views/menu.css b/views/menu.css index ca90e93..f9697a7 100644 --- a/views/menu.css +++ b/views/menu.css @@ -151,6 +151,9 @@ .item-icon { filter: invert(1); vertical-align: middle; + display: inline-block; + margin-top: 3px; + margin-bottom: -1px; } div.services.home { @@ -221,4 +224,25 @@ span#copyright { backdrop-filter: blur(10px); background: rgba(0, 0, 0, 0.5); left: 10vw; +} + +.item-text { + vertical-align: middle; + margin-top: 8px; + display: inline-block; +} + +@media (max-height: 600px) { + img[alt="full-logo"][src="../logo/full.png"].full-logo { + margin-top: 16px !important; + } + + span#copyright.copyright { + bottom: 14px !important; + } +} + +body { + height: calc(100vh / 1.2); + overflow: hidden; }
\ No newline at end of file diff --git a/views/menu.html b/views/menu.html index b2a0129..d06eba6 100644 --- a/views/menu.html +++ b/views/menu.html @@ -10,11 +10,15 @@ <link rel="stylesheet" href="menu.css"> <title>Kartik</title> <script src="../crash/client.js"></script> - <script src="./script/global_compatlayer.js"></script> + <script src="./script/global_compatlayer.js"></script><script src="../typescript/mainloader.js"></script> <script src="./script/menu_login.js"></script> <script src="../sfx/sfx.js"></script> - <link rel="stylesheet" href="rain/rainstyle.css"> + <script src="./rain/snow.js"></script> <script> + snowStorm.flakesMaxActive = 80; + snowStorm.followMouse = false; + snowStorm.snowStick = false; + scenar("intro", "neutral"); if (!require('@electron/remote').getCurrentWindow().debug) { document.write('<link rel="stylesheet" href="common/mouse.css">'); @@ -29,47 +33,47 @@ } </script> - <div id="box" style="display: none;background:#222;position:fixed;top:0;left:0;right:0;bottom:0;"> + <div id="box" style="display: none;background:#9abecd;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;"></div> - <img alt="full-logo" src="../logo/full.png" style="margin-left: 50px;margin-top: 30px;height: 96px;"> + <div style="width: 100%;height: 100%;opacity:.5;background-image: url('./menu.jpg');background-size: cover;position: fixed;z-index: -1;"></div> + <img alt="full-logo" class="full-logo" src="../logo/full.png" style="margin-left: 50px;margin-top: 30px;height: 96px;"> <div id="services-background"></div> <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> + <li class="selected"><span class="item"><a href="#" id="single"><img class="item-icon" src="../icons/singleplayer.svg"> <span class="item-text"><script>document.write(lang.menu.titles[0])</script></span></a></span></li> <script id="prefill"> if (require('@electron/remote').getCurrentWindow().online) { - document.write(`<li><span class="item"><a href="#" id="play"><img class="item-icon" src="../icons/local.svg"> ${lang.online.menu.local}</a></span></li>`) - document.write(`<li><span class="item"><a href="#" id="online"><img class="item-icon" src="../icons/online.svg"> ${lang.online.menu.online}</a></span></li>`); - document.write(`<li><span class="item"><a href="#" id="settings"><img class="item-icon" src="../icons/settings.svg"> ${lang.menu.titles[2]}</a></span></li>`); + document.write(`<li><span class="item"><a href="#" id="play"><img class="item-icon" src="../icons/local.svg"> <span class="item-text">${lang.online.menu.local}</span></a></span></li>`) + document.write(`<li><span class="item"><a href="#" id="online"><img class="item-icon" src="../icons/online.svg"> <span class="item-text">${lang.online.menu.online}</span></a></span></li>`); + document.write(`<li><span class="item"><a href="#" id="settings"><img class="item-icon" src="../icons/settings.svg"> <span class="item-text">${lang.menu.titles[2]}</span></a></span></li>`); } else { - document.write(`<li><span class="item"><a href="#" id="play"><img class="item-icon" src="../icons/local.svg"> ${lang.online.menu.local}</a></span></li>`) - document.write(`<li><span class="item"><a href="#" id="settings"><img class="item-icon" src="../icons/settings.svg"> ${lang.menu.titles[2]}</a></span></li>`); + document.write(`<li><span class="item"><a href="#" id="play"><img class="item-icon" src="../icons/local.svg"> <span class="item-text">${lang.online.menu.local}</span></a></span></li>`) + document.write(`<li><span class="item"><a href="#" id="settings"><img class="item-icon" src="../icons/settings.svg"> <span class="item-text">${lang.menu.titles[2]}</span></a></span></li>`); } document.getElementById('prefill').outerHTML = ""; </script> - <li><span class="item"><a href="#" id="stats"><img class="item-icon" src="../icons/stats.svg"> <script>document.write(lang.stats.menu)</script></a></span></li> - <li><span class="item"><a href="#" id="quit"><img class="item-icon" src="../icons/exit.svg"> <script>document.write(lang.menu.titles[4])</script></a></span></li> + <li><span class="item"><a href="#" id="stats"><img class="item-icon" src="../icons/stats.svg"> <span class="item-text"><script>document.write(lang.stats.menu)</script></span></a></span></li> + <li><span class="item"><a href="#" id="quit"><img class="item-icon" src="../icons/exit.svg"> <span class="item-text"><script>document.write(lang.menu.titles[4])</script></span></a></span></li> </ul> </div> </div> <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> + <span style="text-align:center;display:block;font-weight: bold;margin-bottom: 5px;"><script>document.write(lang.polymer.gpu);</script></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> + <div id="gpuinfo-model" style="opacity: .25;padding-top: 5px;text-align: center;">-</div> + <div id="gpuinfo-vram" style="opacity: .25;padding-top: 5px;text-align: center;">- 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-outer" style="opacity: .25;padding-top: 5px;text-align: center;">↓ <script>document.write(lang.polymer.gpuShift);</script></div> <div id="gpuinfo-inner" style="font-family:monospace;opacity:0;height:0;"> <script src="./script/menu_gpuinfo.js"></script> </div> @@ -89,7 +93,7 @@ <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=" + <div style="position: fixed;right: 16px;top: 16px;color: white;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; @@ -106,12 +110,11 @@ " alt=" " id="kto-picture"> </div> - <span id="copyright">© <script src="./script/menu_copyright.js"></script></span> + <span id="copyright" class="copyright">© <script src="./script/menu_copyright.js"></script></span> </div> <script src="./script/menu_music.js"></script> </body> <script src="./script/menu_global.js"></script> -<script src="./rain/rainscript.js"></script> <script src="./script/client_fullscreen.js"></script> </html> diff --git a/views/menu.jpg b/views/menu.jpg Binary files differindex 0ac1665..ade8fdd 100644 --- a/views/menu.jpg +++ b/views/menu.jpg diff --git a/views/online.html b/views/online.html index cd1cff5..f1c20c1 100644 --- a/views/online.html +++ b/views/online.html @@ -9,7 +9,7 @@ <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="./script/global_compatlayer.js"></script><script src="../typescript/mainloader.js"></script> <script src="../sfx/sfx.js"></script> <script> if (!require('@electron/remote').getCurrentWindow().debug) { diff --git a/views/rain/snow.js b/views/rain/snow.js new file mode 100644 index 0000000..014dad0 --- /dev/null +++ b/views/rain/snow.js @@ -0,0 +1,666 @@ +/** @license + * DHTML Snowstorm! JavaScript-based snow for web pages + * Making it snow on the internets since 2003. You're welcome. + * ----------------------------------------------------------- + * Version 1.44.20131208 (Previous rev: 1.44.20131125) + * Copyright (c) 2007, Scott Schiller. All rights reserved. + * Code provided under the BSD License + * http://schillmania.com/projects/snowstorm/license.txt + */ + +/*jslint nomen: true, plusplus: true, sloppy: true, vars: true, white: true */ +/*global window, document, navigator, clearInterval, setInterval */ + +var snowStorm = (function(window, document) { + + // --- common properties --- + + this.autoStart = true; // Whether the snow should start automatically or not. + this.excludeMobile = true; // Snow is likely to be bad news for mobile phones' CPUs (and batteries.) Enable at your own risk. + this.flakesMax = 128; // Limit total amount of snow made (falling + sticking) + this.flakesMaxActive = 64; // Limit amount of snow falling at once (less = lower CPU use) + this.animationInterval = 33; // Theoretical "miliseconds per frame" measurement. 20 = fast + smooth, but high CPU use. 50 = more conservative, but slower + this.useGPU = true; // Enable transform-based hardware acceleration, reduce CPU load. + this.className = null; // CSS class name for further customization on snow elements + this.excludeMobile = true; // Snow is likely to be bad news for mobile phones' CPUs (and batteries.) By default, be nice. + this.flakeBottom = null; // Integer for Y axis snow limit, 0 or null for "full-screen" snow effect + this.followMouse = true; // Snow movement can respond to the user's mouse + this.snowColor = '#fff'; // Don't eat (or use?) yellow snow. + this.snowCharacter = '•'; // • = bullet, · is square on some systems etc. + this.snowStick = true; // Whether or not snow should "stick" at the bottom. When off, will never collect. + this.targetElement = null; // element which snow will be appended to (null = document.body) - can be an element ID eg. 'myDiv', or a DOM node reference + this.useMeltEffect = true; // When recycling fallen snow (or rarely, when falling), have it "melt" and fade out if browser supports it + this.useTwinkleEffect = false; // Allow snow to randomly "flicker" in and out of view while falling + this.usePositionFixed = false; // true = snow does not shift vertically when scrolling. May increase CPU load, disabled by default - if enabled, used only where supported + this.usePixelPosition = false; // Whether to use pixel values for snow top/left vs. percentages. Auto-enabled if body is position:relative or targetElement is specified. + + // --- less-used bits --- + + this.freezeOnBlur = true; // Only snow when the window is in focus (foreground.) Saves CPU. + this.flakeLeftOffset = 0; // Left margin/gutter space on edge of container (eg. browser window.) Bump up these values if seeing horizontal scrollbars. + this.flakeRightOffset = 0; // Right margin/gutter space on edge of container + this.flakeWidth = 8; // Max pixel width reserved for snow element + this.flakeHeight = 8; // Max pixel height reserved for snow element + this.vMaxX = 5; // Maximum X velocity range for snow + this.vMaxY = 4; // Maximum Y velocity range for snow + this.zIndex = 0; // CSS stacking order applied to each snowflake + + // --- "No user-serviceable parts inside" past this point, yadda yadda --- + + var storm = this, + features, + // UA sniffing and backCompat rendering mode checks for fixed position, etc. + isIE = navigator.userAgent.match(/msie/i), + isIE6 = navigator.userAgent.match(/msie 6/i), + isMobile = navigator.userAgent.match(/mobile|opera m(ob|in)/i), + isBackCompatIE = (isIE && document.compatMode === 'BackCompat'), + noFixed = (isBackCompatIE || isIE6), + screenX = null, screenX2 = null, screenY = null, scrollY = null, docHeight = null, vRndX = null, vRndY = null, + windOffset = 1, + windMultiplier = 2, + flakeTypes = 6, + fixedForEverything = false, + targetElementIsRelative = false, + opacitySupported = (function(){ + try { + document.createElement('div').style.opacity = '0.5'; + } catch(e) { + return false; + } + return true; + }()), + didInit = false, + docFrag = document.createDocumentFragment(); + + features = (function() { + + var getAnimationFrame; + + /** + * hat tip: paul irish + * http://paulirish.com/2011/requestanimationframe-for-smart-animating/ + * https://gist.github.com/838785 + */ + + function timeoutShim(callback) { + window.setTimeout(callback, 1000/(storm.animationInterval || 20)); + } + + var _animationFrame = (window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + timeoutShim); + + // apply to window, avoid "illegal invocation" errors in Chrome + getAnimationFrame = _animationFrame ? function() { + return _animationFrame.apply(window, arguments); + } : null; + + var testDiv; + + testDiv = document.createElement('div'); + + function has(prop) { + + // test for feature support + var result = testDiv.style[prop]; + return (result !== undefined ? prop : null); + + } + + // note local scope. + var localFeatures = { + + transform: { + ie: has('-ms-transform'), + moz: has('MozTransform'), + opera: has('OTransform'), + webkit: has('webkitTransform'), + w3: has('transform'), + prop: null // the normalized property value + }, + + getAnimationFrame: getAnimationFrame + + }; + + localFeatures.transform.prop = ( + localFeatures.transform.w3 || + localFeatures.transform.moz || + localFeatures.transform.webkit || + localFeatures.transform.ie || + localFeatures.transform.opera + ); + + testDiv = null; + + return localFeatures; + + }()); + + this.timer = null; + this.flakes = []; + this.disabled = false; + this.active = false; + this.meltFrameCount = 20; + this.meltFrames = []; + + this.setXY = function(o, x, y) { + + if (!o) { + return false; + } + + if (storm.usePixelPosition || targetElementIsRelative) { + + o.style.left = (x - storm.flakeWidth) + 'px'; + o.style.top = (y - storm.flakeHeight) + 'px'; + + } else if (noFixed) { + + o.style.right = (100-(x/screenX*100)) + '%'; + // avoid creating vertical scrollbars + o.style.top = (Math.min(y, docHeight-storm.flakeHeight)) + 'px'; + + } else { + + if (!storm.flakeBottom) { + + // if not using a fixed bottom coordinate... + o.style.right = (100-(x/screenX*100)) + '%'; + o.style.bottom = (100-(y/screenY*100)) + '%'; + + } else { + + // absolute top. + o.style.right = (100-(x/screenX*100)) + '%'; + o.style.top = (Math.min(y, docHeight-storm.flakeHeight)) + 'px'; + + } + + } + + }; + + this.events = (function() { + + var old = (!window.addEventListener && window.attachEvent), slice = Array.prototype.slice, + evt = { + add: (old?'attachEvent':'addEventListener'), + remove: (old?'detachEvent':'removeEventListener') + }; + + function getArgs(oArgs) { + var args = slice.call(oArgs), len = args.length; + if (old) { + args[1] = 'on' + args[1]; // prefix + if (len > 3) { + args.pop(); // no capture + } + } else if (len === 3) { + args.push(false); + } + return args; + } + + function apply(args, sType) { + var element = args.shift(), + method = [evt[sType]]; + if (old) { + element[method](args[0], args[1]); + } else { + element[method].apply(element, args); + } + } + + function addEvent() { + apply(getArgs(arguments), 'add'); + } + + function removeEvent() { + apply(getArgs(arguments), 'remove'); + } + + return { + add: addEvent, + remove: removeEvent + }; + + }()); + + function rnd(n,min) { + if (isNaN(min)) { + min = 0; + } + return (Math.random()*n)+min; + } + + function plusMinus(n) { + return (parseInt(rnd(2),10)===1?n*-1:n); + } + + this.randomizeWind = function() { + var i; + vRndX = plusMinus(rnd(storm.vMaxX,0.2)); + vRndY = rnd(storm.vMaxY,0.2); + if (this.flakes) { + for (i=0; i<this.flakes.length; i++) { + if (this.flakes[i].active) { + this.flakes[i].setVelocities(); + } + } + } + }; + + this.scrollHandler = function() { + var i; + // "attach" snowflakes to bottom of window if no absolute bottom value was given + scrollY = (storm.flakeBottom ? 0 : parseInt(window.scrollY || document.documentElement.scrollTop || (noFixed ? document.body.scrollTop : 0), 10)); + if (isNaN(scrollY)) { + scrollY = 0; // Netscape 6 scroll fix + } + if (!fixedForEverything && !storm.flakeBottom && storm.flakes) { + for (i=0; i<storm.flakes.length; i++) { + if (storm.flakes[i].active === 0) { + storm.flakes[i].stick(); + } + } + } + }; + + this.resizeHandler = function() { + if (window.innerWidth || window.innerHeight) { + screenX = window.innerWidth - 16 - storm.flakeRightOffset; + screenY = (storm.flakeBottom || window.innerHeight); + } else { + screenX = (document.documentElement.clientWidth || document.body.clientWidth || document.body.scrollWidth) - (!isIE ? 8 : 0) - storm.flakeRightOffset; + screenY = storm.flakeBottom || document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight; + } + docHeight = document.body.offsetHeight; + screenX2 = parseInt(screenX/2,10); + }; + + this.resizeHandlerAlt = function() { + screenX = storm.targetElement.offsetWidth - storm.flakeRightOffset; + screenY = storm.flakeBottom || storm.targetElement.offsetHeight; + screenX2 = parseInt(screenX/2,10); + docHeight = document.body.offsetHeight; + }; + + this.freeze = function() { + // pause animation + if (!storm.disabled) { + storm.disabled = 1; + } else { + return false; + } + storm.timer = null; + }; + + this.resume = function() { + if (storm.disabled) { + storm.disabled = 0; + } else { + return false; + } + storm.timerInit(); + }; + + this.toggleSnow = function() { + if (!storm.flakes.length) { + // first run + storm.start(); + } else { + storm.active = !storm.active; + if (storm.active) { + storm.show(); + storm.resume(); + } else { + storm.stop(); + storm.freeze(); + } + } + }; + + this.stop = function() { + var i; + this.freeze(); + for (i=0; i<this.flakes.length; i++) { + this.flakes[i].o.style.display = 'none'; + } + storm.events.remove(window,'scroll',storm.scrollHandler); + storm.events.remove(window,'resize',storm.resizeHandler); + if (storm.freezeOnBlur) { + if (isIE) { + storm.events.remove(document,'focusout',storm.freeze); + storm.events.remove(document,'focusin',storm.resume); + } else { + storm.events.remove(window,'blur',storm.freeze); + storm.events.remove(window,'focus',storm.resume); + } + } + }; + + this.show = function() { + var i; + for (i=0; i<this.flakes.length; i++) { + this.flakes[i].o.style.display = 'block'; + } + }; + + this.SnowFlake = function(type,x,y) { + var s = this; + this.type = type; + this.x = x||parseInt(rnd(screenX-20),10); + this.y = (!isNaN(y)?y:-rnd(screenY)-12); + this.vX = null; + this.vY = null; + this.vAmpTypes = [1,1.2,1.4,1.6,1.8]; // "amplification" for vX/vY (based on flake size/type) + this.vAmp = this.vAmpTypes[this.type] || 1; + this.melting = false; + this.meltFrameCount = storm.meltFrameCount; + this.meltFrames = storm.meltFrames; + this.meltFrame = 0; + this.twinkleFrame = 0; + this.active = 1; + this.fontSize = (10+(this.type/5)*10); + this.o = document.createElement('div'); + this.o.innerHTML = storm.snowCharacter; + if (storm.className) { + this.o.setAttribute('class', storm.className); + } + this.o.style.color = storm.snowColor; + this.o.style.position = (fixedForEverything?'fixed':'absolute'); + if (storm.useGPU && features.transform.prop) { + // GPU-accelerated snow. + this.o.style[features.transform.prop] = 'translate3d(0px, 0px, 0px)'; + } + this.o.style.width = storm.flakeWidth+'px'; + this.o.style.height = storm.flakeHeight+'px'; + this.o.style.fontFamily = 'arial,verdana'; + this.o.style.cursor = 'default'; + this.o.style.overflow = 'hidden'; + this.o.style.fontWeight = 'normal'; + this.o.style.zIndex = storm.zIndex; + docFrag.appendChild(this.o); + + this.refresh = function() { + if (isNaN(s.x) || isNaN(s.y)) { + // safety check + return false; + } + storm.setXY(s.o, s.x, s.y); + }; + + this.stick = function() { + if (noFixed || (storm.targetElement !== document.documentElement && storm.targetElement !== document.body)) { + s.o.style.top = (screenY+scrollY-storm.flakeHeight)+'px'; + } else if (storm.flakeBottom) { + s.o.style.top = storm.flakeBottom+'px'; + } else { + s.o.style.display = 'none'; + s.o.style.bottom = '0%'; + s.o.style.position = 'fixed'; + s.o.style.display = 'block'; + } + }; + + this.vCheck = function() { + if (s.vX>=0 && s.vX<0.2) { + s.vX = 0.2; + } else if (s.vX<0 && s.vX>-0.2) { + s.vX = -0.2; + } + if (s.vY>=0 && s.vY<0.2) { + s.vY = 0.2; + } + }; + + this.move = function() { + var vX = s.vX*windOffset, yDiff; + s.x += vX; + s.y += (s.vY*s.vAmp); + if (s.x >= screenX || screenX-s.x < storm.flakeWidth) { // X-axis scroll check + s.x = 0; + } else if (vX < 0 && s.x-storm.flakeLeftOffset < -storm.flakeWidth) { + s.x = screenX-storm.flakeWidth-1; // flakeWidth; + } + s.refresh(); + yDiff = screenY+scrollY-s.y+storm.flakeHeight; + if (yDiff<storm.flakeHeight) { + s.active = 0; + if (storm.snowStick) { + s.stick(); + } else { + s.recycle(); + } + } else { + if (storm.useMeltEffect && s.active && s.type < 3 && !s.melting && Math.random()>0.998) { + // ~1/1000 chance of melting mid-air, with each frame + s.melting = true; + s.melt(); + // only incrementally melt one frame + // s.melting = false; + } + if (storm.useTwinkleEffect) { + if (s.twinkleFrame < 0) { + if (Math.random() > 0.97) { + s.twinkleFrame = parseInt(Math.random() * 8, 10); + } + } else { + s.twinkleFrame--; + if (!opacitySupported) { + s.o.style.visibility = (s.twinkleFrame && s.twinkleFrame % 2 === 0 ? 'hidden' : 'visible'); + } else { + s.o.style.opacity = (s.twinkleFrame && s.twinkleFrame % 2 === 0 ? 0 : 1); + } + } + } + } + }; + + this.animate = function() { + // main animation loop + // move, check status, die etc. + s.move(); + }; + + this.setVelocities = function() { + s.vX = vRndX+rnd(storm.vMaxX*0.12,0.1); + s.vY = vRndY+rnd(storm.vMaxY*0.12,0.1); + }; + + this.setOpacity = function(o,opacity) { + if (!opacitySupported) { + return false; + } + o.style.opacity = opacity; + }; + + this.melt = function() { + if (!storm.useMeltEffect || !s.melting) { + s.recycle(); + } else { + if (s.meltFrame < s.meltFrameCount) { + s.setOpacity(s.o,s.meltFrames[s.meltFrame]); + s.o.style.fontSize = s.fontSize-(s.fontSize*(s.meltFrame/s.meltFrameCount))+'px'; + s.o.style.lineHeight = storm.flakeHeight+2+(storm.flakeHeight*0.75*(s.meltFrame/s.meltFrameCount))+'px'; + s.meltFrame++; + } else { + s.recycle(); + } + } + }; + + this.recycle = function() { + s.o.style.display = 'none'; + s.o.style.position = (fixedForEverything?'fixed':'absolute'); + s.o.style.bottom = 'auto'; + s.setVelocities(); + s.vCheck(); + s.meltFrame = 0; + s.melting = false; + s.setOpacity(s.o,1); + s.o.style.padding = '0px'; + s.o.style.margin = '0px'; + s.o.style.fontSize = s.fontSize+'px'; + s.o.style.lineHeight = (storm.flakeHeight+2)+'px'; + s.o.style.textAlign = 'center'; + s.o.style.verticalAlign = 'baseline'; + s.x = parseInt(rnd(screenX-storm.flakeWidth-20),10); + s.y = parseInt(rnd(screenY)*-1,10)-storm.flakeHeight; + s.refresh(); + s.o.style.display = 'block'; + s.active = 1; + }; + + this.recycle(); // set up x/y coords etc. + this.refresh(); + + }; + + this.snow = function() { + var active = 0, flake = null, i, j; + for (i=0, j=storm.flakes.length; i<j; i++) { + if (storm.flakes[i].active === 1) { + storm.flakes[i].move(); + active++; + } + if (storm.flakes[i].melting) { + storm.flakes[i].melt(); + } + } + if (active<storm.flakesMaxActive) { + flake = storm.flakes[parseInt(rnd(storm.flakes.length),10)]; + if (flake.active === 0) { + flake.melting = true; + } + } + if (storm.timer) { + features.getAnimationFrame(storm.snow); + } + }; + + this.mouseMove = function(e) { + if (!storm.followMouse) { + return true; + } + var x = parseInt(e.clientX,10); + if (x<screenX2) { + windOffset = -windMultiplier+(x/screenX2*windMultiplier); + } else { + x -= screenX2; + windOffset = (x/screenX2)*windMultiplier; + } + }; + + this.createSnow = function(limit,allowInactive) { + var i; + for (i=0; i<limit; i++) { + storm.flakes[storm.flakes.length] = new storm.SnowFlake(parseInt(rnd(flakeTypes),10)); + if (allowInactive || i>storm.flakesMaxActive) { + storm.flakes[storm.flakes.length-1].active = -1; + } + } + storm.targetElement.appendChild(docFrag); + }; + + this.timerInit = function() { + storm.timer = true; + storm.snow(); + }; + + this.init = function() { + var i; + for (i=0; i<storm.meltFrameCount; i++) { + storm.meltFrames.push(1-(i/storm.meltFrameCount)); + } + storm.randomizeWind(); + storm.createSnow(storm.flakesMax); // create initial batch + storm.events.add(window,'resize',storm.resizeHandler); + storm.events.add(window,'scroll',storm.scrollHandler); + if (storm.freezeOnBlur) { + if (isIE) { + storm.events.add(document,'focusout',storm.freeze); + storm.events.add(document,'focusin',storm.resume); + } else { + storm.events.add(window,'blur',storm.freeze); + storm.events.add(window,'focus',storm.resume); + } + } + storm.resizeHandler(); + storm.scrollHandler(); + if (storm.followMouse) { + storm.events.add(isIE?document:window,'mousemove',storm.mouseMove); + } + storm.animationInterval = Math.max(20,storm.animationInterval); + storm.timerInit(); + }; + + this.start = function(bFromOnLoad) { + if (!didInit) { + didInit = true; + } else if (bFromOnLoad) { + // already loaded and running + return true; + } + if (typeof storm.targetElement === 'string') { + var targetID = storm.targetElement; + storm.targetElement = document.getElementById(targetID); + if (!storm.targetElement) { + throw new Error('Snowstorm: Unable to get targetElement "'+targetID+'"'); + } + } + if (!storm.targetElement) { + storm.targetElement = (document.body || document.documentElement); + } + if (storm.targetElement !== document.documentElement && storm.targetElement !== document.body) { + // re-map handler to get element instead of screen dimensions + storm.resizeHandler = storm.resizeHandlerAlt; + //and force-enable pixel positioning + storm.usePixelPosition = true; + } + storm.resizeHandler(); // get bounding box elements + storm.usePositionFixed = (storm.usePositionFixed && !noFixed && !storm.flakeBottom); // whether or not position:fixed is to be used + if (window.getComputedStyle) { + // attempt to determine if body or user-specified snow parent element is relatlively-positioned. + try { + targetElementIsRelative = (window.getComputedStyle(storm.targetElement, null).getPropertyValue('position') === 'relative'); + } catch(e) { + // oh well + targetElementIsRelative = false; + } + } + fixedForEverything = storm.usePositionFixed; + if (screenX && screenY && !storm.disabled) { + storm.init(); + storm.active = true; + } + }; + + function doDelayedStart() { + window.setTimeout(function() { + storm.start(true); + }, 20); + // event cleanup + storm.events.remove(isIE?document:window,'mousemove',doDelayedStart); + } + + function doStart() { + if (!storm.excludeMobile || !isMobile) { + doDelayedStart(); + } + // event cleanup + storm.events.remove(window, 'load', doStart); + } + + // hooks for starting the snow + if (storm.autoStart) { + storm.events.add(window, 'load', doStart, false); + } + + return this; + +}(window, document));
\ No newline at end of file diff --git a/views/script/core_chart.js b/views/script/core_chart.js index 059c818..2f8a521 100644 --- a/views/script/core_chart.js +++ b/views/script/core_chart.js @@ -2,7 +2,7 @@ setInterval(() => { try { currentMemory = process.memoryUsage().rss; currentMemoryMib = (((currentMemory)/1024)/1024).toFixed(2); - if ((((currentMemory)/1024)/1024) > 250) { + if ((((currentMemory)/1024)/1024) > ((require('os').totalmem() / 1000000) / 4)) { throw new Error("Out of memory"); } @@ -66,5 +66,9 @@ setInterval(() => { } else { document.title="Kartik"+require('@electron/remote').getCurrentWindow().channel+require('./package.json').version + eaid; } - } catch (e) {} + } catch (e) { + if (e.message === "Out of memory") { + throw e; + } + } }, 1000)
\ No newline at end of file diff --git a/views/script/core_crash.js b/views/script/core_crash.js new file mode 100644 index 0000000..d24ec2d --- /dev/null +++ b/views/script/core_crash.js @@ -0,0 +1,21 @@ +global.gameCrashed = false; +crashSound = new Audio("./sfx/gamecrash.wav"); + +function destroy() { + global.gameCrashed = true; + crashSound.play(); + require('@electron/remote').webContents.fromId(webview.getWebContentsId()).forcefullyCrashRenderer(); + try { musicElement.pause(); } catch (e) {} +} + +function spawnError(crashReport) { + document.getElementById("error-outer").style.display = "flex"; + document.getElementById("crash-dump").value = crashReport; + destroy(); +} + +const crashHandler = require('electron').ipcRenderer; + +crashHandler.on('crashreport', (event, args) => { + spawnError(args); +})
\ No newline at end of file diff --git a/views/script/core_fullscreen.js b/views/script/core_fullscreen.js index 69f9e45..f2c540d 100644 --- a/views/script/core_fullscreen.js +++ b/views/script/core_fullscreen.js @@ -1,9 +1,40 @@ -$(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); +window.addEventListener("load", () => { + require('@electron/remote').getCurrentWindow().show(); + + 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) { + 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"); + } + } + }) + + 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_stats.js b/views/script/core_stats.js index c8d26df..930c776 100644 --- a/views/script/core_stats.js +++ b/views/script/core_stats.js @@ -6,42 +6,46 @@ timer = null; current = null; webview.addEventListener('dom-ready', () => { - if (webview.getURL() !== current) { - if (session !== null) { - require('electron').ipcRenderer.send('addstats', { catalog: "times", key: session, add: Math.floor((new Date() - timer)/1000) }); + try { + if (webview.getURL() !== current) { + if (session !== null) { + require('electron').ipcRenderer.send('addstats', { catalog: "times", key: session, add: Math.floor((new Date() - timer)/1000) }); - session = null; - timer = null; - current = null; + session = null; + timer = null; + current = null; + } } - } - if (webview.getURL().endsWith("game.html")) { // Local - session = "local"; - timer = new Date(); - current = webview.getURL(); - } - if (webview.getURL().endsWith("game.html?sp")) { // Singleplayer - session = "single"; - timer = new Date(); - current = webview.getURL(); - } - if (webview.getURL().endsWith("game.html?online")) { // Online - session = "online"; - timer = new Date(); - current = webview.getURL(); - } + if (webview.getURL().endsWith("game.html")) { // Local + session = "local"; + timer = new Date(); + current = webview.getURL(); + } + if (webview.getURL().endsWith("game.html?sp")) { // Singleplayer + session = "single"; + timer = new Date(); + current = webview.getURL(); + } + if (webview.getURL().endsWith("game.html?online")) { // Online + session = "online"; + timer = new Date(); + current = webview.getURL(); + } + } catch (e) {} }) window.addEventListener("beforeunload", function(e){ - if (session !== null) { - require('electron').ipcRenderer.send('addstatsandclose', { catalog: "times", key: session, add: Math.floor((new Date() - timer)/1000) }); + try { + if (session !== null) { + require('electron').ipcRenderer.send('addstatsandclose', { catalog: "times", key: session, add: Math.floor((new Date() - timer)/1000) }); - session = null; - timer = null; - current = null; + session = null; + timer = null; + current = null; - e.preventDefault(); - return false; - } + e.preventDefault(); + return false; + } + } catch (e) {} }, false);
\ No newline at end of file diff --git a/views/script/core_viewer.js b/views/script/core_viewer.js index 389bf41..eac3766 100644 --- a/views/script/core_viewer.js +++ b/views/script/core_viewer.js @@ -1,24 +1,28 @@ const webview = document.getElementById('wb'); -webview.addEventListener('dom-ready', () => { - document.getElementById('dummyloader').style.display = "none"; - require('@electron/remote').getCurrentWindow().log(" * " + webview.getURL()); - try { - if (require('@electron/remote').getCurrentWindow().debug) { - info("MainWindow", "Opening debugging tools..."); - webview.openDevTools(); - } - } catch (e) {} -}) - -webview.addEventListener('dom-ready', () => { - setInterval(() => { +try { + webview.addEventListener('dom-ready', () => { + document.getElementById('dummyloader').style.display = "none"; + require('@electron/remote').getCurrentWindow().log(" * " + webview.getURL()); + require('@electron/remote').getCurrentWindow().focus(); + webview.focus(); try { - if (webview.isCrashed()) { - require('@electron/remote').getCurrentWindow().log(" * Compositing engine crashed!"); - error("MainWindow", "Subcontainer crashed"); - crash(new Error("Webview crashed")); + if (require('@electron/remote').getCurrentWindow().debug) { + info("MainWindow", "Opening debugging tools..."); + webview.openDevTools(); } } catch (e) {} - }, 2000) -})
\ No newline at end of file + }) + + 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/views/script/loader_global.js b/views/script/loader_global.js index db70d3b..7543268 100644 --- a/views/script/loader_global.js +++ b/views/script/loader_global.js @@ -3,7 +3,7 @@ window.addEventListener('load', () => { if (native) { setTimeout(() => { setTimeout(() => { - 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);} + $("#progress").fadeOut(500); setTimeout(() => { window.fetch("https://kartik.hopto.org/latest.php?v=" + require('@electron/remote').getCurrentWindow().update).then((data) => { @@ -25,18 +25,19 @@ window.addEventListener('load', () => { } } setTimeout(() => { - document.getElementById('banner').style.width = "380px"; - document.getElementById('banner').style.height = "auto"; - document.getElementById('banner').src = "common/banner.gif"; - introsfx = new Audio("../sfx/newintro.mp3"); - introsfx.play() - introsfx.onended = () => { - $("body").fadeOut(500); - setTimeout(() => { - info("LoadWindow", "Switching control to MenuWindow"); - location.href = "intro.html"; - }, 1000) - } + $("#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); @@ -44,10 +45,31 @@ window.addEventListener('load', () => { 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"; - document.getElementById('banner').src = "common/banner.gif"; - introsfx = new Audio("../sfx/newintro.mp3"); + $("#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); @@ -56,18 +78,19 @@ window.addEventListener('load', () => { location.href = "intro.html"; }, 1000) } - }, 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]}); + }, 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(() => { - document.getElementById('banner').style.width = "380px"; - document.getElementById('banner').style.height = "auto"; - document.getElementById('banner').src = "common/banner.gif"; - introsfx = new Audio("../sfx/newintro.mp3"); + introsfx = document.getElementById("intro-video"); introsfx.play() introsfx.onended = () => { $("body").fadeOut(500); @@ -76,46 +99,28 @@ window.addEventListener('load', () => { location.href = "intro.html"; }, 1000) } - }, 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(() => { - document.getElementById('banner').style.width = "380px"; - document.getElementById('banner').style.height = "auto"; - document.getElementById('banner').src = "common/banner.gif"; - introsfx = new Audio("../sfx/newintro.mp3"); - 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 { - 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);} + setTimeout(() => { - document.getElementById('banner').style.width = "380px"; - document.getElementById('banner').style.height = "auto"; - document.getElementById('banner').src = "common/banner.gif"; - introsfx = new Audio("../sfx/newintro.mp3"); - introsfx.play() - introsfx.onended = () => { - $("body").fadeOut(500); - setTimeout(() => { - info("LoadWindow", "Switching control to MenuWindow"); - location.href = "intro.html"; - }, 1000) - } + $("#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) diff --git a/views/script/menu_copyright.js b/views/script/menu_copyright.js index 35b322a..2b38844 100644 --- a/views/script/menu_copyright.js +++ b/views/script/menu_copyright.js @@ -1,5 +1,5 @@ if (new Date().getFullYear() === 2021) { - document.write(new Date().getFullYear() + " Minteck Projects"); + document.write(new Date().getFullYear() + " Minteck"); } else { - document.write("2021-" + new Date().getFullYear() + " Minteck Projects"); + document.write("2021-" + new Date().getFullYear() + " Minteck"); }
\ No newline at end of file diff --git a/views/script/menu_global.js b/views/script/menu_global.js index 8561fe3..14a924f 100644 --- a/views/script/menu_global.js +++ b/views/script/menu_global.js @@ -14,6 +14,9 @@ $(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(); diff --git a/views/script/menu_login.js b/views/script/menu_login.js index 7f50101..2af88b2 100644 --- a/views/script/menu_login.js +++ b/views/script/menu_login.js @@ -54,7 +54,7 @@ function startLogin() { loggingIn = false; document.getElementById('loggingIn').style.display = "none"; currentNest.auth = playerData; - Nest.export(homedir + "/.kartik/current.kfn", currentNest); + Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest") keysEnabled = false; require('electron').ipcRenderer.send('prefademusic', ""); $("#box").fadeOut(500); @@ -109,49 +109,101 @@ window.addEventListener('load', () => { }) function postOnlineMode() { - if (currentNest.auth === null || !onlineMode) { - $(document).keydown(function(e) { - if (e.keyCode === 76 && !loggingIn && onlineMode) { - startLogin(); + try { + if (currentNest.auth === null || !onlineMode) { + $(document).keydown(function(e) { + if (e.keyCode === 76 && !loggingIn && onlineMode) { + startLogin(); + } + }) + } else { + authData = currentNest.auth; + + 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; + currentNest.auth = authData; + Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest") } - }) - } else { - authData = currentNest.auth; - document.getElementById('loginIntro').style.display = "none"; - document.getElementById('loginUser').style.display = "grid"; + ostats = JSON.parse($.ajax({ + type: "GET", + url: 'https://kartik.hopto.org/online/ingame/api/profile.stats.php?kartik_online_token=' + authData.token, + async: false, + error: (e) => { throw e; } + }).responseText.trim()) - 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 (ostats === null) { + cstats = currentNest.stats; + } else { + cstats = {}; + + for (group in currentNest.stats) { + cstats[group] = {}; + + for (item in currentNest.stats[group]) { + if (ostats[group][item]) { + if (ostats[group][item] > currentNest.stats[group][item]) { + cstats[group][item] = ostats[group][item]; + } else { + cstats[group][item] = currentNest.stats[group][item]; + } + } else { + cstats[group][item] = currentNest.stats[group][item]; + } + } + } + } - 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, + url: 'https://kartik.hopto.org/online/ingame/api/set.stats.php?kartik_online_token=' + authData.token + "&stats=" + Buffer.from(JSON.stringify(cstats)).toString("base64"), async: false, error: (e) => { throw e; } }); - } else if (authData.level < olevel) { - authData.level = $.ajax({ + + currentNest.stats = JSON.parse($.ajax({ type: "GET", - url: 'https://kartik.hopto.org/online/ingame/api/profile.level.php?kartik_online_token=' + authData.token, + url: 'https://kartik.hopto.org/online/ingame/api/profile.stats.php?kartik_online_token=' + authData.token, async: false, error: (e) => { throw e; } - }).responseText.trim() - 1 + 1; - currentNest.auth = authData; - Nest.export(homedir + "/.kartik/current.kfn", currentNest); - } + }).responseText.trim()); + Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest") - 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; + 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; + } } + } catch (e) { + require('@electron/remote').getCurrentWindow().webContents.send("notification", {title: lang.polymer.error[0], message: lang.polymer.error[1]}); + console.error(e); + onlineMode = false; + document.getElementById("loginIntro").innerText = lang.polymer.error[2]; + document.getElementById("online").parentElement.parentElement.outerHTML = ""; } }
\ No newline at end of file diff --git a/views/script/settings_global.js b/views/script/settings_global.js index e284585..90f1f6e 100644 --- a/views/script/settings_global.js +++ b/views/script/settings_global.js @@ -46,22 +46,22 @@ $(document).keydown(function(e) { if (document.getElementById("setting-music").innerText === "1") { document.getElementById("setting-music").innerText = "0"; currentNest.config.music = false; - Nest.export(homedir + "/.kartik/current.kfn", currentNest); + Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest") } else { document.getElementById("setting-music").innerText = "1"; currentNest.config.music = true; - Nest.export(homedir + "/.kartik/current.kfn", currentNest); + Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest") } } if (id === "voice") { if (document.getElementById("setting-voice").innerText === "1") { document.getElementById("setting-voice").innerText = "0"; currentNest.config.music = false; - Nest.export(homedir + "/.kartik/current.kfn", currentNest); + Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest") } else { document.getElementById("setting-voice").innerText = "1"; currentNest.config.music = true; - Nest.export(homedir + "/.kartik/current.kfn", currentNest); + Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest") } } if (id === "lang") { @@ -86,7 +86,7 @@ $(document).keydown(function(e) { if (ci !== -1 && ni !== -1) { document.getElementById("setting-lang").innerText = slng[slst[ni]]; currentNest.config.lang = slst[ni]; - Nest.export(homedir + "/.kartik/current.kfn", currentNest); + Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest") require('@electron/remote').getCurrentWindow().lp = slst[ni]; } } diff --git a/views/settings.html b/views/settings.html index 4799527..0addaf3 100644 --- a/views/settings.html +++ b/views/settings.html @@ -10,7 +10,7 @@ <link rel="stylesheet" href="menu.css"> <title>Kartik</title> <script src="../crash/client.js"></script> - <script src="./script/global_compatlayer.js"></script> + <script src="./script/global_compatlayer.js"></script><script src="../typescript/mainloader.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 92183ab..3b23571 100644 --- a/views/stats.html +++ b/views/stats.html @@ -9,7 +9,7 @@ <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="./script/global_compatlayer.js"></script><script src="../typescript/mainloader.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 9b0cafb..c9892e7 100644 --- a/views/win.html +++ b/views/win.html @@ -9,7 +9,7 @@ <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="./script/global_compatlayer.js"></script><script src="../typescript/mainloader.js"></script> <script src="../sfx/sfx.js"></script> <script> if (!require('@electron/remote').getCurrentWindow().debug) { |