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

perform tilemap upgrade on xml instead of workspace #10368

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

riknoll
Copy link
Member

@riknoll riknoll commented Feb 4, 2025

fixes microsoft/pxt-arcade#6602
fixes microsoft/pxt-arcade#6635
fixes microsoft/pxt-arcade#6601

our old method of upgrading tilemaps doesn't seem to be working with the new blockly; when blockly sets the values of the created fields the field validation code is causing their values to be overwritten before we can perform our upgrades.

to bypass that issue, i converted the upgrade code to be performed directly on the blocks xml instead of the workspace.

also, since people might not be familiar with this ancient code, this is the upgrade logic that i put into place ages ago when we started having a concept of "assets" in projects. previously we stored the tileset in the variables of the blockly workspace and that's what the tileset field drew its options from. tilemap blocks also just inlined all of the tilemap data instead of compiling down to an asset reference

@riknoll riknoll requested a review from a team February 4, 2025 22:35
@abchatra
Copy link
Collaborator

abchatra commented Feb 4, 2025

Nice


const upgradedTileMapping: pxt.Map<pxt.Tile> = {};

for (const element of dom.children) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious if iterating over everything in the dom is the most efficient way to do this.. Would this or would filtering for elements with the variable tag and then iterating through those entries be faster?

Copy link
Member Author

Choose a reason for hiding this comment

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

i don't think it would make a huge difference either way. this is only looping over the top-level elements in the xml file so it should only be the variables and any top-level events like on-start

@riknoll riknoll merged commit 41f8784 into master Feb 6, 2025
6 checks passed
@riknoll riknoll deleted the dev/riknoll/legacy-tilemap-import branch February 6, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants