mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 23:12:24 -05:00
Load text layer asset
This commit is contained in:
parent
88b6bdd06c
commit
b6b3ca21d7
1 changed files with 15 additions and 2 deletions
|
@ -153,7 +153,11 @@ const loadCostumeFromAsset = function (costume, costumeAsset, runtime, optVersio
|
||||||
*/
|
*/
|
||||||
const loadCostume = function (md5ext, costume, runtime, optVersion) {
|
const loadCostume = function (md5ext, costume, runtime, optVersion) {
|
||||||
let costumePromise;
|
let costumePromise;
|
||||||
|
let textLayerPromise;
|
||||||
if (costume.asset) {
|
if (costume.asset) {
|
||||||
|
// TODO if text asset exists, merge the 2 assets, put it back in storage, clean up text layer
|
||||||
|
// data from costume and return the costume with merged asset here.
|
||||||
|
|
||||||
// Costume comes with asset. It could be coming from camera, image upload, drag and drop, or sb file
|
// Costume comes with asset. It could be coming from camera, image upload, drag and drop, or sb file
|
||||||
costumePromise = Promise.resolve(costume.asset);
|
costumePromise = Promise.resolve(costume.asset);
|
||||||
} else {
|
} else {
|
||||||
|
@ -174,10 +178,19 @@ const loadCostume = function (md5ext, costume, runtime, optVersion) {
|
||||||
log.error(`Couldn't fetch costume asset: ${md5ext}`);
|
log.error(`Couldn't fetch costume asset: ${md5ext}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (costume.textLayerMD5) {
|
||||||
|
textLayerPromise = runtime.storage.load(AssetType.ImageBitmap, costume.textLayerMD5, 'png');
|
||||||
|
} else {
|
||||||
|
textLayerPromise = Promise.resolve(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return costumePromise.then(costumeAsset => {
|
return Promise.all(costumePromise, textLayerPromise).then(assetArray => {
|
||||||
costume.asset = costumeAsset;
|
costume.asset = assetArray[0];
|
||||||
|
if (assetArray[1]) {
|
||||||
|
costume.textLayerAsset = assetArray[1];
|
||||||
|
}
|
||||||
return loadCostumeFromAsset(costume, costumeAsset, runtime, optVersion);
|
return loadCostumeFromAsset(costume, costumeAsset, runtime, optVersion);
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
|
Loading…
Reference in a new issue