Skip to content

Commit 2991c63

Browse files
committed
Added basic WeDo 2.0 blocks.
Added messenger blocks for simple interactions like countdown. Simplified integrations and fixed smaller issues.
1 parent 4510fa8 commit 2991c63

File tree

66 files changed

+1902
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1902
-356
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.profraw
12
*.stackdump
23
.DS_Store
34
.c9

build/cwc/gss.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,7 @@ closureBuilder.build({
2828
name: 'CwC Closure Style Sheets files',
2929
prefix: 'cwc-',
3030
srcs: glob([
31-
// Internal style sheets
32-
'static_files/css/animations.gss',
33-
'static_files/css/backgrounds.gss',
34-
'static_files/css/fonts.gss',
35-
'static_files/css/icons.gss',
36-
'static_files/css/default.gss',
37-
'static_files/css/loading_screen.gss',
38-
39-
// External style definitions
40-
'static_files/css/blockly/*.gss',
41-
'static_files/css/closure/*.gss',
42-
'static_files/css/codemirror/*.gss',
43-
'static_files/css/material-design-lite/*.gss',
44-
'static_files/css/shepherd/*.gss',
45-
46-
// GSS definitions
31+
'static_files/css/**/*.gss',
4732
'src/**/*.gss',
4833
]),
4934
out: 'genfiles/core/css/editor.css',

package-lock.json

Lines changed: 104 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mode/blocks.soy renamed to src/blocks/blocks.soy

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* @author [email protected] (Markus Bordihn)
1919
*/
20-
{namespace cwc.soy.mode.Blocks autoescape="strict"}
20+
{namespace cwc.soy.Blocks autoescape="strict"}
2121

2222

2323
/**
@@ -78,10 +78,65 @@
7878
{/template}
7979

8080

81+
/**
82+
* Blockly default display blocks.
83+
*/
84+
{template .defaultDisplayBlocks}
85+
<category name="{msg desc="Display Blocks"}Display{/msg}" colour="120">
86+
87+
<block type="general_messenger_display_text">
88+
<value name="text">
89+
<block type="text">
90+
<field name="TEXT">Hello World</field>
91+
</block>
92+
</value>
93+
</block>
94+
95+
<block type="controls_for">
96+
<field name="VAR">countdown</field>
97+
<value name="FROM">
98+
<block type="math_number">
99+
<field name="NUM">10</field>
100+
</block>
101+
</value>
102+
<value name="TO">
103+
<block type="math_number">
104+
<field name="NUM">1</field>
105+
</block>
106+
</value>
107+
<value name="BY">
108+
<block type="math_number">
109+
<field name="NUM">1</field>
110+
</block>
111+
</value>
112+
<statement name="DO">
113+
<block type="general_messenger_display_text">
114+
<value name="text">
115+
<block type="variables_get">
116+
<field name="VAR">countdown</field>
117+
</block>
118+
</value>
119+
</block>
120+
</statement>
121+
<next>
122+
<block type="general_messenger_display_text">
123+
<value name="text">
124+
<block type="text">
125+
<field name="TEXT">Go</field>
126+
</block>
127+
</value>
128+
</block>
129+
</next>
130+
</block>
131+
132+
</category>
133+
{/template}
134+
135+
81136
/**
82137
* Blockly default blocks.
83138
*/
84-
{template .defaultBlocks_}
139+
{template .defaultBlocks_ private="true"}
85140
<category name="{msg desc="Logic Blocks"}Logic{/msg}" colour="210">
86141
<block type="controls_if"></block>
87142
<block type="logic_compare"></block>
@@ -356,7 +411,7 @@
356411
/**
357412
* Blockly default color blocks.
358413
*/
359-
{template .defaultColorBlocks_}
414+
{template .defaultColorBlocks_ private="true"}
360415
<category name="{msg desc="Colour Blocks"}Colour{/msg}" colour="20">
361416
<block type="colour_picker"></block>
362417
<block type="colour_random"></block>

src/blocks/general/blocks_helper.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,14 @@
1818
* @author [email protected] (Markus Bordihn)
1919
*/
2020
Blockly.BlocksHelper = {};
21+
22+
23+
/**
24+
* @param {string} text
25+
* @return {string}
26+
*/
27+
Blockly.BlocksHelper['validate_text'] = function(text) {
28+
return text
29+
.replace(/'/g, '')
30+
.replace(/\\/g, '');
31+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @fileoverview General messenger display block definition.
3+
*
4+
* @license Copyright 2018 The Coding with Chrome Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author [email protected] (Markus Bordihn)
19+
*/
20+
21+
22+
/**
23+
* Display text on local screen.
24+
*/
25+
Blockly.Blocks['general_messenger_display_text'] = {
26+
init: function() {
27+
this.setColour(150);
28+
this.appendValueInput('text')
29+
.appendField(Blockly.BlocksTemplate.addCircle())
30+
.appendField(i18t('display text'))
31+
.setCheck('String');
32+
this.setPreviousStatement(true);
33+
this.setNextStatement(true);
34+
this.setTooltip('');
35+
this.setHelpUrl('');
36+
},
37+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @fileoverview JavaScript for the general messenger display blocks.
3+
*
4+
* @license Copyright 2018 The Coding with Chrome Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author [email protected] (Markus Bordihn)
19+
*/
20+
21+
22+
/**
23+
* Display text on local screen.
24+
* @param {!Blockly.block} block
25+
* @return {string}
26+
*/
27+
Blockly.JavaScript['general_messenger_display_text'] = function(block) {
28+
let value_text = Blockly.JavaScript.valueToCode(
29+
block, 'text', Blockly.JavaScript.ORDER_ATOMIC) || '';
30+
return 'cwcMessengerDisplay.displayText(String(' + value_text + '));\n';
31+
};

src/blocks/lego/ev3/blocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview EV3 blocks for Blockly.
2+
* @fileoverview Lego EV3 blocks for Blockly.
33
*
44
* @license Copyright 2015 The Coding with Chrome Authors.
55
*

src/blocks/lego/ev3/javascript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview JavaScript for the EV3 blocks.
2+
* @fileoverview JavaScript for the Lego EV3 blocks.
33
*
44
* @license Copyright 2015 The Coding with Chrome Authors.
55
*

0 commit comments

Comments
 (0)