From 6837513d3f217e94522a3ce756273d6ff8e7538c Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Wed, 17 Apr 2024 15:54:48 -0700 Subject: [PATCH] fix: readd the sound blocks (#24) * fix: readd the sound blocks * chore: remove vestigial sound_sounds_menu implementation --- blocks_vertical/sound.js | 61 ++++++++-------------------------------- src/index.js | 1 + 2 files changed, 13 insertions(+), 49 deletions(-) diff --git a/blocks_vertical/sound.js b/blocks_vertical/sound.js index 03c33630ba..fb39ed2eea 100644 --- a/blocks_vertical/sound.js +++ b/blocks_vertical/sound.js @@ -18,51 +18,14 @@ * limitations under the License. */ -'use strict'; - -goog.provide('Blockly.Blocks.sound'); - -goog.require('Blockly.Blocks'); -goog.require('Blockly.Colours'); -goog.require('Blockly.constants'); -goog.require('Blockly.ScratchBlocks.VerticalExtensions'); +import * as Blockly from 'blockly/core'; +import {Categories} from '../src/categories.js'; Blockly.Blocks['sound_sounds_menu'] = { /** - * Sound effects drop-down menu. + * Sound effects drop-down menu. Populated dynamically by scratch-gui. * @this Blockly.Block */ - init: function() { - this.jsonInit({ - "message0": "%1", - "args0": [ - { - "type": "field_dropdown", - "name": "SOUND_MENU", - "options": [ - ['1', '0'], - ['2', '1'], - ['3', '2'], - ['4', '3'], - ['5', '4'], - ['6', '5'], - ['7', '6'], - ['8', '7'], - ['9', '8'], - ['10', '9'], - ['call a function', function() { - window.alert('function called!');} - ] - ] - } - ], - "colour": Blockly.Colours.sounds.secondary, - "colourSecondary": Blockly.Colours.sounds.secondary, - "colourTertiary": Blockly.Colours.sounds.tertiary, - "colourQuaternary": Blockly.Colours.sounds.quaternary, - "extensions": ["output_string"] - }); - } }; Blockly.Blocks['sound_play'] = { @@ -79,7 +42,7 @@ Blockly.Blocks['sound_play'] = { "name": "SOUND_MENU" } ], - "category": Blockly.Categories.sound, + "category": Categories.sound, "extensions": ["colours_sounds", "shape_statement"] }); } @@ -99,7 +62,7 @@ Blockly.Blocks['sound_playuntildone'] = { "name": "SOUND_MENU" } ], - "category": Blockly.Categories.sound, + "category": Categories.sound, "extensions": ["colours_sounds", "shape_statement"] }); } @@ -113,7 +76,7 @@ Blockly.Blocks['sound_stopallsounds'] = { init: function() { this.jsonInit({ "message0": Blockly.Msg.SOUND_STOPALLSOUNDS, - "category": Blockly.Categories.sound, + "category": Categories.sound, "extensions": ["colours_sounds", "shape_statement"] }); } @@ -141,7 +104,7 @@ Blockly.Blocks['sound_seteffectto'] = { "name": "VALUE" } ], - "category": Blockly.Categories.sound, + "category": Categories.sound, "extensions": ["colours_sounds", "shape_statement"] }); } @@ -170,7 +133,7 @@ Blockly.Blocks['sound_changeeffectby'] = { "name": "VALUE" } ], - "category": Blockly.Categories.sound, + "category": Categories.sound, "extensions": ["colours_sounds", "shape_statement"] }); } @@ -184,7 +147,7 @@ Blockly.Blocks['sound_cleareffects'] = { init: function() { this.jsonInit({ "message0": Blockly.Msg.SOUND_CLEAREFFECTS, - "category": Blockly.Categories.sound, + "category": Categories.sound, "extensions": ["colours_sounds", "shape_statement"] }); } @@ -204,7 +167,7 @@ Blockly.Blocks['sound_changevolumeby'] = { "name": "VOLUME" } ], - "category": Blockly.Categories.sound, + "category": Categories.sound, "extensions": ["colours_sounds", "shape_statement"] }); } @@ -224,7 +187,7 @@ Blockly.Blocks['sound_setvolumeto'] = { "name": "VOLUME" } ], - "category": Blockly.Categories.sound, + "category": Categories.sound, "extensions": ["colours_sounds", "shape_statement"] }); } @@ -238,7 +201,7 @@ Blockly.Blocks['sound_volume'] = { init: function() { this.jsonInit({ "message0": Blockly.Msg.SOUND_VOLUME, - "category": Blockly.Categories.sound, + "category": Categories.sound, "checkboxInFlyout": true, "extensions": ["colours_sounds", "output_number"] }); diff --git a/src/index.js b/src/index.js index 22fd9f0a64..ab673fd4d0 100644 --- a/src/index.js +++ b/src/index.js @@ -11,6 +11,7 @@ import '../blocks_vertical/event.js'; import '../blocks_vertical/looks.js'; import '../blocks_vertical/motion.js'; import '../blocks_vertical/operators.js'; +import '../blocks_vertical/sound.js'; export * from 'blockly'; export * from './categories.js';