Skip to content

Commit

Permalink
Improve input prompt overlay
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wjt committed Dec 12, 2024
1 parent 0562921 commit c7e57c6
Show file tree
Hide file tree
Showing 24 changed files with 624 additions and 18 deletions.
6 changes: 6 additions & 0 deletions assets/input-prompts/keyboard_a.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions assets/input-prompts/keyboard_a.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://c0jvv7knv0gkx"
path="res://.godot/imported/keyboard_a.svg-ed26b8a8bd86aba66c5f697af8b6e2c5.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/input-prompts/keyboard_a.svg"
dest_files=["res://.godot/imported/keyboard_a.svg-ed26b8a8bd86aba66c5f697af8b6e2c5.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
6 changes: 6 additions & 0 deletions assets/input-prompts/keyboard_arrow_down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions assets/input-prompts/keyboard_arrow_down.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ca07i6uub5tw6"
path="res://.godot/imported/keyboard_arrow_down.svg-18f0da674bcfed6ee0c2ffe6a8ef1ab1.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/input-prompts/keyboard_arrow_down.svg"
dest_files=["res://.godot/imported/keyboard_arrow_down.svg-18f0da674bcfed6ee0c2ffe6a8ef1ab1.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
6 changes: 6 additions & 0 deletions assets/input-prompts/keyboard_arrow_left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions assets/input-prompts/keyboard_arrow_left.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bwt5tfdwi6444"
path="res://.godot/imported/keyboard_arrow_left.svg-3e3bf82bab52783fc9467a38798d179c.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/input-prompts/keyboard_arrow_left.svg"
dest_files=["res://.godot/imported/keyboard_arrow_left.svg-3e3bf82bab52783fc9467a38798d179c.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
6 changes: 6 additions & 0 deletions assets/input-prompts/keyboard_arrow_right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions assets/input-prompts/keyboard_arrow_right.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ejrlpu5caxit"
path="res://.godot/imported/keyboard_arrow_right.svg-d78277bf14dbbaee96630dc8c8569d50.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/input-prompts/keyboard_arrow_right.svg"
dest_files=["res://.godot/imported/keyboard_arrow_right.svg-d78277bf14dbbaee96630dc8c8569d50.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
6 changes: 6 additions & 0 deletions assets/input-prompts/keyboard_arrow_up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions assets/input-prompts/keyboard_arrow_up.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bvblole4tllwp"
path="res://.godot/imported/keyboard_arrow_up.svg-563cab88f949a7c82cce1b16e72577b3.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/input-prompts/keyboard_arrow_up.svg"
dest_files=["res://.godot/imported/keyboard_arrow_up.svg-563cab88f949a7c82cce1b16e72577b3.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
6 changes: 6 additions & 0 deletions assets/input-prompts/keyboard_d.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions assets/input-prompts/keyboard_d.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://djskjyoqjltro"
path="res://.godot/imported/keyboard_d.svg-c7535420b56dd7b8f9f2f192d2f824cf.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/input-prompts/keyboard_d.svg"
dest_files=["res://.godot/imported/keyboard_d.svg-c7535420b56dd7b8f9f2f192d2f824cf.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
6 changes: 6 additions & 0 deletions assets/input-prompts/keyboard_s.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions assets/input-prompts/keyboard_s.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://crymwedc3lo5e"
path="res://.godot/imported/keyboard_s.svg-98912e340bd6dffd68fb5e94784b1038.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/input-prompts/keyboard_s.svg"
dest_files=["res://.godot/imported/keyboard_s.svg-98912e340bd6dffd68fb5e94784b1038.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
6 changes: 6 additions & 0 deletions assets/input-prompts/keyboard_w.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions assets/input-prompts/keyboard_w.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://brdwgpvrgx8dh"
path="res://.godot/imported/keyboard_w.svg-3ca18719d0f621248861c20aab4cc8d2.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/input-prompts/keyboard_w.svg"
dest_files=["res://.godot/imported/keyboard_w.svg-3ca18719d0f621248861c20aab4cc8d2.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
6 changes: 6 additions & 0 deletions assets/input-prompts/steamdeck_button_a.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c7e57c6

Please sign in to comment.