mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
fix backward compatibility issue on piskelapp.com
This commit is contained in:
parent
f342b72e1b
commit
5a39d6850e
@ -32,6 +32,5 @@
|
|||||||
onSuccess(piskel, extra);
|
onSuccess(piskel, extra);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
if (data instanceof ArrayBuffer || data instanceof Array) {
|
if (data instanceof ArrayBuffer || data instanceof Array) {
|
||||||
var uint8 = new Uint8Array(data);
|
var uint8 = new Uint8Array(data);
|
||||||
|
|
||||||
// Backward compatibility for JSON (modelVersion < 3)
|
// Backward compatibility for modelVersion < 3 for LocalStorage, FileImport etc... which
|
||||||
|
// now always serve the serialized sprites as strings and no longer as objects
|
||||||
if (String.fromCharCode(uint8[0]) == '{') {
|
if (String.fromCharCode(uint8[0]) == '{') {
|
||||||
data = '';
|
data = '';
|
||||||
for (var i = 0; i < uint8.length; i++) {
|
for (var i = 0 ; i < uint8.length ; i++) {
|
||||||
data += String.fromCharCode(uint8[i]);
|
data += String.fromCharCode(uint8[i]);
|
||||||
}
|
}
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
@ -25,6 +26,9 @@
|
|||||||
var arr16 = new Uint16Array(uint8.buffer);
|
var arr16 = new Uint16Array(uint8.buffer);
|
||||||
modelVersion = arr16[0];
|
modelVersion = arr16[0];
|
||||||
}
|
}
|
||||||
|
} else if (typeof data == 'object') {
|
||||||
|
// Backward Compatibility for sprites served from piskelapp.com with modelVersion < 3
|
||||||
|
modelVersion = data.modelVersion;
|
||||||
} else {
|
} else {
|
||||||
throw 'Invalid data for deserializing: ' + data;
|
throw 'Invalid data for deserializing: ' + data;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user