Skip to content

Commit

Permalink
fix: readd the sound blocks (scratchfoundation#24)
Browse files Browse the repository at this point in the history
* fix: readd the sound blocks

* chore: remove vestigial sound_sounds_menu implementation
  • Loading branch information
gonfunko authored Apr 17, 2024
1 parent 34f07c0 commit 6837513
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 49 deletions.
61 changes: 12 additions & 49 deletions blocks_vertical/sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = {
Expand All @@ -79,7 +42,7 @@ Blockly.Blocks['sound_play'] = {
"name": "SOUND_MENU"
}
],
"category": Blockly.Categories.sound,
"category": Categories.sound,
"extensions": ["colours_sounds", "shape_statement"]
});
}
Expand All @@ -99,7 +62,7 @@ Blockly.Blocks['sound_playuntildone'] = {
"name": "SOUND_MENU"
}
],
"category": Blockly.Categories.sound,
"category": Categories.sound,
"extensions": ["colours_sounds", "shape_statement"]
});
}
Expand All @@ -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"]
});
}
Expand Down Expand Up @@ -141,7 +104,7 @@ Blockly.Blocks['sound_seteffectto'] = {
"name": "VALUE"
}
],
"category": Blockly.Categories.sound,
"category": Categories.sound,
"extensions": ["colours_sounds", "shape_statement"]
});
}
Expand Down Expand Up @@ -170,7 +133,7 @@ Blockly.Blocks['sound_changeeffectby'] = {
"name": "VALUE"
}
],
"category": Blockly.Categories.sound,
"category": Categories.sound,
"extensions": ["colours_sounds", "shape_statement"]
});
}
Expand All @@ -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"]
});
}
Expand All @@ -204,7 +167,7 @@ Blockly.Blocks['sound_changevolumeby'] = {
"name": "VOLUME"
}
],
"category": Blockly.Categories.sound,
"category": Categories.sound,
"extensions": ["colours_sounds", "shape_statement"]
});
}
Expand All @@ -224,7 +187,7 @@ Blockly.Blocks['sound_setvolumeto'] = {
"name": "VOLUME"
}
],
"category": Blockly.Categories.sound,
"category": Categories.sound,
"extensions": ["colours_sounds", "shape_statement"]
});
}
Expand All @@ -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"]
});
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 6837513

Please sign in to comment.