From ce391a48b0d485ce7921767d4742d711146a2816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20M=C3=B6nig?= Date: Thu, 31 Mar 2022 16:21:03 +0200 Subject: [PATCH] support various data types inside menus (sprites, costumes, blocks) --- HISTORY.md | 1 + src/objects.js | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 7d103048..aebad2dd 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -29,6 +29,7 @@ ### 2022-03-31 * threads, objects: new menu functionality for ASK command, when passing a list +* objects: support various data types inside menus (sprites, costumes, blocks) ### 2022-03-28 * new "Tad" turtle costumes, thanks, Meghan and Brian! diff --git a/src/objects.js b/src/objects.js index 22b70870..a8edeba3 100644 --- a/src/objects.js +++ b/src/objects.js @@ -12883,7 +12883,7 @@ StagePickerMorph.prototype.init = function (options) { this.addLine(); } else { this.addItem( - this.dataRepresentation(key), + key, value, null, // hint null, // color @@ -12913,10 +12913,16 @@ StagePickerMorph.prototype.isSubmenu = function (options) { StagePickerMorph.prototype.dataRepresentation = function (data) { switch (Process.prototype.reportTypeOf(data)) { - case 'number': - return data.toString(); + case 'costume': + case 'sprite': + case 'stage': + return data.thumbnail(new Point(40, 40).multiplyBy(this.scale)); + case 'command': + case 'reporter': + case 'predicate': + return data.image(); default: - return data; + return data.toString(); } }; @@ -12949,7 +12955,7 @@ StagePickerMorph.prototype.createLabel = function () { this.label.destroy(); } text = new TextMorph( - localize(this.title), + this.title, SpriteMorph.prototype.bubbleFontSize * this.scale, null, // MorphicPreferences.menuFontName, true, @@ -13040,7 +13046,7 @@ StagePickerMorph.prototype.createItems = function (scale) { item = new StagePickerItemMorph( this.target, tuple[1], - tuple[0], + this.dataRepresentation(tuple[0]), SpriteMorph.prototype.bubbleFontSize * this.scale, null, // MorphicPreferences.menuFontName, this.environment,