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

Improve input prompt overlay #19

Merged
merged 1 commit into from
Dec 13, 2024
Merged

Improve input prompt overlay #19

merged 1 commit into from
Dec 13, 2024

Conversation

wjt
Copy link
Member

@wjt wjt commented Dec 12, 2024

When the game first starts, an overlay is shown with instructions describing the controls. This was previously purely text-based.

Add assets for the controls from the Kenney Input Prompts pack https://kenney.nl/assets/input-prompts (CC-0): arrow keys, W A S D, and joypad buttons, for which I chose the Steam Deck assets which are reasonably generic.

Rework the HUD to lay out the controls in a grid. Pack the keyboard images and controller images into a TabContainer (with the tabs hidden) which can be used to switch between the two sets of controls. Monitor the Input.joy_connection_changed signal to switch between the two sets of images based on the corresponding controller being connecter or disconnected. This signal is emitted at the start of the game for each connected controller, so we can default to the keyboard tab in each case.

It might be nice to detect whether the touch controls are visible and hide the control overlay in that case. This can be done by checking DisplayServer.is_touchscreen_available(), which is what the touch buttons use too. But this isn't a regression: we previously showed keyboard controls even when touch controls were visible.

It might also be nice to only show the player two controls if there is a player two. But again this is not a regression.

Before

image

After

No controller connected
One controller connected
Two controller connected
Player one's controller has been removed

@wjt wjt force-pushed the improve-input-prompt-overlay branch from e08491c to c7e57c6 Compare December 12, 2024 19:14
@wjt wjt marked this pull request as ready for review December 12, 2024 19:14
When the game first starts, an overlay is shown with instructions
describing the controls. This was previously purely text-based.

Add assets for the controls from the Kenney Input Prompts pack
<https://kenney.nl/assets/input-prompts> (CC-0): arrow keys, W A S D,
and joypad buttons, for which I chose the Steam Deck assets which are
reasonably generic.

Rework the HUD to lay out the controls in a grid. Pack the keyboard
images and controller images into a TabContainer (with the tabs hidden)
which can be used to switch between the two sets of controls. Monitor
the Input.joy_connection_changed signal to switch between the two sets
of images based on the corresponding controller being connecter or
disconnected. This signal is emitted at the start of the game for each
connected controller, so we can default to the keyboard tab in each
case.

It might be nice to detect whether the touch controls are visible
and hide the control overlay in that case. This can be done by checking
DisplayServer.is_touchscreen_available(), which is what the touch
buttons use too. But this isn't a regression: we previously showed
keyboard controls even when touch controls were visible.

It might also be nice to only show the player two controls if there is
a player two. But again this is not a regression.
@wjt wjt force-pushed the improve-input-prompt-overlay branch from c7e57c6 to 46a1aed Compare December 12, 2024 19:18
@wjt wjt requested review from jbourqueendless and manuq December 12, 2024 19:19
Copy link
Contributor

@manuq manuq left a comment

Choose a reason for hiding this comment

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

Nice! Very interesting use of the UI tabs, I would have toggled the nodes visibility myself, but this is better.

@manuq manuq merged commit d902078 into main Dec 13, 2024
1 check passed
@manuq manuq deleted the improve-input-prompt-overlay branch December 13, 2024 12:50
Comment on lines +34 to +36
%PlayerOneJoypad.visible = connected
1:
%PlayerTwoJoypad.visible = connected
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually you ended up with the visibility toggle.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, setting the visible tab as invisible makes the other one visible.

I used to use GtkNotebook like this before GtkStack existed.

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

Successfully merging this pull request may close these issues.

2 participants