Skip to content
Snippets Groups Projects
Unverified Commit a46b6cae authored by Ray Schamp's avatar Ray Schamp Committed by GitHub
Browse files

Merge pull request #2745 from paulkaplan/backpack-to-tiles

Add from backpack to sprite/stage tiles
parents bc93a131 b3932385
No related branches found
No related tags found
No related merge requests found
...@@ -53,8 +53,11 @@ const SpriteList = function (props) { ...@@ -53,8 +53,11 @@ const SpriteList = function (props) {
// Note the absence of the self-sharing check: a sprite can share assets with itself. // 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 // This is a quirk of 2.0, but seems worth leaving possible, it
// allows quick (albeit unusual) duplication of assets. // allows quick (albeit unusual) duplication of assets.
isRaised = isRaised || draggingType === DragConstants.COSTUME || isRaised = isRaised || [
draggingType === DragConstants.SOUND; DragConstants.COSTUME,
DragConstants.SOUND,
DragConstants.BACKPACK_COSTUME,
DragConstants.BACKPACK_SOUND].includes(draggingType);
return ( return (
<SortableAsset <SortableAsset
......
...@@ -16,7 +16,13 @@ import backdropLibraryContent from '../lib/libraries/backdrops.json'; ...@@ -16,7 +16,13 @@ import backdropLibraryContent from '../lib/libraries/backdrops.json';
import costumeLibraryContent from '../lib/libraries/costumes.json'; import costumeLibraryContent from '../lib/libraries/costumes.json';
import {handleFileUpload, costumeUpload} from '../lib/file-uploader.js'; 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); const DroppableStage = DropAreaHOC(dragTypes)(StageSelectorComponent);
class StageSelector extends React.Component { class StageSelector extends React.Component {
...@@ -86,6 +92,15 @@ class StageSelector extends React.Component { ...@@ -86,6 +92,15 @@ class StageSelector extends React.Component {
this.props.vm.shareCostumeToTarget(dragInfo.index, this.props.id); this.props.vm.shareCostumeToTarget(dragInfo.index, this.props.id);
} else if (dragInfo.dragType === DragConstants.SOUND) { } else if (dragInfo.dragType === DragConstants.SOUND) {
this.props.vm.shareSoundToTarget(dragInfo.index, this.props.id); 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) { setFileInput (input) {
......
...@@ -156,6 +156,18 @@ class TargetPane extends React.Component { ...@@ -156,6 +156,18 @@ class TargetPane extends React.Component {
this.props.vm.shareCostumeToTarget(dragInfo.index, targetId); this.props.vm.shareCostumeToTarget(dragInfo.index, targetId);
} else if (targetId && dragInfo.dragType === DragConstants.SOUND) { } else if (targetId && dragInfo.dragType === DragConstants.SOUND) {
this.props.vm.shareSoundToTarget(dragInfo.index, targetId); 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);
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment