mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -05:00
Handle images uploaded as sprites
The sprite upload code in GUI serializes asset data, flattening it. We need to rehydrate the asset.
This commit is contained in:
parent
de86eb3f19
commit
3d06f0e633
2 changed files with 16 additions and 1 deletions
|
@ -71,7 +71,19 @@ const deserializeCostume = function (costume, runtime, zip, assetFileName) {
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!zip) { // Zip will not be provided if loading project json from server
|
if (costume.asset) {
|
||||||
|
// When uploading a sprite from an image file, the asset data will be provided
|
||||||
|
// @todo Cache the asset data somewhere and pull it out here
|
||||||
|
return Promise.resolve(storage.createAsset(
|
||||||
|
costume.asset.assetType,
|
||||||
|
costume.asset.dataFormat,
|
||||||
|
new Uint8Array(Object.keys(costume.asset.data).map(key => costume.asset.data[key])),
|
||||||
|
costume.asset.assetId
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!zip) {
|
||||||
|
// Zip will not be provided if loading project json from server
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -823,6 +823,9 @@ const parseScratchObject = function (object, runtime, extensions, zip) {
|
||||||
const costumePromises = (object.costumes || []).map(costumeSource => {
|
const costumePromises = (object.costumes || []).map(costumeSource => {
|
||||||
// @todo: Make sure all the relevant metadata is being pulled out.
|
// @todo: Make sure all the relevant metadata is being pulled out.
|
||||||
const costume = {
|
const costume = {
|
||||||
|
// costumeSource only has an asset if an image is being uploaded as
|
||||||
|
// a sprite
|
||||||
|
asset: costumeSource.asset,
|
||||||
assetId: costumeSource.assetId,
|
assetId: costumeSource.assetId,
|
||||||
skinId: null,
|
skinId: null,
|
||||||
name: costumeSource.name,
|
name: costumeSource.name,
|
||||||
|
|
Loading…
Reference in a new issue