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

Provide a function to clear action state #108

Closed
Shatur opened this issue Apr 9, 2022 · 2 comments · Fixed by #112
Closed

Provide a function to clear action state #108

Shatur opened this issue Apr 9, 2022 · 2 comments · Fixed by #112
Labels
enhancement New feature or request
Milestone

Comments

@Shatur
Copy link
Collaborator

Shatur commented Apr 9, 2022

What problem does this solve?

In my game I have a chat and pause menu, both handled by separate systems. When I press UiAction::Back I would like to close the chat first and on second press I would like open the menu.
So in chat system I want to catch UiAction::Back if it was just pressed and the chat was open, to avoid it propagation to the in-game menu.

For this use case we currently have make_held function which unpressed the button. I can use it to avoid action propagation. But If I switch from just_pressed check to just_released - it won't work:

if ui_actions.just_released(UiAction::Chat) {
    ui_actions.make_held(UiAction::Chat);
    println!("{}", ui_actions.just_released(UiAction::Chat)); // Prints `true`
}

Because the function only unpressed the button, it doesn't clear just_*.

What solution would you like?

I would suggest to replace make_held with a new function called reset that fully clears the action state. So it becomes "unpressed" and "unjusted". I believe this is what user would expect and in want most cases.

@Shatur Shatur added the enhancement New feature or request label Apr 9, 2022
@alice-i-cecile alice-i-cecile added this to the 0.3 milestone Apr 9, 2022
@alice-i-cecile
Copy link
Contributor

Agreed: I think this is much clearer.

@Shatur
Copy link
Collaborator Author

Shatur commented Apr 12, 2022

Closed by #112.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants