Skip to content

Add InputMap.is_builtin_action() #98482

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

timothyqiu
Copy link
Member

Closes godotengine/godot-proposals#11016

This PR:

  • Adds is_builtin_action() to check if a name is the name of a built-in action.
  • Makes erase_action() warn about removing a built-in action.
  • Makes default_builtin_cache and default_builtin_with_overrides_cache mutable since caches are expected to be modified in const methods.
  • Removes a redundant header include.

@timothyqiu timothyqiu added this to the 4.4 milestone Oct 24, 2024
@timothyqiu timothyqiu requested review from a team as code owners October 24, 2024 05:34
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally, it works as expected.

I suggest adding some unit tests to tests/test_input_event.h after line 98:

	CHECK(InputMap::get_singleton()->is_builtin_action("ui_accept"), true);
	CHECK(InputMap::get_singleton()->is_builtin_action("ui_text_submit"), true);
	CHECK(InputMap::get_singleton()->is_builtin_action("ui_this_is_not_builtin"), false);
	CHECK(InputMap::get_singleton()->is_builtin_action("move_forward"), false);
	CHECK(InputMap::get_singleton()->is_builtin_action(""), false);

@timothyqiu timothyqiu requested a review from a team as a code owner October 26, 2024 02:24
@timothyqiu
Copy link
Member Author

Tests added. CHECK expects one argument, so CHECK_EQ is used instead.

@InkONat
Copy link

InkONat commented Oct 28, 2024

I think is_engine_action is a better name for this method, since it matches up with other similar methods

@timothyqiu
Copy link
Member Author

I think is_engine_action is a better name for this method, since it matches up with other similar methods

EditorSettings have a set_builtin_action_override() to operate on ui_* actions.

Result searching for engine in exposed API1:

doc/classes/EditorSettings.xml
1040:		<member name="network/connection/engine_version_update_mode" type="int" setter="" getter="">
1397:		<member name="text_editor/theme/highlighting/engine_type_color" type="Color" setter="" getter="">

doc/classes/ProjectSettings.xml
2221:		<member name="physics/2d/physics_engine" type="String" setter="" getter="" default="&quot;DEFAULT&quot;">
2300:		<member name="physics/3d/physics_engine" type="String" setter="" getter="" default="&quot;DEFAULT&quot;">

doc/classes/VehicleBody3D.xml
18:		<member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force" default="0.0">

doc/classes/VehicleWheel3D.xml
62:		<member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force" default="0.0">

Footnotes

  1. rg '(name|setter|getter)="[^"]*engine' doc/classes/

@timothyqiu timothyqiu modified the milestones: 4.4, 4.x Nov 14, 2024
@InkONat

This comment was marked as off-topic.

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

Successfully merging this pull request may close these issues.

Add a is_engine_action method to differentiate between the default actions and custom actions
4 participants