Skip to content

Conversation

@cwillisf
Copy link
Contributor

@cwillisf cwillisf commented Apr 2, 2020

Resolves

Resolves a problem specific to the scratch-desktop branch in which the library icons for sprites would not correctly animate even in the presence of multiple costumes.

Proposed Changes

Two changes:

  • if a library item (or sub-item) contains both assetId and dataFormat properties, use those to determine the icon. Prefer that over options which require splitting on .
  • if a library item (or sub-item) has a property called md5ext use that (higher priority than existing code which used md5 or baseLayerMD5).

Reason for Changes

An animated library item may now have assetId and dataFormat properties. The new library generation code provides these properties and they align better to the way scratch-storage works.

Also, a library item may now contain a property called md5ext, which is just a renamed version of the old md5 property. We are trying to encourage md5ext rather than just md5 to describe a property or variable which contains both the MD5 hash and the file extension, just so that the code is more self-documenting.

Test Coverage

Tested by hand:

  1. Open Scratch Desktop
  2. Click "Choose a Sprite"
  3. Hover over "Bear-walking"

Expected: the "Bear-walking" library item shows the bear's walking animation.

Also tested:

  • Loading a sprite, costume, or sound still works as intended.
  • Playing sounds in the sound library works as intended.

@ericrosenbaum
Copy link
Contributor

Looks like travis failed due to props validation:

/home/travis/build/LLK/scratch-gui/src/components/scratch-image/scratch-image.jsx
  97:13  error  'src' is missing in props validation  react/prop-types

@ericrosenbaum
Copy link
Contributor

also @cwillisf I'm curious how this will interact with the possible-future-changes (still in review) in #5460, which changes the shape of the sprite library data

`getItemIcons` (formerly `getItemImageSource`) now handles the current
library formats as well as upcoming library changes in which library
items will no longer have a `json` property. Or, at least, it should
work...

As part of that effort, `getItemIcons` now handles library items with
single or multiple icons internally, meaning that the caller no longer
needs to do extra work to check. Likewise, the `LibraryItem` container
now has just one `iconSource` property instead of an `icon` property for
the one-icon case and an `icons` property for the multi-icon case. The
LibraryItem component (not container) still only takes one icon, and the
container is still responsible for managing icon rotation.
@cwillisf
Copy link
Contributor Author

OK, I think these changes preemptively resolve any trouble that might come from #5460, though it's possible I missed some detail. Also, these changes should make it easier to quickly fix anything broken by #5460 if I did miss anything. :D

Co-Authored-By: apple502j <33279053+apple502j@users.noreply.github.com>
Copy link
Contributor

@ericrosenbaum ericrosenbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! tested in playground but not desktop

Co-authored-by: adroitwhiz <adroitwhiz@protonmail.com>
@cwillisf cwillisf merged commit 8412cfc into scratchfoundation:scratch-desktop May 13, 2020
@cwillisf cwillisf deleted the fix-costume-animation branch May 13, 2020 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants