Deploying to built from @ 05a92c2733 🚀

This commit is contained in:
pulsejet 2020-10-20 12:23:46 +00:00
parent ef59fb7418
commit 32bf12bb03
4 changed files with 566 additions and 559 deletions

File diff suppressed because one or more lines are too long

View File

@ -178,7 +178,7 @@
</div> </div>
<script type='text/javascript'> <script type='text/javascript'>
var namespace = 'kne'; var namespace = 'kne_b';
var wTitle = 'KN_E' var wTitle = 'KN_E'
document.title = wTitle; document.title = wTitle;

View File

@ -86,39 +86,46 @@ window.loadFileAsync = function(fullPath, bitmap, callback) {
} }
window.saveFile = function(filename) { window.saveFile = function(filename, localOnly) {
const buf = FS.readFile('/game/' + filename); const fpath = '/game/' + filename;
if (!FS.analyzePath(fpath).exists) return;
const buf = FS.readFile(fpath);
localforage.setItem(namespace + filename, buf); localforage.setItem(namespace + filename, buf);
localforage.getItem(namespace, function(err, res) { localforage.getItem(namespace, function(err, res) {
if (err || !res) res = {}; if (err || !res) res = {};
res[filename] = 1; res[filename] = { t: Number(FS.stat(fpath).mtime) };
localforage.setItem(namespace, res); localforage.setItem(namespace, res);
}); });
if (!localOnly) {
(window.saveCloudFile || (()=>{}))(filename, buf); (window.saveCloudFile || (()=>{}))(filename, buf);
}
}; };
var loadFiles = function() { var loadFiles = function() {
localforage.getItem(namespace, function(err, res) { localforage.getItem(namespace, function(err, folder) {
if (err || !folder) return;
console.log('Locally stored savefiles:', folder);
Object.keys(folder).forEach((key) => {
const meta = folder[key];
localforage.getItem(namespace + key, (err, res) => {
if (err || !res) return; if (err || !res) return;
const keys = Object.keys(res);
console.log('Locally stored savefiles', keys);
keys.forEach((key) => {
localforage.getItem(namespace + key, (err, res) => {
if (err) return;
// Don't overwrite existing files // Don't overwrite existing files
const fname = '/game/' + key; const fpath = '/game/' + key;
if (FS.analyzePath(fname).exists) return; if (FS.analyzePath(fpath).exists) return;
FS.writeFile(fname, res); FS.writeFile(fpath, res);
});
if (Number.isInteger(meta.t)) {
FS.utime(fpath, meta.t, meta.t);
}
}); });
}); });
}, console.error);
(window.loadCloudFiles || (()=>{}))(); (window.loadCloudFiles || (()=>{}))();
} }

BIN
mkxp.wasm

Binary file not shown.