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

support copy/pasting assets between projects #10383

Merged
merged 4 commits into from
Feb 13, 2025

Conversation

riknoll
Copy link
Member

@riknoll riknoll commented Feb 12, 2025

fixes microsoft/pxt-arcade#6656

this changes the asset fields' serialization so that they also include any referenced assets when saving state. saveState/loadState aren't called on fields during XML serialization, but they are called during copy/paste so this handles that scenario nicely without changing the save format of our projects.

when loading the state of a saved asset, there are a few scenarios to consider:

  1. pasting the asset into a project that doesn't have an existing asset with that id
  2. pasting the asset into a project that does have an asset with that id, where the value of the existing asset matches that of the serialized asset
  3. pasting the asset into a project that does have an asset with that id where the value of the existing asset does not match that of the serialized asset

for scenario 1, we simply create a new asset in the destination project. for scenario 2, we don't do anything since the asset is already in project.

scenario 3 is the tricky one. first we check to see if there is another asset in the destination project with the same value. if so, paste that one instead. if there isn't, then we need to create a new asset with a different id to avoid the collision. luckily, we already have code to do this for tilemaps since we have supported copying/pasting from within the tilemap editor for a while now

@riknoll riknoll requested a review from a team February 12, 2025 18:28
@riknoll riknoll merged commit 7114176 into master Feb 13, 2025
6 checks passed
@riknoll riknoll deleted the dev/riknoll/copy-paste-assets branch February 13, 2025 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copying block with image pack graphic from skillmap to another project give unknown image
2 participants