Skip to content

Commit f2de1ef

Browse files
committed
Improved Blockly UI Layout and visual appearance.
This changes allow to adding icons to the different Blockly sections for easier recognition.
1 parent c38187e commit f2de1ef

File tree

21 files changed

+308
-50
lines changed

21 files changed

+308
-50
lines changed

locales/deu/blocks/phaser_blocks.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@ Locales['deu'] = Locales['deu'] || {};
2727
*/
2828
/* eslint-disable max-len */
2929
Object.assign(Locales['deu'], {
30+
'BLOCKS_PHASER_AUDIO': 'Audio',
3031
'BLOCKS_PHASER_CREATE': 'Erstellen',
3132
'BLOCKS_PHASER_GAME': 'Spiel',
33+
'BLOCKS_PHASER_PRELOAD': 'Vorrausladen',
34+
'BLOCKS_PHASER_INPUT': 'Eingabe',
35+
'BLOCKS_PHASER_UPDATE': 'Aktualisieren',
36+
'BLOCKS_PHASER_RENDERER': 'Renderer',
37+
'BLOCKS_PHASER_FILES': 'Dateien',
38+
'BLOCKS_PHASER_EXAMPLE_FILES': 'Beispiel Dateien',
3239
'BLOCKS_PHASER_ON_CREATE': 'beim Erstellen',
3340
'BLOCKS_PHASER_OPEN_FILE_LIBRARY': 'Öffne Datei Bibliothek',
41+
'BLOCKS_PHASER_COLLIDE_WITH': 'kollidiert mit',
3442
});

locales/deu/sidebar.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* @fileoverview Translation file for the sidebar (german).
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+
window['Locales'] = window['Locales'] || {};
21+
Locales['deu'] = Locales['deu'] || {};
22+
23+
24+
/**
25+
* @final
26+
* @export
27+
*/
28+
/* eslint-disable max-len */
29+
Object.assign(Locales['deu'], {
30+
'SIDEBAR_LIBRARY': 'Öffne Datei Bibliothek',
31+
'SIDEBAR_MEDIA': 'Medien hochladen und einfügen',
32+
'SIDEBAR_FILE_DESCRIPTION': 'Dateibeschreibung anzeigen',
33+
'SIDEBAR_TUTORIAL': 'Tutorial starten / neustarten',
34+
});

locales/eng/blocks/phaser_blocks.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@ Locales['eng'] = Locales['eng'] || {};
2727
*/
2828
/* eslint-disable max-len */
2929
Object.assign(Locales['eng'], {
30+
'BLOCKS_PHASER_AUDIO': 'Audio',
3031
'BLOCKS_PHASER_CREATE': 'Create',
3132
'BLOCKS_PHASER_GAME': 'Game',
33+
'BLOCKS_PHASER_PRELOAD': 'Preload',
34+
'BLOCKS_PHASER_INPUT': 'Input',
35+
'BLOCKS_PHASER_UPDATE': 'Update',
36+
'BLOCKS_PHASER_RENDERER': 'Renderer',
37+
'BLOCKS_PHASER_FILES': 'Files',
38+
'BLOCKS_PHASER_EXAMPLE_FILES': 'Example Files',
3239
'BLOCKS_PHASER_ON_CREATE': 'on create',
3340
'BLOCKS_PHASER_OPEN_FILE_LIBRARY': 'Open file library',
41+
'BLOCKS_PHASER_COLLIDE_WITH': 'collide with',
3442
});

locales/eng/sidebar.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* @fileoverview Translation file for the sidebar (english).
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+
window['Locales'] = window['Locales'] || {};
21+
Locales['eng'] = Locales['eng'] || {};
22+
23+
24+
/**
25+
* @final
26+
* @export
27+
*/
28+
/* eslint-disable max-len */
29+
Object.assign(Locales['eng'], {
30+
'SIDEBAR_LIBRARY': 'Open file library',
31+
'SIDEBAR_MEDIA': 'Upload and insert media',
32+
'SIDEBAR_FILE_DESCRIPTION': 'Show file description',
33+
'SIDEBAR_TUTORIAL': 'Start/restart tutorial',
34+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@
114114
"lint": "eslint .",
115115
"show-updates": "ncu",
116116
"sync": "echo Syncing. Please wait ... && git pull && git submodule init && git submodule update && npm run update",
117-
"update": "npm run clean && ncu -u -a && npm install && npm update -a && npm run build-third_party && npm test"
117+
"update": "npm run clean && ncu -u -a --packageFile package.json && npm install && npm update -a && npm run build-third_party && npm test"
118118
}
119119
}

src/blocks/general/template.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ Blockly.BlocksTemplate.addCircle = function() {
4747
};
4848

4949

