Remove preloading progress, load wasm
This commit is contained in:
parent
30c4b1d594
commit
00ccbf5db9
28
shell.html
28
shell.html
|
@ -217,13 +217,10 @@
|
|||
const url = mapping[f.toLowerCase().replace(new RegExp("\\.[^/.]+$"), "")];
|
||||
if (!url) return;
|
||||
|
||||
// Get filename
|
||||
let filename = url.split('?')[0];
|
||||
filename = filename.split('/');
|
||||
filename = filename[filename.length -1];
|
||||
|
||||
// Preload asset
|
||||
getLazyAsset('gameasync/' + url, filename, () => {});
|
||||
// Preload the asset
|
||||
setTimeout(() => {
|
||||
fetch('gameasync/' + url).then().catch();
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -238,7 +235,6 @@
|
|||
if (xhr.readyState == XMLHttpRequest.DONE) {
|
||||
pdiv.innerHTML = `${filename} - done`;
|
||||
hideTimer = setTimeout(() => {
|
||||
window.setNotBusy();
|
||||
pdiv.style.opacity = '0';
|
||||
hideTimer = 0;
|
||||
}, 500);
|
||||
|
@ -255,9 +251,10 @@
|
|||
xhr.open('GET', url);
|
||||
xhr.send();
|
||||
|
||||
pdiv.innerHTML = `${filename} - starting`;
|
||||
|
||||
showTimer = setTimeout(() => {
|
||||
pdiv.style.opacity = '0.5';
|
||||
window.setBusy();
|
||||
}, 100);
|
||||
|
||||
if (hideTimer) {
|
||||
|
@ -267,6 +264,17 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
{{{ SCRIPT }}}
|
||||
<script>
|
||||
// Load wasm then initialize
|
||||
setTimeout(() => {
|
||||
getLazyAsset('mkxp.wasm', 'Game engine', () => {
|
||||
const s = document.createElement('script');
|
||||
s.setAttribute('src', 'mkxp.js');
|
||||
document.body.appendChild(s);
|
||||
});
|
||||
}, 500);
|
||||
</script>
|
||||
|
||||
<!-- {{{ SCRIPT }}} -->
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -13,6 +13,9 @@ EM_JS(void, load_file_async_js, (const char* fullPathC), {
|
|||
// Check if already loaded
|
||||
if (window.fileAsyncCache.hasOwnProperty(fullPath)) return wakeUp();
|
||||
|
||||
// Show spinner
|
||||
if (window.setBusy) window.setBusy();
|
||||
|
||||
// Get mapping key
|
||||
const mappingKey = fullPath.toLowerCase().replace(new RegExp("\\\\.[^/.]+$"), "");
|
||||
const mappingValue = mapping[mappingKey];
|
||||
|
@ -39,6 +42,7 @@ EM_JS(void, load_file_async_js, (const char* fullPathC), {
|
|||
getLazyAsset(iurl, filename, () => {
|
||||
FS.createPreloadedFile(path, filename, iurl, true, true, function() {
|
||||
window.fileAsyncCache[fullPath] = 1;
|
||||
if (window.setNotBusy) window.setNotBusy();
|
||||
if (window.fileLoadedAsync) window.fileLoadedAsync(fullPath);
|
||||
wakeUp();
|
||||
}, console.error);
|
||||
|
|
Loading…
Reference in New Issue