Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(demo) Remove bitmap resolution from asset library json #5475

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/library/library.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ class LibraryComponent extends React.Component {
extensionId={dataItem.extensionId}
featured={dataItem.featured}
hidden={dataItem.hidden}
iconMd5={dataItem.md5}
iconMd5={dataItem.costumes ? dataItem.costumes[0].md5ext : dataItem.md5ext}
iconRawURL={dataItem.rawURL}
icons={dataItem.json && dataItem.json.costumes}
icons={dataItem.costumes}
id={index}
insetIconURL={dataItem.insetIconURL}
internetConnectionRequired={dataItem.internetConnectionRequired}
Expand Down
8 changes: 4 additions & 4 deletions src/containers/backdrop-library.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class BackdropLibrary extends React.Component {
handleItemSelect (item) {
const vmBackdrop = {
name: item.name,
rotationCenterX: item.info[0] && item.info[0] / 2,
rotationCenterY: item.info[1] && item.info[1] / 2,
bitmapResolution: item.info.length > 2 ? item.info[2] : 1,
rotationCenterX: item.rotationCenterX,
rotationCenterY: item.rotationCenterY,
bitmapResolution: item.bitmapResolution,
skinId: null
};
// Do not switch to stage, just add the backdrop
this.props.vm.addBackdrop(item.md5, vmBackdrop);
this.props.vm.addBackdrop(item.md5ext, vmBackdrop);
}
render () {
return (
Expand Down
12 changes: 4 additions & 8 deletions src/containers/costume-library.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@ class CostumeLibrary extends React.PureComponent {
]);
}
handleItemSelected (item) {
const split = item.md5.split('.');
const type = split.length > 1 ? split[1] : null;
const rotationCenterX = type === 'svg' ? item.info[0] : item.info[0] / 2;
const rotationCenterY = type === 'svg' ? item.info[1] : item.info[1] / 2;
const vmCostume = {
name: item.name,
rotationCenterX,
rotationCenterY,
bitmapResolution: item.info.length > 2 ? item.info[2] : 1,
rotationCenterX: item.rotationCenterX,
rotationCenterY: item.rotationCenterY,
bitmapResolution: item.bitmapResolution,
skinId: null
};
this.props.vm.addCostumeFromLibrary(item.md5, vmCostume);
this.props.vm.addCostumeFromLibrary(item.md5ext, vmCostume);
}
render () {
return (
Expand Down
20 changes: 8 additions & 12 deletions src/containers/costume-tab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,12 @@ class CostumeTab extends React.Component {
}
handleSurpriseCostume () {
const item = costumeLibraryContent[Math.floor(Math.random() * costumeLibraryContent.length)];
const split = item.md5.split('.');
const type = split.length > 1 ? split[1] : null;
const rotationCenterX = type === 'svg' ? item.info[0] : item.info[0] / 2;
const rotationCenterY = type === 'svg' ? item.info[1] : item.info[1] / 2;
const vmCostume = {
name: item.name,
md5: item.md5,
rotationCenterX,
rotationCenterY,
bitmapResolution: item.info.length > 2 ? item.info[2] : 1,
md5: item.md5ext,
rotationCenterX: item.rotationCenterX,
rotationCenterY: item.rotationCenterY,
bitmapResolution: item.bitmapResolution,
skinId: null
};
this.handleNewCostume(vmCostume, true /* fromCostumeLibrary */);
Expand All @@ -194,10 +190,10 @@ class CostumeTab extends React.Component {
const item = backdropLibraryContent[Math.floor(Math.random() * backdropLibraryContent.length)];
const vmCostume = {
name: item.name,
md5: item.md5,
rotationCenterX: item.info[0] && item.info[0] / 2,
rotationCenterY: item.info[1] && item.info[1] / 2,
bitmapResolution: item.info.length > 2 ? item.info[2] : 1,
md5: item.md5ext,
rotationCenterX: item.rotationCenterX,
rotationCenterY: item.rotationCenterY,
bitmapResolution: item.bitmapResolution,
skinId: null
};
this.handleNewCostume(vmCostume);
Expand Down
4 changes: 2 additions & 2 deletions src/containers/sound-library.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ class SoundLibrary extends React.PureComponent {
// @todo need to use this hack to avoid library using md5 for image
const soundLibraryThumbnailData = soundLibraryContent.map(sound => {
const {
md5,
md5ext,
...otherData
} = sound;
return {
_md5: md5,
_md5: md5ext,
rawURL: this.props.isRtl ? soundIconRtl : soundIcon,
...otherData
};
Expand Down
4 changes: 2 additions & 2 deletions src/containers/sound-tab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class SoundTab extends React.Component {
handleSurpriseSound () {
const soundItem = soundLibraryContent[Math.floor(Math.random() * soundLibraryContent.length)];
const vmSound = {
format: soundItem.format,
md5: soundItem.md5,
format: soundItem.dataFormat,
md5: soundItem.md5ext,
rate: soundItem.rate,
sampleCount: soundItem.sampleCount,
name: soundItem.name
Expand Down
2 changes: 1 addition & 1 deletion src/containers/sprite-library.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SpriteLibrary extends React.PureComponent {
handleItemSelect (item) {
// Randomize position of library sprite
randomizeSpritePosition(item);
this.props.vm.addSprite(JSON.stringify(item.json)).then(() => {
this.props.vm.addSprite(JSON.stringify(item)).then(() => {
this.props.onActivateBlocksTab();
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/containers/stage-selector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ class StageSelector extends React.Component {
addBackdropFromLibraryItem (item, shouldActivateTab = true) {
const vmBackdrop = {
name: item.name,
md5: item.md5,
rotationCenterX: item.info[0] && item.info[0] / 2,
rotationCenterY: item.info[1] && item.info[1] / 2,
bitmapResolution: item.info.length > 2 ? item.info[2] : 1,
md5: item.md5ext,
rotationCenterX: item.rotationCenterX,
rotationCenterY: item.rotationCenterY,
bitmapResolution: item.bitmapResolution,
skinId: null
};
this.handleNewBackdrop(vmBackdrop, shouldActivateTab);
Expand Down
2 changes: 1 addition & 1 deletion src/containers/target-pane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class TargetPane extends React.Component {
);
const item = surpriseSprites[Math.floor(Math.random() * surpriseSprites.length)];
randomizeSpritePosition(item);
this.props.vm.addSprite(JSON.stringify(item.json))
this.props.vm.addSprite(JSON.stringify(item))
.then(this.handleActivateBlocksTab);
}
handlePaintSpriteClick () {
Expand Down
Loading