Deploying to built from @ 262a2254b6 🚀

This commit is contained in:
pulsejet 2020-10-20 16:03:03 +00:00
parent bc2a204499
commit 454786b22f
3 changed files with 575 additions and 569 deletions

File diff suppressed because one or more lines are too long

View File

@ -1101,8 +1101,8 @@ var mappingArray = [
["graphics/transitions/020-flat01", "Graphics/Transitions/020-Flat01.png?h=94dd9f75005cdc7236a0b400b71920fd"], ["graphics/transitions/020-flat01", "Graphics/Transitions/020-Flat01.png?h=94dd9f75005cdc7236a0b400b71920fd"],
["graphics/windowskins", "Graphics/Windowskins?h="], ["graphics/windowskins", "Graphics/Windowskins?h="],
["graphics/windowskins/windowskin_kn", "Graphics/Windowskins/Windowskin_kn.png?h=6ad592d1b718424e634dda8f7b96aac2"], ["graphics/windowskins/windowskin_kn", "Graphics/Windowskins/Windowskin_kn.png?h=6ad592d1b718424e634dda8f7b96aac2"],
["bitmap-map", "bitmap-map.js?h=aa57757c4398e0bd546f80ef63386cbe"], ["bitmap-map", "bitmap-map.js?h=1abc5d6cb7fca45042dab38ab7632504"],
["mapping", "mapping.js?h=c713fd63fd66b4be258f9cf94559cd55"], ["mapping", "mapping.js?h=bb851a310612778fb5cce683b0df55fa"],
["rgss", "rgss.rb?h=e4f6ce1cd6617eedd6e4704cfd0d263b"], ["rgss", "rgss.rb?h=e4f6ce1cd6617eedd6e4704cfd0d263b"],
]; ];

View File

@ -172,11 +172,15 @@ function preloadList(jsonArray) {
const filename = mappingValue.substring(mappingValue.lastIndexOf("/") + 1).split("?")[0]; const filename = mappingValue.substring(mappingValue.lastIndexOf("/") + 1).split("?")[0];
// Preload the asset // Preload the asset
FS.createPreloadedFile(path, filename, "gameasync/" + mappingValue, true, true, function() { getLazyAsset("gameasync/" + mappingValue, filename, (data) => {
if (!data) return;
FS.createPreloadedFile(path, filename, new Uint8Array(data), true, true, function() {
window.fileAsyncCache[mappingKey] = 1; window.fileAsyncCache[mappingKey] = 1;
}, console.error, false, false, () => { }, console.error, false, false, () => {
try { FS.unlink(path + "/" + filename); } catch (err) {} try { FS.unlink(path + "/" + filename); } catch (err) {}
}); });
}, true);
}); });
} }
@ -196,28 +200,36 @@ window.fileLoadedAsync = function(file) {
}); });
}; };
var hideTimer = 0; var activeStreams = [];
function getLazyAsset(url, filename, callback) { function getLazyAsset(url, filename, callback, noretry) {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.responseType = "arraybuffer"; xhr.responseType = "arraybuffer";
const pdiv = document.getElementById("progress"); const pdiv = document.getElementById("progress");
let showTimer = 0;
let abortTimer = 0; let abortTimer = 0;
const end = (message) => {
pdiv.innerHTML = `${filename} - ${message}`;
activeStreams.splice(activeStreams.indexOf(filename), 1);
if (activeStreams.length === 0) {
pdiv.style.opacity = '0';
}
clearTimeout(abortTimer);
}
const retry = () => { const retry = () => {
xhr.abort(); xhr.abort();
if (noretry) {
end('skip'); callback(null);
} else {
activeStreams.splice(activeStreams.indexOf(filename), 1);
getLazyAsset(url, filename, callback); getLazyAsset(url, filename, callback);
} }
}
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE && xhr.status >= 200 && xhr.status < 400) { if (xhr.readyState == XMLHttpRequest.DONE && xhr.status >= 200 && xhr.status < 400) {
pdiv.innerHTML = `${filename} - done`; end('done');
hideTimer = setTimeout(() => {
pdiv.style.opacity = '0';
hideTimer = 0;
}, 500);
clearTimeout(showTimer);
clearTimeout(abortTimer);
callback(xhr.response); callback(xhr.response);
} }
} }
@ -232,16 +244,10 @@ function getLazyAsset(url, filename, callback) {
xhr.open('GET', url); xhr.open('GET', url);
xhr.send(); xhr.send();
pdiv.innerHTML = `${filename} - starting`; pdiv.innerHTML = `${filename} - start`;
showTimer = setTimeout(() => {
pdiv.style.opacity = '0.5'; pdiv.style.opacity = '0.5';
}, 100);
activeStreams.push(filename);
abortTimer = setTimeout(retry, 10000); abortTimer = setTimeout(retry, 10000);
if (hideTimer) {
clearTimeout(hideTimer);
hideTimer = 0;
}
} }