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

YY Plugin: Determine sprite names by looking for meta files #3213

Merged
merged 1 commit into from
Dec 21, 2021

Conversation

krukai
Copy link
Contributor

@krukai krukai commented Dec 17, 2021

Before assuming the name of an image file without its extension to be the name of the associated sprite, search the current and up to two parent directories for a *.yy meta file. If found, use its name without the file extension instead.
A custom "sprite" property may still override this feature and will also prevent file system crawling.

This enables a user to use the sprite image files directly from their game project for image layers without having to specify the custom "sprite" property or using a copy with a proper name, as GameMaker Studio2 uses some UUID naming scheme for asset files.
The search is extended to parent directories as sprites resources also may contain subdirectories for individual layers. By the same token, a user may store different versions of an asset in the same folder. This is purely for added convenience so "it just works", even if a user merely wishes to have a Sprite be represented only by one of its layers.

src/plugins/yy/yyplugin.cpp Outdated Show resolved Hide resolved
src/plugins/yy/yyplugin.cpp Outdated Show resolved Hide resolved
@krukai
Copy link
Contributor Author

krukai commented Dec 20, 2021

I added some caching and took care of the other review comments as well.

However, the caching method will look up every empty string it receives as input. Before I add a check for that, I would rather hear your opinion on where it should be. It seems to me that placing it outside the method is the better approach as the method lacks the context to give the proper answer, even if it might always be an empty string at the moment.

Finally, passing the context along feels a bit awkward, but I guess it is line with how the plugin is currently structured.

Copy link
Member

@bjorn bjorn left a comment

Choose a reason for hiding this comment

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

However, the caching method will look up every empty string it receives as input. Before I add a check for that, I would rather hear your opinion on where it should be.

You've already added the check, right? I think it's fine where it is. But when does this actually happen?

Finally, passing the context along feels a bit awkward, but I guess it is in line with how the plugin is currently structured.

I can see it must be a bit awkward to add this parameter in so many places. Alternatively we could rename Context to RoomWriter for example and move all these static functions into that class.

src/plugins/yy/yyplugin.cpp Outdated Show resolved Hide resolved
src/plugins/yy/yyplugin.cpp Outdated Show resolved Hide resolved
@krukai
Copy link
Contributor Author

krukai commented Dec 21, 2021

Should be done now, minus additional testing perhaps.

Before assuming the name of an image file without its extension to be
the name of the associated sprite, search the current and up to two
parent directories for a *.yy meta file. If found, use its name
without the file extension instead.
A custom "sprite" property may still override this feature.
@bjorn bjorn merged commit 54f0004 into mapeditor:master Dec 21, 2021
@bjorn
Copy link
Member

bjorn commented Dec 21, 2021

It looks good to me, nice work! Let's see how it behaves in the wild. :-)

@krukai krukai deleted the yy-changes branch December 21, 2021 10:56
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.

None yet

2 participants