mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Merge pull request #1719 from rschamp/hotfix/sprite-upload-from-image
Handle images uploaded as sprites
This commit is contained in:
commit
d64322a110
2 changed files with 16 additions and 1 deletions
|
@ -71,7 +71,19 @@ const deserializeCostume = function (costume, runtime, zip, assetFileName) {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -823,6 +823,9 @@ const parseScratchObject = function (object, runtime, extensions, zip) {
|
|||
const costumePromises = (object.costumes || []).map(costumeSource => {
|
||||
// @todo: Make sure all the relevant metadata is being pulled out.
|
||||
const costume = {
|
||||
// costumeSource only has an asset if an image is being uploaded as
|
||||
// a sprite
|
||||
asset: costumeSource.asset,
|
||||
assetId: costumeSource.assetId,
|
||||
skinId: null,
|
||||
name: costumeSource.name,
|
||||
|
|
Loading…
Reference in a new issue