Skip to content

Commit

Permalink
Merge pull request #36579 from code-dot-org/jk-new-background-block-s…
Browse files Browse the repository at this point in the history
…pritelab

Spritelab set background as block
  • Loading branch information
JillianK committed Nov 4, 2020
2 parents a71df14 + a278258 commit e3caa22
Show file tree
Hide file tree
Showing 9 changed files with 654 additions and 169 deletions.
1 change: 1 addition & 0 deletions apps/i18n/common/en_us.json
Expand Up @@ -75,6 +75,7 @@
"animationPicker_drawYourOwn": "Draw your own",
"animationPicker_error": "Error: {message}",
"animationPicker_failedToParseImage": "The image could not be parsed",
"animationPicker_noResultsFound": "Sorry, no results found.",
"animationPicker_title": "Animation Library",
"animationPicker_unsupportedType": "Sorry, this file type is not supported.",
"animationPicker_unsupportedSize": "Please make sure the image you are trying to upload is smaller than 100 KB.",
Expand Down
2 changes: 1 addition & 1 deletion apps/src/p5lab/AnimationPicker/AnimationPickerBody.jsx
Expand Up @@ -238,7 +238,7 @@ export default class AnimationPickerBody extends React.Component {
{(searchQuery !== '' || categoryQuery !== '') &&
results.length === 0 && (
<div style={animationPickerStyles.emptyResults}>
Sorry, no results found.
{msg.animationPicker_noResultsFound()}
</div>
)}
{((searchQuery === '' && categoryQuery === '') ||
Expand Down
3 changes: 3 additions & 0 deletions apps/src/p5lab/spritelab/commands.js
Expand Up @@ -242,6 +242,9 @@ export const commands = {
setBackgroundImage(img) {
worldCommands.setBackgroundImage.apply(this, [img]);
},
setBackgroundImageAs(img) {
worldCommands.setBackgroundImageAs.apply(this, [img]);
},
showTitleScreen(title, subtitle) {
worldCommands.showTitleScreen(title, subtitle);
},
Expand Down
11 changes: 11 additions & 0 deletions apps/src/p5lab/spritelab/commands/worldCommands.js
Expand Up @@ -29,13 +29,24 @@ export const commands = {
coreLibrary.background = color;
},

// Deprecated. The new background block is setBackgroundImageAs
setBackgroundImage(img) {
if (this._preloadedBackgrounds && this._preloadedBackgrounds[img]) {
let backgroundImage = this._preloadedBackgrounds[img];
coreLibrary.background = backgroundImage;
}
},

setBackgroundImageAs(img) {
if (
this._predefinedSpriteAnimations &&
this._predefinedSpriteAnimations[img]
) {
let backgroundImage = this._predefinedSpriteAnimations[img];
coreLibrary.background = backgroundImage;
}
},

setQuestion(questionText, variableName, setterCallback) {
coreLibrary.registerQuestion(questionText, variableName, setterCallback);
getStore().dispatch(addQuestion(questionText, variableName));
Expand Down

0 comments on commit e3caa22

Please sign in to comment.