mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Separate output edge shapes from output types (#447)
* Separate output shape from type checking. * Fix enum check in actual output shape rendering. * Add output shapes for most relevant blocks. * Bring back and update output shapes for unoccupied connections. * Fix output shapes for boolean-type operators * Update type-checking in blocks to match Scratch 2.0
This commit is contained in:
parent
d98844de34
commit
553c825d7a
10 changed files with 155 additions and 123 deletions
|
@ -53,24 +53,6 @@ Blockly.Connection = function(source, type) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Constant for identifying connections that accept a boolean.
|
||||
* @const
|
||||
*/
|
||||
Blockly.Connection.BOOLEAN = 1;
|
||||
|
||||
/**
|
||||
* Constant for identifying connections that accept a string.
|
||||
* @const
|
||||
*/
|
||||
Blockly.Connection.STRING = 2;
|
||||
|
||||
/**
|
||||
* Constant for identifying connections that accept a number OR null.
|
||||
* @const
|
||||
*/
|
||||
Blockly.Connection.NUMBER = 3;
|
||||
|
||||
/**
|
||||
* Constants for checking whether two connections are compatible.
|
||||
*/
|
||||
|
@ -700,18 +682,21 @@ Blockly.Connection.prototype.setCheck = function(check) {
|
|||
|
||||
/**
|
||||
* Returns a shape enum for this connection.
|
||||
* Used in scratch-blocks to draw unoccupied inputs.
|
||||
* @return {number} Enum representing shape.
|
||||
*/
|
||||
Blockly.Connection.prototype.getOutputShape = function() {
|
||||
if (!this.check_) return Blockly.Connection.NUMBER;
|
||||
if (!this.check_) return Blockly.OUTPUT_SHAPE_SQUARE;
|
||||
if (this.check_.indexOf('Boolean') !== -1) {
|
||||
return Blockly.Connection.BOOLEAN;
|
||||
return Blockly.OUTPUT_SHAPE_HEXAGONAL;
|
||||
}
|
||||
if (this.check_.indexOf('Number') !== -1) {
|
||||
return Blockly.OUTPUT_SHAPE_ROUND;
|
||||
}
|
||||
if (this.check_.indexOf('String') !== -1) {
|
||||
return Blockly.Connection.STRING;
|
||||
return Blockly.OUTPUT_SHAPE_SQUARE;
|
||||
}
|
||||
|
||||
return Blockly.Connection.NUMBER;
|
||||
return Blockly.OUTPUT_SHAPE_SQUARE;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue