mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Explain when it's OK to omit <field> element
Also, alphabetize the `ArgumentType` and `BlockType` enums.
This commit is contained in:
parent
772da24d9e
commit
99b868c0f0
3 changed files with 13 additions and 6 deletions
|
@ -459,10 +459,17 @@ class Runtime extends EventEmitter {
|
|||
const argInfo = blockInfo.arguments[placeholder] || {};
|
||||
const argTypeInfo = ArgumentTypeMap[argInfo.type] || {};
|
||||
const defaultValue = (typeof argInfo.defaultValue === 'undefined' ? '' : argInfo.defaultValue.toString());
|
||||
|
||||
// <value> is the ScratchBlocks name for a block input.
|
||||
// The <shadow> is a placeholder for a reporter and is visible when there's no reporter in this input.
|
||||
inputList.push(`<value name="${placeholder}"><shadow type="${argTypeInfo.shadowType}">`);
|
||||
|
||||
// <field> is a text field that the user can type into. Some shadows, like the color picker, don't allow
|
||||
// text input and therefore don't need a field element.
|
||||
if (argTypeInfo.fieldType) {
|
||||
inputList.push(`<field name="${argTypeInfo.fieldType}">${defaultValue}</field>`);
|
||||
}
|
||||
|
||||
inputList.push('</shadow></value>');
|
||||
|
||||
return `%${argNum}`;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const ArgumentType = {
|
||||
NUMBER: 'number',
|
||||
STRING: 'string',
|
||||
BOOLEAN: 'Boolean',
|
||||
COLOR: 'color'
|
||||
COLOR: 'color',
|
||||
NUMBER: 'number',
|
||||
STRING: 'string'
|
||||
};
|
||||
|
||||
module.exports = ArgumentType;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
const BlockType = {
|
||||
COMMAND: 'command',
|
||||
REPORTER: 'reporter',
|
||||
BOOLEAN: 'Boolean',
|
||||
COMMAND: 'command',
|
||||
CONDITIONAL: 'conditional',
|
||||
HAT: 'hat',
|
||||
CONDITIONAL: 'conditional'
|
||||
REPORTER: 'reporter'
|
||||
};
|
||||
|
||||
module.exports = BlockType;
|
||||
|
|
Loading…
Reference in a new issue