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

Add an @export annotation for InputMap actions #11202

Open
Sulfrix opened this issue Nov 21, 2024 · 1 comment
Open

Add an @export annotation for InputMap actions #11202

Sulfrix opened this issue Nov 21, 2024 · 1 comment

Comments

@Sulfrix
Copy link

Sulfrix commented Nov 21, 2024

Describe the project you are working on

Input glyph displays for a 2D game that show control hints on screen

Describe the problem or limitation you are having in your project

I have a resource that exports a StringName property corresponding to the action in the InputMap that should be displayed as a button glyph. This works fine, but I feel that it would help to have a way to select an action from a dropdown, reducing the chance of mistyping an action name, and reducing trips to the Input Map project settings in case one forgets the correct name. In addition, the built-in TouchScreenButton node also simply has a StringName property that should correspond to an action in the InputMap.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I think an @export_action annotation, similar to other annotations that use project context like @export_file, would provide a nice experience for specifying InputMap actions for nodes/resources that require one.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The inspector would display the property similar to @export_enum, allowing the user to pick from a list of actions defined in the project settings' InputMap.
Image
This would be used in GDScript as follows:

@export_action var hint_action: StringName = &"run"

This could also be applied to the TouchScreenButton node so that an action can be quickly selected.
If TouchScreenButton does use this action dropdown, there is possibility for a regression if a project uses dynamically created actions since the default inspector enum behavior does not allow the user to type in a value manually, so it should probably use PROPERTY_HINT_ENUM_SUGGESTION.

If this enhancement will not be used often, can it be worked around with a few lines of script?

As far as I'm aware, @export_enum nor @export_custom allow a dynamic list of options, like options taken from project settings, so they are not suitable for this. You could possibly implement this using get_property_list() but this seems rather inconvenient.

Is there a reason why this should be core and not an add-on in the asset library?

Currently GDScript does not support custom annotations (#1316) so an add-on could not implement it. In addition, this change could also improve the built-in node TouchScreenButton.

@Calinou Calinou changed the title Export annotation for InputMap actions Add an @export annotation for InputMap actions Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants