From 9be9d3da11461f218108eb3375875e6363208a7b Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 4 Feb 2014 14:45:15 +0100 Subject: Import sounds from the project menu Thanks, Brian, for the changeset! --- gui.js | 28 +++++++++++++++++++++++++++- history.txt | 3 ++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/gui.js b/gui.js index 1943636..96903a0 100644 --- a/gui.js +++ b/gui.js @@ -64,7 +64,7 @@ standardSettings, Sound, BlockMorph, ToggleMorph, InputSlotDialogMorph, ScriptsMorph, isNil, SymbolMorph, BlockExportDialogMorph, BlockImportDialogMorph, SnapTranslator, localize, List, InputSlotMorph, SnapCloud, Uint8Array, HandleMorph, SVG_Costume, fontHeight, hex_sha512, -sb, CommentMorph, CommandBlockMorph, BlockLabelPlaceHolderMorph*/ +sb, CommentMorph, CommandBlockMorph, BlockLabelPlaceHolderMorph, Audio*/ // Global stuff //////////////////////////////////////////////////////// @@ -2415,6 +2415,32 @@ IDE_Morph.prototype.projectMenu = function () { }, 'Select a costume from the media library' ); + menu.addItem( + localize('Sounds') + '...', + function () { + var names = this.getCostumesList('Sounds'), + libMenu = new MenuMorph(this, 'Import sound'); + + function loadSound(name) { + var url = 'Sounds/' + name, + audio = new Audio(); + audio.src = url; + audio.load(); + myself.droppedAudio(audio, name); + } + + names.forEach(function (line) { + if (line.length > 0) { + libMenu.addItem( + line, + function () {loadSound(line); } + ); + } + }); + libMenu.popup(world, pos); + }, + 'Select a sound from the media library' + ); menu.popup(world, pos); }; diff --git a/history.txt b/history.txt index d1fea7e..577e17a 100755 --- a/history.txt +++ b/history.txt @@ -2078,4 +2078,5 @@ ______ 140204 ------ -* GUI: Import costumes and background from the project menu, thanks, Brian, for the changeset! +* GUI: Import costumes and backgrounds from the project menu, thanks, Brian, for the changeset! +* GUI: Import sounds from the project menu, thanks, Brian, for the changeset! -- cgit v1.3.1