From 66eeefe02e5b4690beed014e863ddfa0c69b4a75 Mon Sep 17 00:00:00 2001 From: c0repwn3r Date: Tue, 23 May 2023 09:22:48 -0400 Subject: [PATCH] pyblocks basics - framework, disable useless scratch blocks - add a couple blocks from a few categories --- .idea/.gitignore | 5 + blocks_vertical/control.js | 20 +- blocks_vertical/default_toolbox.js | 245 +++++++++++++++++++ blocks_vertical/display.js | 63 +++++ blocks_vertical/hub.js | 42 ++++ blocks_vertical/hub_status_light.js | 43 ++++ blocks_vertical/imu.js | 118 +++++++++ blocks_vertical/input.js | 34 +++ blocks_vertical/{ => upstream}/data.js | 0 blocks_vertical/{ => upstream}/event.js | 0 blocks_vertical/{ => upstream}/extensions.js | 0 blocks_vertical/{ => upstream}/looks.js | 0 blocks_vertical/{ => upstream}/motion.js | 0 blocks_vertical/{ => upstream}/procedures.js | 0 blocks_vertical/{ => upstream}/sensing.js | 0 blocks_vertical/{ => upstream}/sound.js | 0 blocks_vertical/vertical_extensions.js | 3 +- core/colours.js | 70 +++++- core/constants.js | 24 +- msg/js/en.js | 12 + msg/json/en.json | 14 +- msg/messages.js | 67 +++++ package.json | 2 +- tests/custom_procedure_playground.html | 14 +- tests/vertical_playground.html | 26 +- tests/workspace_svg/index.html | 4 +- 26 files changed, 764 insertions(+), 42 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 blocks_vertical/display.js create mode 100644 blocks_vertical/hub.js create mode 100644 blocks_vertical/hub_status_light.js create mode 100644 blocks_vertical/imu.js create mode 100644 blocks_vertical/input.js rename blocks_vertical/{ => upstream}/data.js (100%) rename blocks_vertical/{ => upstream}/event.js (100%) rename blocks_vertical/{ => upstream}/extensions.js (100%) rename blocks_vertical/{ => upstream}/looks.js (100%) rename blocks_vertical/{ => upstream}/motion.js (100%) rename blocks_vertical/{ => upstream}/procedures.js (100%) rename blocks_vertical/{ => upstream}/sensing.js (100%) rename blocks_vertical/{ => upstream}/sound.js (100%) diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..b58b603f --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/blocks_vertical/control.js b/blocks_vertical/control.js index e5bb20b5..ac42c4bf 100644 --- a/blocks_vertical/control.js +++ b/blocks_vertical/control.js @@ -175,27 +175,27 @@ Blockly.Blocks['control_stop'] = { * @this Blockly.Block */ init: function() { - var ALL_SCRIPTS = 'all'; - var THIS_SCRIPT = 'this script'; - var OTHER_SCRIPTS = 'other scripts in sprite'; + var AND_EXIT_PROGRAM = 'and exit program'; + var AND_RESTART_PROGRAM = 'and restart program'; + var AND_SHUTDOWN_HUB = 'and turn off hub'; var stopDropdown = new Blockly.FieldDropdown(function() { if (this.sourceBlock_ && this.sourceBlock_.nextConnection && this.sourceBlock_.nextConnection.isConnected()) { - return [ - [Blockly.Msg.CONTROL_STOP_OTHER, OTHER_SCRIPTS] - ]; + return [[Blockly.Msg.CONTROL_STOP_EXIT, AND_EXIT_PROGRAM], + [Blockly.Msg.CONTROL_STOP_RESTART, AND_RESTART_PROGRAM], + [Blockly.Msg.CONTROL_STOP_SHUTDOWN, AND_SHUTDOWN_HUB]]; } - return [[Blockly.Msg.CONTROL_STOP_ALL, ALL_SCRIPTS], - [Blockly.Msg.CONTROL_STOP_THIS, THIS_SCRIPT], - [Blockly.Msg.CONTROL_STOP_OTHER, OTHER_SCRIPTS] + return [[Blockly.Msg.CONTROL_STOP_EXIT, AND_EXIT_PROGRAM], + [Blockly.Msg.CONTROL_STOP_RESTART, AND_RESTART_PROGRAM], + [Blockly.Msg.CONTROL_STOP_SHUTDOWN, AND_SHUTDOWN_HUB] ]; }, function(option) { // Create an event group to keep field value and mutator in sync // Return null at the end because setValue is called here already. Blockly.Events.setGroup(true); var oldMutation = Blockly.Xml.domToText(this.sourceBlock_.mutationToDom()); - this.sourceBlock_.setNextStatement(option == OTHER_SCRIPTS); + this.sourceBlock_.setNextStatement(option == AND_SHUTDOWN_HUB); var newMutation = Blockly.Xml.domToText(this.sourceBlock_.mutationToDom()); Blockly.Events.fire(new Blockly.Events.BlockChange(this.sourceBlock_, 'mutation', null, oldMutation, newMutation)); diff --git a/blocks_vertical/default_toolbox.js b/blocks_vertical/default_toolbox.js index 8c5624fa..8516e0db 100644 --- a/blocks_vertical/default_toolbox.js +++ b/blocks_vertical/default_toolbox.js @@ -28,6 +28,248 @@ goog.require('Blockly.Blocks'); * @fileoverview Provide a default toolbox XML. */ +Blockly.Blocks.defaultToolbox = ''; + +/* Blockly.Blocks.defaultToolbox = '