parent
							
								
									bc5cbb6b33
								
							
						
					
					
						commit
						65fa627aeb
					
				| @ -16,7 +16,7 @@ Blockly.Blocks['controls_whileUntil'] = { | ||||
|         this.setHelpUrl(Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL); | ||||
|         this.setColour(getColour().loops); | ||||
|         this.appendValueInput('BOOL') | ||||
|             .setCheck(getCompatibleTypes(Boolean)) | ||||
|             .setCheck(getCompatibleTypes('boolean')) | ||||
|             .appendField(new Blockly.FieldDropdown(OPERATORS), 'MODE'); | ||||
|         this.appendStatementInput('DO') | ||||
|             .appendField(Blockly.Msg.CONTROLS_WHILEUNTIL_INPUT_DO); | ||||
| @ -53,19 +53,19 @@ Blockly.Blocks['controls_for'] = { | ||||
|                 { | ||||
|                     "type": "input_value", | ||||
|                     "name": "FROM", | ||||
|                     "check": getCompatibleTypes(Number), | ||||
|                     "check": getCompatibleTypes('int'), | ||||
|                     "align": "RIGHT" | ||||
|                 }, | ||||
|                 { | ||||
|                     "type": "input_value", | ||||
|                     "name": "TO", | ||||
|                     "check": getCompatibleTypes(Number), | ||||
|                     "check": getCompatibleTypes('int'), | ||||
|                     "align": "RIGHT" | ||||
|                 }, | ||||
|                 { | ||||
|                     "type": "input_value", | ||||
|                     "name": "BY", | ||||
|                     "check": getCompatibleTypes(Number), | ||||
|                     "check": getCompatibleTypes('int'), | ||||
|                     "align": "RIGHT" | ||||
|                 } | ||||
|             ], | ||||
| @ -104,7 +104,7 @@ Blockly.Blocks['controls_forEach'] = { | ||||
|                 { | ||||
|                     "type": "input_value", | ||||
|                     "name": "LIST", | ||||
|                     "check": getCompatibleTypes(Array) | ||||
|                     "check": getCompatibleTypes('Array') | ||||
|                 } | ||||
|             ], | ||||
|             "previousStatement": null, | ||||
| @ -197,7 +197,7 @@ Blockly.Blocks['controls_repeat_ext'] = { | ||||
|                 { | ||||
|                     "type": "input_value", | ||||
|                     "name": "TIMES", | ||||
|                     "check": getCompatibleTypes(Number), | ||||
|                     "check": getCompatibleTypes('int'), | ||||
|                 } | ||||
|             ], | ||||
|             "previousStatement": null, | ||||
|  | ||||
| @ -105,135 +105,3 @@ export const getCompatibleTypes = (type) => { | ||||
| }; | ||||
| 
 | ||||
| export const VARIABLE_TYPES = [['SHORT_NUMBER', 'char'], ['NUMBER', 'int'], ['DECIMAL', 'long'], ['TEXT', 'String'], ['CHARACTER', 'char'], ['BOOLEAN', 'boolean'], ['NULL', 'void'], ['UNDEF', 'undefined']]; | ||||
| 
 | ||||
| // /**
 | ||||
| //  * Some Types have circular dependencies on their compatibilities, so add them
 | ||||
| //  * after declaration.
 | ||||
| //  */
 | ||||
| // Blockly.Types.NUMBER.addCompatibleTypes([
 | ||||
| //     Blockly.Types.BOOLEAN,
 | ||||
| //     Blockly.Types.SHORT_NUMBER,
 | ||||
| //     Blockly.Types.LARGE_NUMBER,
 | ||||
| //     Blockly.Types.DECIMAL]);
 | ||||
| 
 | ||||
| // Blockly.Types.SHORT_NUMBER.addCompatibleTypes([
 | ||||
| //     Blockly.Types.BOOLEAN,
 | ||||
| //     Blockly.Types.NUMBER,
 | ||||
| //     Blockly.Types.LARGE_NUMBER,
 | ||||
| //     Blockly.Types.DECIMAL]);
 | ||||
| 
 | ||||
| // Blockly.Types.LARGE_NUMBER.addCompatibleTypes([
 | ||||
| //     Blockly.Types.BOOLEAN,
 | ||||
| //     Blockly.Types.SHORT_NUMBER,
 | ||||
| //     Blockly.Types.NUMBER,
 | ||||
| //     Blockly.Types.DECIMAL]);
 | ||||
| 
 | ||||
| // /**
 | ||||
| //  * Adds another type to the Blockly.Types collection.
 | ||||
| //  * @param {string} typeId_ Identifiable name of the type.
 | ||||
| //  * @param {string} typeMsgName_ Name of the member variable from Blockly.Msg
 | ||||
| //  *     object to identify the translateble string.for the Type name.
 | ||||
| //  * @param {Array<Blockly.Type>} compatibleTypes_ List of types this Type is
 | ||||
| //  *     compatible with.
 | ||||
| //  */
 | ||||
| // Blockly.Types.addType = function (typeId_, typeMsgName_, compatibleTypes_) {
 | ||||
| //     // The Id is used as the key from the value pair in the BlocklyTypes object
 | ||||
| //     var key = typeId_.toUpperCase().replace(/ /g, '_');
 | ||||
| //     if (Blockly.Types[key] !== undefined) {
 | ||||
| //         throw 'The Blockly type ' + key + ' already exists.';
 | ||||
| //     }
 | ||||
| //     Blockly.Types[key] = new Blockly.Type({
 | ||||
| //         typeId: typeId_,
 | ||||
| //         typeName: typeMsgName_,
 | ||||
| //         compatibleTypes: compatibleTypes_
 | ||||
| //     });
 | ||||
| // };
 | ||||
| 
 | ||||
| // /**
 | ||||
| //  * Converts the static types dictionary in to a an array with 2-item arrays.
 | ||||
| //  * This array only contains the valid types, excluding any error or temp types.
 | ||||
| //  * @return {!Array<Array<string>>} Blockly types in the format described above.
 | ||||
| //  */
 | ||||
| // Blockly.Types.getValidTypeArray = function () {
 | ||||
| //     var typesArray = [];
 | ||||
| //     for (var typeKey in Blockly.Types) {
 | ||||
| //         if ((typeKey !== 'UNDEF') && (typeKey !== 'CHILD_BLOCK_MISSING') &&
 | ||||
| //             (typeKey !== 'NULL') && (typeKey !== 'ARRAY') &&
 | ||||
| //             (typeof Blockly.Types[typeKey] !== 'function') &&
 | ||||
| //             !(Blockly.Types[typeKey] instanceof RegExp)) {
 | ||||
| //             typesArray.push([Blockly.Types[typeKey].typeName, typeKey]);
 | ||||
| //         }
 | ||||
| //     }
 | ||||
| //     return typesArray;
 | ||||
| // };
 | ||||
| 
 | ||||
| // /**
 | ||||
| //  * Navigates through child blocks of the argument block to get this block type.
 | ||||
| //  * @param {!Blockly.Block} block Block to navigate through children.
 | ||||
| //  * @return {Blockly.Type} Type of the input block.
 | ||||
| //  */
 | ||||
| // Blockly.Types.getChildBlockType = function (block) {
 | ||||
| //     var blockType = null;
 | ||||
| //     var nextBlock = block;
 | ||||
| //     // Only checks first input block, so it decides the type. Incoherences amongst
 | ||||
| //     // multiple inputs dealt at a per-block level with their own block warnings
 | ||||
| //     while (nextBlock && (nextBlock.getBlockType === undefined) &&
 | ||||
| //         (nextBlock.inputList.length > 0) &&
 | ||||
| //         (nextBlock.inputList[0].connection)) {
 | ||||
| //         nextBlock = nextBlock.inputList[0].connection.targetBlock();
 | ||||
| //     }
 | ||||
| //     if (nextBlock === block) {
 | ||||
| //         // Set variable block is empty, so no type yet
 | ||||
| //         blockType = Blockly.Types.CHILD_BLOCK_MISSING;
 | ||||
| //     } else if (nextBlock === null) {
 | ||||
| //         // Null return from targetBlock indicates no block connected
 | ||||
| //         blockType = Blockly.Types.CHILD_BLOCK_MISSING;
 | ||||
| //     } else {
 | ||||
| //         var func = nextBlock.getBlockType;
 | ||||
| //         if (func) {
 | ||||
| //             blockType = nextBlock.getBlockType();
 | ||||
| //         } else {
 | ||||
| //             // Most inner block, supposed to define a type, is missing getBlockType()
 | ||||
| //             blockType = Blockly.Types.NULL;
 | ||||
| //         }
 | ||||
| //     }
 | ||||
| //     return blockType;
 | ||||
| // };
 | ||||
| 
 | ||||
| // /**
 | ||||
| //  * Regular expressions to identify an integer.
 | ||||
| //  * @private
 | ||||
| //  */
 | ||||
| // Blockly.Types.regExpInt_ = new RegExp(/^-?\d+$/);
 | ||||
| 
 | ||||
| // /**
 | ||||
| //  * Regular expressions to identify a decimal.
 | ||||
| //  * @private
 | ||||
| //  */
 | ||||
| // Blockly.Types.regExpFloat_ = new RegExp(/^-?[0-9]*[.][0-9]+$/);
 | ||||
| 
 | ||||
| // /**
 | ||||
| //  * Uses regular expressions to identify if the input number is an integer or a
 | ||||
| //  * floating point.
 | ||||
| //  * @param {string} numberString String of the number to identify.
 | ||||
| //  * @return {!Blockly.Type} Blockly type.
 | ||||
| //  */
 | ||||
| // Blockly.Types.identifyNumber = function (numberString) {
 | ||||
| //     if (Blockly.Types.regExpInt_.test(numberString)) {
 | ||||
| //         var intValue = parseInt(numberString);
 | ||||
| //         if (isNaN(intValue)) {
 | ||||
| //             return Blockly.Types.NULL;
 | ||||
| //         }
 | ||||
| //         if (intValue > 32767 || intValue < -32768) {
 | ||||
| //             return Blockly.Types.LARGE_NUMBER;
 | ||||
| //         }
 | ||||
| //         return Blockly.Types.NUMBER;
 | ||||
| //     } else if (Blockly.Types.regExpFloat_.test(numberString)) {
 | ||||
| //         return Blockly.Types.DECIMAL;
 | ||||
| //     }
 | ||||
| //     return Blockly.Types.NULL;
 | ||||
| // };
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -64,6 +64,14 @@ export const UI = { | ||||
|     messages_GET_TUTORIAL_FAIL: 'Zurück zur Tutorials-Übersicht', | ||||
|     messages_LOGIN_FAIL: 'Der Benutzername oder das Passwort ist nicht korrekt.', | ||||
|     messages_copy_code: "Code wurde in die Zwischenablage kopiert", | ||||
|      | ||||
|     /** | ||||
|      * Reset Dialog | ||||
|      */ | ||||
|      | ||||
|     resetDialog_headline: "Workspace zurücksetzen?", | ||||
|     resetDialog_text: "Möchtest du wirklich die Workspace zurücksetzen? Hierbei werden alle Blöcke gelöscht!", | ||||
|      | ||||
|     /** | ||||
|      * Share Dialog | ||||
|      */ | ||||
|  | ||||
| @ -67,6 +67,15 @@ export const UI = { | ||||
|     messages_LOGIN_FAIL: 'The username or password is incorrect.', | ||||
|     messages_login_error: "Enter both a username and a password.", | ||||
|     messages_copy_code: "Copy code to clipboard succesfull", | ||||
| 
 | ||||
|          | ||||
|     /** | ||||
|      * Reset Dialog | ||||
|      */ | ||||
|      | ||||
|      resetDialog_headline: "Reset workspace?", | ||||
|      resetDialog_text: "Do you really want to reset the workspace? All blocks will be deleted!", | ||||
| 
 | ||||
|     /** | ||||
|      * Share Dialog | ||||
|      */ | ||||
|  | ||||
| @ -16,6 +16,8 @@ import Tooltip from '@material-ui/core/Tooltip'; | ||||
| 
 | ||||
| import { faShare } from "@fortawesome/free-solid-svg-icons"; | ||||
| import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||||
| import Dialog from '../Dialog'; | ||||
| import Button from '@material-ui/core/Button'; | ||||
| 
 | ||||
| const styles = (theme) => ({ | ||||
|   button: { | ||||
| @ -39,12 +41,21 @@ class ResetWorkspace extends Component { | ||||
|     this.inputRef = React.createRef(); | ||||
|     this.state = { | ||||
|       snackbar: false, | ||||
|       open: false, | ||||
|       type: '', | ||||
|       key: '', | ||||
|       message: '', | ||||
|     }; | ||||
|   } | ||||
| 
 | ||||
|   toggleDialog = () => { | ||||
|     this.setState({ open: !this.state}); | ||||
|   } | ||||
| 
 | ||||
|   openDialog = () => { | ||||
|     this.setState({open: true}); | ||||
|   } | ||||
| 
 | ||||
|   resetWorkspace = () => { | ||||
|     const workspace = Blockly.getMainWorkspace(); | ||||
|     Blockly.Events.disable(); // https://groups.google.com/forum/#!topic/blockly/m7e3g0TC75Y
 | ||||
| @ -69,7 +80,7 @@ class ResetWorkspace extends Component { | ||||
|         <Tooltip title={Blockly.Msg.tooltip_reset_workspace} arrow> | ||||
|           <IconButton | ||||
|             className={this.props.classes.button} | ||||
|             onClick={() => this.resetWorkspace()} | ||||
|             onClick={() => this.openDialog()} | ||||
|           > | ||||
|             <FontAwesomeIcon icon={faShare} size="xs" flip='horizontal' /> | ||||
|           </IconButton> | ||||
| @ -81,6 +92,17 @@ class ResetWorkspace extends Component { | ||||
|           type={this.state.type} | ||||
|           key={this.state.key} | ||||
|         /> | ||||
|          <Dialog | ||||
|           open={this.state.open} | ||||
|           title={Blockly.Msg.resetDialog_headline} | ||||
|           content={Blockly.Msg.resetDialog_text} | ||||
|           onClose={() => { this.toggleDialog(); }} | ||||
|           onClick={() => { this.toggleDialog(); }} | ||||
|           button={Blockly.Msg.button_cancel} | ||||
|         > <div style={{ marginTop: '10px' }}> | ||||
|         | ||||
|         <Button variant='contained' color='primary' onClick={() => { this.resetWorkspace(); this.toggleDialog(); }}>Zurücksetzen</Button> | ||||
|       </div></Dialog> | ||||
|       </div> | ||||
|     ); | ||||
|   }; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user