50+
/**
51+
* @return {!Blockly.FieldImage}
52+
*/
53+
Blockly.BlocksTemplate.collide = function() {
54+
return new Blockly.FieldImage(
55+
'../images/icons/collide_20pt.png', 18, 18, '▼');
56+
};
57+
58+
5059
/**
5160
* @return {!Blockly.FieldImage}
5261
*/

src/blocks/phaser/arcade_physics/blocks.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Blockly.Blocks['phaser_physics_arcade_enable'] = {
134134
Blockly.Blocks['phaser_physics_arcade_overlap'] = {
135135
init: function() {
136136
this.appendDummyInput()
137-
.appendField(Blockly.BlocksTemplate.runningMan())
137+
.appendField(Blockly.BlocksTemplate.collide())
138138
.appendField(i18t('on collision between'));
139139
this.appendValueInput('object1');
140140
this.appendDummyInput()
@@ -157,12 +157,10 @@ Blockly.Blocks['phaser_physics_arcade_overlap'] = {
157157
*/
158158
Blockly.Blocks['phaser_physics_arcade_collide'] = {
159159
init: function() {
160+
this.appendValueInput('object1')
161+
.appendField(Blockly.BlocksTemplate.collide());
160162
this.appendDummyInput()
161-
.appendField(Blockly.BlocksTemplate.point())
162-
.appendField(i18t('collide between'));
163-
this.appendValueInput('object1');
164-
this.appendDummyInput()
165-
.appendField(i18t('and'));
163+
.appendField(i18t('BLOCKS_PHASER_COLLIDE_WITH'));
166164
this.appendValueInput('object2');
167165
this.setPreviousStatement(true, 'Update');
168166
this.setNextStatement(true, 'Update');

src/blocks/phaser/create/blocks.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,29 @@ Blockly.Blocks['phaser_add_background'] = {
7777
};
7878

7979

80+
/**
81+
* Add background with specific size.
82+
*/
83+
Blockly.Blocks['phaser_add_background_scaled'] = {
84+
init: function() {
85+
this.appendDummyInput()
86+
.appendField(Blockly.BlocksTemplate.point())
87+
.appendField(i18t('add background image'))
88+
.appendField(new Blockly.FieldTextInput('name'), 'sprite')
89+
.appendField(Blockly.BlocksTemplate.image())
90+
.appendField(i18t('with size'))
91+
.appendField(new Blockly.FieldNumber(0, 0, 5760), 'width')
92+
.appendField('x')
93+
.appendField(new Blockly.FieldNumber(0, 0, 2160), 'height');
94+
this.setPreviousStatement(true, 'Create');
95+
this.setNextStatement(true, 'Create');
96+
this.setColour(30);
97+
this.setTooltip('');
98+
this.setHelpUrl('');
99+
},
100+
};
101+
102+
80103
/**
81104
* Add group.
82105
*/

src/blocks/phaser/create/javascript.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,24 @@ Blockly.JavaScript['phaser_stage_background_color'] = function(block) {
5151
*/
5252
Blockly.JavaScript['phaser_add_background'] = function(block) {
5353
let text_sprite = block.getFieldValue('sprite');
54-
return 'game.add.image(0, 0, \'' + text_sprite + '\')\n';
54+
return 'game.add.image(0, 0, \'' + text_sprite + '\');\n';
55+
};
56+
57+
58+
/**
59+
* Add background with specific size.
60+
* @param {Blockly.Block} block
61+
* @return {!string}
62+
*/
63+
Blockly.JavaScript['phaser_add_background_scaled'] = function(block) {
64+
let text_sprite = block.getFieldValue('sprite');
65+
let number_width = Number(block.getFieldValue('width')) || 'game.world.width';
66+
let number_height =
67+
Number(block.getFieldValue('height')) || 'game.world.height';
68+
return 'var backgroundImage = game.add.image(0, 0, \'' +
69+
text_sprite + '\');\n' +
70+
'backgroundImage.width = ' + number_width + ';\n' +
71+
'backgroundImage.height = ' + number_height + ';\n';
5572
};
5673

5774

src/blocks/phaser/game/javascript.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626
*/
2727
Blockly.JavaScript['phaser_game'] = function(block) {
2828
let text_name = block.getFieldValue('name');
29-
let number_width = block.getFieldValue('width');
30-
let number_height = block.getFieldValue('height');
29+
let number_width =
30+
Number(block.getFieldValue('width')) || 'window.innerWidth';
31+
let number_height =
32+
Number(block.getFieldValue('height')) || 'window.innerHeight';
3133
return 'var obstacle_group;\n' +
32-
'var game = new Phaser.Game(' + number_width + ' || window.innerWidth, ' +
33-
number_height + ' || window.innerHeight, Phaser.AUTO, \'' +
34-
text_name + '\');\n';
34+
'var game = new Phaser.Game(' + number_width + ', ' + number_height +
35+
', Phaser.AUTO, \'' + text_name + '\');\n';
3536
};
3637

3738

0 commit comments

Comments
 (0)