Lazy load bitmap map

This commit is contained in:
Varun Patil 2020-10-20 12:34:24 +05:30
parent f75a1e6866
commit 61e8b248f6
2 changed files with 7 additions and 3 deletions

View File

@ -37,7 +37,6 @@ window.loadFileAsync = function(fullPath, bitmap, callback) {
// Check if already loaded // Check if already loaded
if (window.fileAsyncCache.hasOwnProperty(mappingKey)) return callback(); if (window.fileAsyncCache.hasOwnProperty(mappingKey)) return callback();
console.log('load', mappingKey);
// Show spinner // Show spinner
if (!bitmap && window.setBusy) window.setBusy(); if (!bitmap && window.setBusy) window.setBusy();
@ -183,7 +182,6 @@ function preloadList(jsonArray) {
// Preload the asset // Preload the asset
FS.createPreloadedFile(path, filename, "gameasync/" + mappingValue, true, true, function() { FS.createPreloadedFile(path, filename, "gameasync/" + mappingValue, true, true, function() {
window.fileAsyncCache[mappingKey] = 1; window.fileAsyncCache[mappingKey] = 1;
console.log('preload', mappingKey);
}, console.error, false, false, () => { }, console.error, false, false, () => {
try { FS.unlink(path + "/" + filename); } catch (err) {} try { FS.unlink(path + "/" + filename); } catch (err) {}
}); });

View File

@ -9,7 +9,6 @@
<script src="js/drive.js"></script> <script src="js/drive.js"></script>
<script src="js/dpad.js"></script> <script src="js/dpad.js"></script>
<script src="gameasync/mapping.js"></script> <script src="gameasync/mapping.js"></script>
<script src="gameasync/bitmap-map.js"></script>
<title>MKXP</title> <title>MKXP</title>
<style> <style>
@ -238,8 +237,15 @@
const s = document.createElement('script'); const s = document.createElement('script');
s.setAttribute('src', 'mkxp.js'); s.setAttribute('src', 'mkxp.js');
document.body.appendChild(s); document.body.appendChild(s);
getLazyAsset('gameasync/bitmap-map.js', 'Primary assets', () => {
const s = document.createElement('script');
s.setAttribute('src', 'gameasync/bitmap-map.js');
document.body.appendChild(s);
});
}); });
}, 200); }, 200);
var bitmapSizeMapping = {};
if (!is_touch_device()) { if (!is_touch_device()) {
document.getElementById('dpad').style.display = 'none'; document.getElementById('dpad').style.display = 'none';