Add hideFromPalette flag for hiding legacy blocks

This commit is contained in:
Paul Kaplan committed 2017-11-01 11:30:15 -04:00
1 parent 082e051cce
commit 18398d010b
3 files changed
+11 -5

No files matched your search

+8 -4
View File
@@ -328,7 +328,8 @@ class Scratch3PenBlocks {
type: ArgumentType.NUMBER,
defaultValue: 1
}
}
},
hideFromPalette: true
},
{
opcode: 'changePenShadeBy',
@@ -339,7 +340,8 @@ class Scratch3PenBlocks {
type: ArgumentType.NUMBER,
defaultValue: 1
}
}
},
hideFromPalette: true
},
{
opcode: 'setPenHueToNumber',
@@ -350,7 +352,8 @@ class Scratch3PenBlocks {
type: ArgumentType.NUMBER,
defaultValue: 1
}
}
},
hideFromPalette: true
},
{
opcode: 'changePenHueBy',
@@ -361,7 +364,8 @@ class Scratch3PenBlocks {
type: ArgumentType.NUMBER,
defaultValue: 1
}
}
},
hideFromPalette: true
}
],
menus: {
+2 -1
View File
@@ -630,8 +630,9 @@ class Runtime extends EventEmitter {
const xmlParts = [];
for (const categoryInfo of this._blockInfo) {
const {name, color1, color2} = categoryInfo;
const paletteBlocks = categoryInfo.blocks.filter(block => !block.info.hideFromPalette);
xmlParts.push(`<category name="${name}" colour="${color1}" secondaryColour="${color2}">`);
xmlParts.push.apply(xmlParts, categoryInfo.blocks.map(blockInfo => blockInfo.xml));
xmlParts.push.apply(xmlParts, paletteBlocks.map(block => block.xml));
xmlParts.push('</category>');
}
return xmlParts.join('\n');
@@ -30,6 +30,7 @@ const builtinExtensions = {
* @property {object.<string,ArgumentInfo>|undefined} arguments - information about this block's arguments, if any
* @property {string|Function|undefined} func - the method for this block on the extension service (default: opcode)
* @property {Array.<string>|undefined} filter - the list of targets for which this block should appear (default: all)
* @property {Boolean|undefined} hideFromPalette - true if should not be appear in the palette. (default false)
*/
/**