update variable names
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { onChangeWorkspace, clearStats } from '../../actions/workspaceActions';
|
||||
import React, { Component } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { connect } from "react-redux";
|
||||
import { onChangeWorkspace, clearStats } from "../../actions/workspaceActions";
|
||||
|
||||
import BlocklyComponent from './BlocklyComponent';
|
||||
import BlocklySvg from './BlocklySvg';
|
||||
import BlocklyComponent from "./BlocklyComponent";
|
||||
import BlocklySvg from "./BlocklySvg";
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
import './blocks/index';
|
||||
import './generator/index';
|
||||
|
||||
import { initialXml } from './initialXml.js';
|
||||
import * as Blockly from "blockly/core";
|
||||
import "./blocks/index";
|
||||
import "./generator/index";
|
||||
|
||||
import { initialXml } from "./initialXml.js";
|
||||
|
||||
class BlocklyWindow extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.simpleWorkspace = React.createRef();
|
||||
@@ -41,6 +39,7 @@ class BlocklyWindow extends Component {
|
||||
Blockly.Events.disableOrphans(event);
|
||||
}
|
||||
});
|
||||
|
||||
Blockly.svgResize(workspace);
|
||||
}
|
||||
|
||||
@@ -64,46 +63,65 @@ class BlocklyWindow extends Component {
|
||||
// workspace.updateToolbox(toolbox.toolboxDef_);
|
||||
}
|
||||
Blockly.svgResize(workspace);
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<BlocklyComponent ref={this.simpleWorkspace}
|
||||
<BlocklyComponent
|
||||
ref={this.simpleWorkspace}
|
||||
style={this.props.svg ? { height: 0 } : this.props.blocklyCSS}
|
||||
readOnly={this.props.readOnly !== undefined ? this.props.readOnly : false}
|
||||
trashcan={this.props.trashcan !== undefined ? this.props.trashcan : true}
|
||||
readOnly={
|
||||
this.props.readOnly !== undefined ? this.props.readOnly : false
|
||||
}
|
||||
trashcan={
|
||||
this.props.trashcan !== undefined ? this.props.trashcan : true
|
||||
}
|
||||
renderer={this.props.renderer}
|
||||
zoom={{ // https://developers.google.com/blockly/guides/configure/web/zoom
|
||||
controls: this.props.zoomControls !== undefined ? this.props.zoomControls : true,
|
||||
zoom={{
|
||||
// https://developers.google.com/blockly/guides/configure/web/zoom
|
||||
controls:
|
||||
this.props.zoomControls !== undefined
|
||||
? this.props.zoomControls
|
||||
: true,
|
||||
wheel: false,
|
||||
startScale: 1,
|
||||
maxScale: 3,
|
||||
minScale: 0.3,
|
||||
scaleSpeed: 1.2
|
||||
scaleSpeed: 1.2,
|
||||
}}
|
||||
grid={this.props.grid !== undefined && !this.props.grid ? {} :
|
||||
{ // https://developers.google.com/blockly/guides/configure/web/grid
|
||||
spacing: 20,
|
||||
length: 1,
|
||||
colour: '#4EAF47', // senseBox-green
|
||||
snap: false
|
||||
}}
|
||||
media={'/media/blockly/'}
|
||||
move={this.props.move !== undefined && !this.props.move ? {} :
|
||||
{ // https://developers.google.com/blockly/guides/configure/web/move
|
||||
scrollbars: true,
|
||||
drag: true,
|
||||
wheel: false
|
||||
}}
|
||||
initialXml={this.props.initialXml ? this.props.initialXml : initialXml}
|
||||
>
|
||||
</BlocklyComponent >
|
||||
{this.props.svg && this.props.initialXml ? <BlocklySvg initialXml={this.props.initialXml} /> : null}
|
||||
grid={
|
||||
this.props.grid !== undefined && !this.props.grid
|
||||
? {}
|
||||
: {
|
||||
// https://developers.google.com/blockly/guides/configure/web/grid
|
||||
spacing: 20,
|
||||
length: 1,
|
||||
colour: "#4EAF47", // senseBox-green
|
||||
snap: false,
|
||||
}
|
||||
}
|
||||
media={"/media/blockly/"}
|
||||
move={
|
||||
this.props.move !== undefined && !this.props.move
|
||||
? {}
|
||||
: {
|
||||
// https://developers.google.com/blockly/guides/configure/web/move
|
||||
scrollbars: true,
|
||||
drag: true,
|
||||
wheel: false,
|
||||
}
|
||||
}
|
||||
initialXml={
|
||||
this.props.initialXml ? this.props.initialXml : initialXml
|
||||
}
|
||||
></BlocklyComponent>
|
||||
{this.props.svg && this.props.initialXml ? (
|
||||
<BlocklySvg initialXml={this.props.initialXml} />
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
BlocklyWindow.propTypes = {
|
||||
@@ -114,10 +132,12 @@ BlocklyWindow.propTypes = {
|
||||
workspaceXML: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
const mapStateToProps = (state) => ({
|
||||
renderer: state.general.renderer,
|
||||
language: state.general.language.Blockly,
|
||||
workspaceXML: state.workspace.code.xml,
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, { onChangeWorkspace, clearStats })(BlocklyWindow);
|
||||
export default connect(mapStateToProps, { onChangeWorkspace, clearStats })(
|
||||
BlocklyWindow
|
||||
);
|
||||
|
||||
@@ -1,43 +1,46 @@
|
||||
import Blockly from 'blockly/core';
|
||||
import { getColour } from '../helpers/colour';
|
||||
import { getCompatibleTypes } from '../helpers/types'
|
||||
|
||||
|
||||
Blockly.Blocks['variables_set_dynamic'] = {
|
||||
init: function () {
|
||||
|
||||
// const type = myVar.type;
|
||||
this.setColour(getColour().variables);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.appendValueInput('VALUE')
|
||||
.appendField('set', 'set')
|
||||
.appendField('', 'type')
|
||||
.appendField(new Blockly.FieldVariable('VAR'), 'VAR')
|
||||
.appendField('to');
|
||||
},
|
||||
onchange: function (e) {
|
||||
let variableID = this.getFieldValue('VAR');
|
||||
let variable = Blockly.getMainWorkspace().getVariableMap().getVariableById(variableID)
|
||||
this.getField('type').setValue(variable.type);
|
||||
this.getInput('VALUE').setCheck(getCompatibleTypes(variable.type));
|
||||
import Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import { getCompatibleTypes } from "../helpers/types";
|
||||
|
||||
Blockly.Blocks["variables_set_dynamic"] = {
|
||||
init: function () {
|
||||
// const type = myVar.type;
|
||||
this.setColour(getColour().variables);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.appendValueInput("VALUE")
|
||||
.appendField("set", "set")
|
||||
.appendField("", "type")
|
||||
.appendField(new Blockly.FieldVariable("VAR"), "VAR")
|
||||
.appendField("to");
|
||||
},
|
||||
onchange: function (e) {
|
||||
let variableID = this.getFieldValue("VAR");
|
||||
let variable = Blockly.getMainWorkspace()
|
||||
.getVariableMap()
|
||||
.getVariableById(variableID);
|
||||
if (variable !== null) {
|
||||
this.getField("type").setValue(variable.type);
|
||||
this.getInput("VALUE").setCheck(getCompatibleTypes(variable.type));
|
||||
}
|
||||
}
|
||||
|
||||
Blockly.Blocks['variables_get_dynamic'] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().variables);
|
||||
this.appendDummyInput()
|
||||
.appendField('', 'type')
|
||||
.appendField(new Blockly.FieldVariable('VAR'), 'VAR');
|
||||
this.setOutput(true);
|
||||
},
|
||||
onchange: function (e) {
|
||||
let variableID = this.getFieldValue('VAR');
|
||||
let variable = Blockly.getMainWorkspace().getVariableMap().getVariableById(variableID)
|
||||
this.getField('type').setValue(variable.type);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["variables_get_dynamic"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().variables);
|
||||
this.appendDummyInput()
|
||||
.appendField("", "type")
|
||||
.appendField(new Blockly.FieldVariable("VAR"), "VAR");
|
||||
this.setOutput(true);
|
||||
},
|
||||
onchange: function (e) {
|
||||
let variableID = this.getFieldValue("VAR");
|
||||
let variable = Blockly.getMainWorkspace()
|
||||
.getVariableMap()
|
||||
.getVariableById(variableID);
|
||||
if (variable !== null) {
|
||||
this.getField("type").setValue(variable.type);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
@@ -10,6 +10,16 @@ export const UI = {
|
||||
toolbox_time: "Zeit",
|
||||
toolbox_functions: "Funktionen",
|
||||
toolbox_variables: "Variablen",
|
||||
variable_NUMBER: "Zahl (int)",
|
||||
variable_SHORT_NUMBER: "char",
|
||||
variable_LONG: "große Zahl (long)",
|
||||
variable_DECIMAL: "Kommazahl (float)",
|
||||
variables_TEXT: "Text (string)",
|
||||
variables_ARRAY: "Array (array)",
|
||||
variables_CHARACTER: "char (char)",
|
||||
variables_BOOLEAN: "Boolean (boolean)",
|
||||
variables_NULL: "void (void)",
|
||||
variables_UNDEF: "undefined",
|
||||
|
||||
/**
|
||||
* Tooltips
|
||||
|
||||
@@ -10,6 +10,16 @@ export const UI = {
|
||||
toolbox_time: "Time",
|
||||
toolbox_functions: "Functions",
|
||||
toolbox_variables: "Variables",
|
||||
variable_NUMBER: "Number (int)",
|
||||
variable_SHORT_NUMBER: "char",
|
||||
variable_LONG: " Zahl (long)",
|
||||
variable_DECIMAL: "Decimal (float)",
|
||||
variables_TEXT: "Text (string)",
|
||||
variables_ARRAY: "Array (array)",
|
||||
variables_CHARACTER: "char (char)",
|
||||
variables_BOOLEAN: "Boolean (boolean)",
|
||||
variables_NULL: "void (void)",
|
||||
variables_UNDEF: "undefined",
|
||||
|
||||
/**
|
||||
* Tooltips
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user