Update calls to addSprite2 to use new API for adding sprites. Cleanup sprite3 representation for uploading a new sprite from an image.

This commit is contained in:
Karishma Chadha committed 2018-05-04 15:14:22 -04:00
1 parent 820008853f
commit 0bbf92f90b
3 files changed
+18 -22

No files matched your search

+1 -1
View File
@@ -39,7 +39,7 @@ class SpriteLibrary extends React.PureComponent {
clearInterval(this.intervalId);
}
handleItemSelect (item) {
this.props.vm.addSprite2(JSON.stringify(item.json));
this.props.vm.addSprite(JSON.stringify(item.json));
analytics.event({
category: 'library',
action: 'Select Sprite',
+3 -3
View File
@@ -72,13 +72,13 @@ class TargetPane extends React.Component {
}
handleSurpriseSpriteClick () {
const item = spriteLibraryContent[Math.floor(Math.random() * spriteLibraryContent.length)];
this.props.vm.addSprite2(JSON.stringify(item.json));
this.props.vm.addSprite(JSON.stringify(item.json));
}
handlePaintSpriteClick () {
// @todo this is brittle, will need to be refactored for localized libraries
const emptyItem = spriteLibraryContent.find(item => item.name === 'Empty');
if (emptyItem) {
this.props.vm.addSprite2(JSON.stringify(emptyItem.json)).then(() => {
this.props.vm.addSprite(JSON.stringify(emptyItem.json)).then(() => {
setTimeout(() => { // Wait for targets update to propagate before tab switching
this.props.onActivateTab(COSTUMES_TAB_INDEX);
});
@@ -86,7 +86,7 @@ class TargetPane extends React.Component {
}
}
handleNewSprite (spriteJSONString) {
this.props.vm.addSprite(spriteJSONString); // TODO change all instances of addSprite2 to addSprite?
this.props.vm.addSprite(spriteJSONString);
}
handleFileUploadClick () {
this.fileInput.click();
+14 -18
View File
@@ -189,24 +189,20 @@ const spriteUpload = function (fileData, fileType, spriteName, storage, handleSp
// let costume = null;
costumeUpload(fileData, fileType, `${spriteName}-costume1`, storage, (vmCostume => {
const newSprite = {
targets: [{
name: spriteName,
isStage: false,
x: 0, // what should we put here...
y: 0,
visible: true,
size: 100,
rotationStyle: 'all around',
direction: 90,
draggable: true,
currentCostume: 0,
blocks: {},
variables: {},
lists: {},
broadcasts: {},
costumes: [vmCostume],
sounds: [] // TODO are all of these necessary?
}]
name: spriteName,
isStage: false,
x: 0,
y: 0,
visible: true,
size: 100,
rotationStyle: 'all around',
direction: 90,
draggable: true,
currentCostume: 0,
blocks: {},
variables: {},
costumes: [vmCostume],
sounds: [] // TODO are all of these necessary?
};
// TODO probably just want sprite upload to handle this object directly
handleSprite(JSON.stringify(newSprite));