From 2a8490a2bf5a170f9a89e23d0fe8880da821c71c Mon Sep 17 00:00:00 2001 From: Kim Ying <15070078+kimprice@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:07:55 -0800 Subject: [PATCH] check for qualified name in sprite editor --- pxtblocks/fields/field_sprite.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pxtblocks/fields/field_sprite.ts b/pxtblocks/fields/field_sprite.ts index b063d1b93286..1711f92c9098 100644 --- a/pxtblocks/fields/field_sprite.ts +++ b/pxtblocks/fields/field_sprite.ts @@ -47,13 +47,22 @@ namespace pxtblockly { const bmp = text ? pxt.sprite.imageLiteralToBitmap(text) : new pxt.sprite.Bitmap(this.params.initWidth, this.params.initHeight); + let data: pxt.sprite.BitmapData; + if (!bmp) { - this.isGreyBlock = true; - this.valueText = text; - return undefined; + // check for qualified name + const images = project.getGalleryAssets(pxt.AssetType.Image).filter(asset => asset.id === text); + const img = images.length && images[0]; + if (!img) { + this.isGreyBlock = true; + this.valueText = text; + return undefined; + } else { + data = img.bitmap; + } } - const data = bmp.data(); + if (!data) data = bmp.data(); const newAsset: pxt.ProjectImage = { internalID: -1,