diff --git a/src/components/sprite-selector/sprite-list.jsx b/src/components/sprite-selector/sprite-list.jsx index a29912b79385183e8c49e0ac819ba5288ec3e761..df42c6c28e94024d15c58e2d388ea4c3ce608fbf 100644 --- a/src/components/sprite-selector/sprite-list.jsx +++ b/src/components/sprite-selector/sprite-list.jsx @@ -53,8 +53,11 @@ const SpriteList = function (props) { // Note the absence of the self-sharing check: a sprite can share assets with itself. // This is a quirk of 2.0, but seems worth leaving possible, it // allows quick (albeit unusual) duplication of assets. - isRaised = isRaised || draggingType === DragConstants.COSTUME || - draggingType === DragConstants.SOUND; + isRaised = isRaised || [ + DragConstants.COSTUME, + DragConstants.SOUND, + DragConstants.BACKPACK_COSTUME, + DragConstants.BACKPACK_SOUND].includes(draggingType); return ( <SortableAsset diff --git a/src/containers/stage-selector.jsx b/src/containers/stage-selector.jsx index aeff4f2ad963de136829471b67d2dd551f45a0e4..e5a86fcc067417198d55724646f85f1ebecebfa9 100644 --- a/src/containers/stage-selector.jsx +++ b/src/containers/stage-selector.jsx @@ -16,7 +16,13 @@ import backdropLibraryContent from '../lib/libraries/backdrops.json'; import costumeLibraryContent from '../lib/libraries/costumes.json'; import {handleFileUpload, costumeUpload} from '../lib/file-uploader.js'; -const dragTypes = [DragConstants.COSTUME, DragConstants.SOUND]; +const dragTypes = [ + DragConstants.COSTUME, + DragConstants.SOUND, + DragConstants.BACKPACK_COSTUME, + DragConstants.BACKPACK_SOUND +]; + const DroppableStage = DropAreaHOC(dragTypes)(StageSelectorComponent); class StageSelector extends React.Component { @@ -86,6 +92,15 @@ class StageSelector extends React.Component { this.props.vm.shareCostumeToTarget(dragInfo.index, this.props.id); } else if (dragInfo.dragType === DragConstants.SOUND) { this.props.vm.shareSoundToTarget(dragInfo.index, this.props.id); + } else if (dragInfo.dragType === DragConstants.BACKPACK_COSTUME) { + this.props.vm.addCostume(dragInfo.payload.body, { + name: dragInfo.payload.name + }, this.props.id); + } else if (dragInfo.dragType === DragConstants.BACKPACK_SOUND) { + this.props.vm.addSound({ + md5: dragInfo.payload.body, + name: dragInfo.payload.name + }, this.props.id); } } setFileInput (input) { diff --git a/src/containers/target-pane.jsx b/src/containers/target-pane.jsx index a116b3c0788127d6743e7555ecb1cdb34016d97d..705957491d3d5840ef72d0bace44ae478975d366 100644 --- a/src/containers/target-pane.jsx +++ b/src/containers/target-pane.jsx @@ -152,6 +152,18 @@ class TargetPane extends React.Component { this.props.vm.shareCostumeToTarget(dragInfo.index, targetId); } else if (targetId && dragInfo.dragType === DragConstants.SOUND) { this.props.vm.shareSoundToTarget(dragInfo.index, targetId); + } else if (dragInfo.dragType === DragConstants.BACKPACK_COSTUME) { + // In scratch 2, this only creates a new sprite from the costume. + // We may be able to handle both kinds of drops, depending on where + // the drop happens. For now, just add the costume. + this.props.vm.addCostume(dragInfo.payload.body, { + name: dragInfo.payload.name + }, targetId); + } else if (dragInfo.dragType === DragConstants.BACKPACK_SOUND) { + this.props.vm.addSound({ + md5: dragInfo.payload.body, + name: dragInfo.payload.name + }, targetId); } } }