X Tutup
Skip to content

ResourceImporterScene: Replace animation bool with an import type string enum#87787

Merged
akien-mga merged 1 commit intogodotengine:masterfrom
aaronfranke:scene-import-type
Aug 27, 2024
Merged

ResourceImporterScene: Replace animation bool with an import type string enum#87787
akien-mga merged 1 commit intogodotengine:masterfrom
aaronfranke:scene-import-type

Conversation

@aaronfranke
Copy link
Member

The current code for ResourceImporterScene has a boolean for importing an animation library, and if false, it imports as a scene. This is not ideal, a boolean does not make much sense because there are more than 2 conceivable possibilities, we don't want to hard-code "animation or scene". This PR replaces this bool with an enum.

In the future we can add more possibilities to this enum, like importing a mesh resource. This PR is part of godotengine/godot-proposals#7494 I am working on it in small pieces to avoid huge unreviewable PRs.

@aaronfranke aaronfranke added this to the 4.x milestone Jan 31, 2024
@aaronfranke aaronfranke requested a review from a team as a code owner January 31, 2024 13:42
@aaronfranke aaronfranke requested a review from a team January 31, 2024 13:42
@lyuma
Copy link
Contributor

lyuma commented Feb 9, 2024

The problem with enums is that they cannot be extended at all, not even by extensions.
I would rather we use a string so that users can define their own import subtypes.
For example, I could add some custom level format and define my own "Import as" -> "MyGameLevel"
I think changing to a String or StringName would be a relatively simple change.

However, if we really are planning to only support 3 cases: animation library, mesh library and scene, then this really belongs as part of the MeshLibrary change.

@aaronfranke
Copy link
Member Author

aaronfranke commented Feb 9, 2024

@lyuma My initial plan was for this only to be extendable from within ResourceImporterScene itself, in which case you can add to the enum. However a String or StringName would also work well, I can change it to that. I'm not totally sure about the requirements to allow this class to be extended outside of Godot but I'm all good with leaving the option open.

EDIT: Done, it uses Strings now.

@aaronfranke aaronfranke force-pushed the scene-import-type branch 4 times, most recently from f8b1dd6 to c0f88e7 Compare February 26, 2024 23:37
@aaronfranke aaronfranke changed the title ResourceImporterScene: Replace animation bool with an import mode enum ResourceImporterScene: Replace animation bool with an import type string enum Feb 26, 2024
@akien-mga akien-mga requested a review from lyuma June 26, 2024 11:46
@aaronfranke
Copy link
Member Author

@lyuma I made it use a String, and @fire requested that I request your review.

Copy link
Contributor

@lyuma lyuma left a comment

Choose a reason for hiding this comment

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

I realize this is only changing the internal api which means plugins don't get to use the new types, but we are going to rework the public apis in another change in the future.

it makes sense to start with this internal change as is.

@akien-mga akien-mga modified the milestones: 4.x, 4.4 Aug 27, 2024
@akien-mga akien-mga merged commit cf27829 into godotengine:master Aug 27, 2024
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup