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

Stop user from being able to bind multiple identical events to the same action #91278

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

Conversation

toadkarter
Copy link

Fixes #91243

In ActionMapEditor, when we return from InputEventConfigurationDialog, and we have confirmed that this input relates to a new event being added, we loop through the events currently bound and early out if the new event matches any of the ones that have already been added.

@@ -58,7 +58,15 @@ void ActionMapEditor::_event_config_confirmed() {
Array events = new_action["events"].duplicate();

if (current_action_event_index == -1) {
// Add new event
// Add new event if not already bound
for (const Variant& event : events)
Copy link
Contributor

@RedMser RedMser Apr 28, 2024

Choose a reason for hiding this comment

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

You should run clang format / the pre-commit hook on your code, this would fail the CI pipeline.

  • Opening brace of for-loop and if-block must be on same line.
  • Newly added comments should end with a period.

When updating your PR, make sure to amend and force-push so that you end up with one commit.

Copy link
Author

@toadkarter toadkarter left a comment

Choose a reason for hiding this comment

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

Thanks for letting me know - I ran clang-format on my changes and amended the PR accordingly, will make sure to do so going forward!

Comment on lines 62 to 63
for (const Variant &event : events) {
Ref<InputEvent> event_to_check = Ref<InputEvent>(event);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for (const Variant &event : events) {
Ref<InputEvent> event_to_check = Ref<InputEvent>(event);
for (Ref<InputEvent> event_to_check : events) {

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, agreed that this is a bit more succinct. Also made the reference const just because we're not mutating these events while iterating over them.

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.

It is possible to add the same event several times to the same input action
4 participants