|
18 | 18 | * limitations under the License. |
19 | 19 | */ |
20 | 20 |
|
21 | | -'use strict'; |
22 | | - |
23 | | -goog.provide('Blockly.Blocks.motion'); |
24 | | - |
25 | | -goog.require('Blockly.Blocks'); |
26 | | -goog.require('Blockly.Colours'); |
27 | | -goog.require('Blockly.constants'); |
28 | | -goog.require('Blockly.ScratchBlocks.VerticalExtensions'); |
| 21 | +import * as Blockly from 'blockly/core'; |
| 22 | +import {Categories} from '../src/categories.js'; |
29 | 23 |
|
30 | 24 |
|
31 | 25 | Blockly.Blocks['motion_movesteps'] = { |
@@ -42,7 +36,7 @@ Blockly.Blocks['motion_movesteps'] = { |
42 | 36 | "name": "STEPS" |
43 | 37 | } |
44 | 38 | ], |
45 | | - "category": Blockly.Categories.motion, |
| 39 | + "category": Categories.motion, |
46 | 40 | "extensions": ["colours_motion", "shape_statement"] |
47 | 41 | }); |
48 | 42 | } |
@@ -59,7 +53,7 @@ Blockly.Blocks['motion_turnright'] = { |
59 | 53 | "args0": [ |
60 | 54 | { |
61 | 55 | "type": "field_image", |
62 | | - "src": Blockly.mainWorkspace.options.pathToMedia + "rotate-right.svg", |
| 56 | + "src": Blockly.getMainWorkspace().options.pathToMedia + "rotate-right.svg", |
63 | 57 | "width": 24, |
64 | 58 | "height": 24 |
65 | 59 | }, |
@@ -68,7 +62,7 @@ Blockly.Blocks['motion_turnright'] = { |
68 | 62 | "name": "DEGREES" |
69 | 63 | } |
70 | 64 | ], |
71 | | - "category": Blockly.Categories.motion, |
| 65 | + "category": Categories.motion, |
72 | 66 | "extensions": ["colours_motion", "shape_statement"] |
73 | 67 | }); |
74 | 68 | } |
@@ -85,7 +79,7 @@ Blockly.Blocks['motion_turnleft'] = { |
85 | 79 | "args0": [ |
86 | 80 | { |
87 | 81 | "type": "field_image", |
88 | | - "src": Blockly.mainWorkspace.options.pathToMedia + "rotate-left.svg", |
| 82 | + "src": Blockly.getMainWorkspace().options.pathToMedia + "rotate-left.svg", |
89 | 83 | "width": 24, |
90 | 84 | "height": 24 |
91 | 85 | }, |
@@ -94,7 +88,7 @@ Blockly.Blocks['motion_turnleft'] = { |
94 | 88 | "name": "DEGREES" |
95 | 89 | } |
96 | 90 | ], |
97 | | - "category": Blockly.Categories.motion, |
| 91 | + "category": Categories.motion, |
98 | 92 | "extensions": ["colours_motion", "shape_statement"] |
99 | 93 | }); |
100 | 94 | } |
@@ -114,7 +108,7 @@ Blockly.Blocks['motion_pointindirection'] = { |
114 | 108 | "name": "DIRECTION" |
115 | 109 | } |
116 | 110 | ], |
117 | | - "category": Blockly.Categories.motion, |
| 111 | + "category": Categories.motion, |
118 | 112 | "extensions": ["colours_motion", "shape_statement"] |
119 | 113 | }); |
120 | 114 | } |
@@ -138,11 +132,7 @@ Blockly.Blocks['motion_pointtowards_menu'] = { |
138 | 132 | ] |
139 | 133 | } |
140 | 134 | ], |
141 | | - "colour": Blockly.Colours.motion.secondary, |
142 | | - "colourSecondary": Blockly.Colours.motion.secondary, |
143 | | - "colourTertiary": Blockly.Colours.motion.tertiary, |
144 | | - "colourQuaternary": Blockly.Colours.motion.quaternary, |
145 | | - "extensions": ["output_string"] |
| 135 | + "extensions": ["colours_motion", "output_string"] |
146 | 136 | }); |
147 | 137 | } |
148 | 138 | }; |
@@ -161,7 +151,7 @@ Blockly.Blocks['motion_pointtowards'] = { |
161 | 151 | "name": "TOWARDS" |
162 | 152 | } |
163 | 153 | ], |
164 | | - "category": Blockly.Categories.motion, |
| 154 | + "category": Categories.motion, |
165 | 155 | "extensions": ["colours_motion", "shape_statement"] |
166 | 156 | }); |
167 | 157 | } |
@@ -185,11 +175,7 @@ Blockly.Blocks['motion_goto_menu'] = { |
185 | 175 | ] |
186 | 176 | } |
187 | 177 | ], |
188 | | - "colour": Blockly.Colours.motion.secondary, |
189 | | - "colourSecondary": Blockly.Colours.motion.secondary, |
190 | | - "colourTertiary": Blockly.Colours.motion.tertiary, |
191 | | - "colourQuaternary": Blockly.Colours.motion.quaternary, |
192 | | - "extensions": ["output_string"] |
| 178 | + "extensions": ["colours_motion", "output_string"] |
193 | 179 | }); |
194 | 180 | } |
195 | 181 | }; |
@@ -212,7 +198,7 @@ Blockly.Blocks['motion_gotoxy'] = { |
212 | 198 | "name": "Y" |
213 | 199 | } |
214 | 200 | ], |
215 | | - "category": Blockly.Categories.motion, |
| 201 | + "category": Categories.motion, |
216 | 202 | "extensions": ["colours_motion", "shape_statement"] |
217 | 203 | }); |
218 | 204 | } |
@@ -232,7 +218,7 @@ Blockly.Blocks['motion_goto'] = { |
232 | 218 | "name": "TO" |
233 | 219 | } |
234 | 220 | ], |
235 | | - "category": Blockly.Categories.motion, |
| 221 | + "category": Categories.motion, |
236 | 222 | "extensions": ["colours_motion", "shape_statement"] |
237 | 223 | }); |
238 | 224 | } |
@@ -260,7 +246,7 @@ Blockly.Blocks['motion_glidesecstoxy'] = { |
260 | 246 | "name": "Y" |
261 | 247 | } |
262 | 248 | ], |
263 | | - "category": Blockly.Categories.motion, |
| 249 | + "category": Categories.motion, |
264 | 250 | "extensions": ["colours_motion", "shape_statement"] |
265 | 251 | }); |
266 | 252 | } |
@@ -284,11 +270,7 @@ Blockly.Blocks['motion_glideto_menu'] = { |
284 | 270 | ] |
285 | 271 | } |
286 | 272 | ], |
287 | | - "colour": Blockly.Colours.motion.secondary, |
288 | | - "colourSecondary": Blockly.Colours.motion.secondary, |
289 | | - "colourTertiary": Blockly.Colours.motion.tertiary, |
290 | | - "colourQuaternary": Blockly.Colours.motion.quaternary, |
291 | | - "extensions": ["output_string"] |
| 273 | + "extensions": ["colours_motion", "output_string"] |
292 | 274 | }); |
293 | 275 | } |
294 | 276 | }; |
@@ -311,7 +293,7 @@ Blockly.Blocks['motion_glideto'] = { |
311 | 293 | "name": "TO" |
312 | 294 | } |
313 | 295 | ], |
314 | | - "category": Blockly.Categories.motion, |
| 296 | + "category": Categories.motion, |
315 | 297 | "extensions": ["colours_motion", "shape_statement"] |
316 | 298 | }); |
317 | 299 | } |
@@ -331,7 +313,7 @@ Blockly.Blocks['motion_changexby'] = { |
331 | 313 | "name": "DX" |
332 | 314 | } |
333 | 315 | ], |
334 | | - "category": Blockly.Categories.motion, |
| 316 | + "category": Categories.motion, |
335 | 317 | "extensions": ["colours_motion", "shape_statement"] |
336 | 318 | }); |
337 | 319 | } |
@@ -351,7 +333,7 @@ Blockly.Blocks['motion_setx'] = { |
351 | 333 | "name": "X" |
352 | 334 | } |
353 | 335 | ], |
354 | | - "category": Blockly.Categories.motion, |
| 336 | + "category": Categories.motion, |
355 | 337 | "extensions": ["colours_motion", "shape_statement"] |
356 | 338 | }); |
357 | 339 | } |
@@ -371,7 +353,7 @@ Blockly.Blocks['motion_changeyby'] = { |
371 | 353 | "name": "DY" |
372 | 354 | } |
373 | 355 | ], |
374 | | - "category": Blockly.Categories.motion, |
| 356 | + "category": Categories.motion, |
375 | 357 | "extensions": ["colours_motion", "shape_statement"] |
376 | 358 | }); |
377 | 359 | } |
@@ -391,7 +373,7 @@ Blockly.Blocks['motion_sety'] = { |
391 | 373 | "name": "Y" |
392 | 374 | } |
393 | 375 | ], |
394 | | - "category": Blockly.Categories.motion, |
| 376 | + "category": Categories.motion, |
395 | 377 | "extensions": ["colours_motion", "shape_statement"] |
396 | 378 | }); |
397 | 379 | } |
@@ -405,7 +387,7 @@ Blockly.Blocks['motion_ifonedgebounce'] = { |
405 | 387 | init: function() { |
406 | 388 | this.jsonInit({ |
407 | 389 | "message0": Blockly.Msg.MOTION_IFONEDGEBOUNCE, |
408 | | - "category": Blockly.Categories.motion, |
| 390 | + "category": Categories.motion, |
409 | 391 | "extensions": ["colours_motion", "shape_statement"] |
410 | 392 | }); |
411 | 393 | } |
@@ -430,7 +412,7 @@ Blockly.Blocks['motion_setrotationstyle'] = { |
430 | 412 | ] |
431 | 413 | } |
432 | 414 | ], |
433 | | - "category": Blockly.Categories.motion, |
| 415 | + "category": Categories.motion, |
434 | 416 | "extensions": ["colours_motion", "shape_statement"] |
435 | 417 | }); |
436 | 418 | } |
@@ -444,7 +426,7 @@ Blockly.Blocks['motion_xposition'] = { |
444 | 426 | init: function() { |
445 | 427 | this.jsonInit({ |
446 | 428 | "message0": Blockly.Msg.MOTION_XPOSITION, |
447 | | - "category": Blockly.Categories.motion, |
| 429 | + "category": Categories.motion, |
448 | 430 | "checkboxInFlyout": true, |
449 | 431 | "extensions": ["colours_motion", "output_number"] |
450 | 432 | }); |
@@ -459,7 +441,7 @@ Blockly.Blocks['motion_yposition'] = { |
459 | 441 | init: function() { |
460 | 442 | this.jsonInit({ |
461 | 443 | "message0": Blockly.Msg.MOTION_YPOSITION, |
462 | | - "category": Blockly.Categories.motion, |
| 444 | + "category": Categories.motion, |
463 | 445 | "checkboxInFlyout": true, |
464 | 446 | "extensions": ["colours_motion", "output_number"] |
465 | 447 | }); |
@@ -474,7 +456,7 @@ Blockly.Blocks['motion_direction'] = { |
474 | 456 | init: function() { |
475 | 457 | this.jsonInit({ |
476 | 458 | "message0": Blockly.Msg.MOTION_DIRECTION, |
477 | | - "category": Blockly.Categories.motion, |
| 459 | + "category": Categories.motion, |
478 | 460 | "checkboxInFlyout": true, |
479 | 461 | "extensions": ["colours_motion", "output_number"] |
480 | 462 | }); |
@@ -497,7 +479,7 @@ Blockly.Blocks['motion_scroll_right'] = { |
497 | 479 | "name": "DISTANCE" |
498 | 480 | } |
499 | 481 | ], |
500 | | - "category": Blockly.Categories.motion, |
| 482 | + "category": Categories.motion, |
501 | 483 | "extensions": ["colours_motion", "shape_statement"] |
502 | 484 | }); |
503 | 485 | } |
@@ -519,7 +501,7 @@ Blockly.Blocks['motion_scroll_up'] = { |
519 | 501 | "name": "DISTANCE" |
520 | 502 | } |
521 | 503 | ], |
522 | | - "category": Blockly.Categories.motion, |
| 504 | + "category": Categories.motion, |
523 | 505 | "extensions": ["colours_motion", "shape_statement"] |
524 | 506 | }); |
525 | 507 | } |
@@ -548,7 +530,7 @@ Blockly.Blocks['motion_align_scene'] = { |
548 | 530 | ] |
549 | 531 | } |
550 | 532 | ], |
551 | | - "category": Blockly.Categories.motion, |
| 533 | + "category": Categories.motion, |
552 | 534 | "extensions": ["colours_motion", "shape_statement"] |
553 | 535 | }); |
554 | 536 | } |
@@ -564,7 +546,7 @@ Blockly.Blocks['motion_xscroll'] = { |
564 | 546 | init: function() { |
565 | 547 | this.jsonInit({ |
566 | 548 | "message0": Blockly.Msg.MOTION_XSCROLL, |
567 | | - "category": Blockly.Categories.motion, |
| 549 | + "category": Categories.motion, |
568 | 550 | "extensions": ["colours_motion", "output_number"] |
569 | 551 | }); |
570 | 552 | } |
@@ -580,7 +562,7 @@ Blockly.Blocks['motion_yscroll'] = { |
580 | 562 | init: function() { |
581 | 563 | this.jsonInit({ |
582 | 564 | "message0": Blockly.Msg.MOTION_YSCROLL, |
583 | | - "category": Blockly.Categories.motion, |
| 565 | + "category": Categories.motion, |
584 | 566 | "extensions": ["colours_motion", "output_number"] |
585 | 567 | }); |
586 | 568 | } |
|