From 46a1aede4c62fb9d0df8dc9d621d85112ef64cb1 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 12 Dec 2024 17:02:11 +0000 Subject: [PATCH] Improve input prompt overlay 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 (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. --- assets/input-prompts/keyboard_a.svg | 6 + assets/input-prompts/keyboard_a.svg.import | 37 +++++ assets/input-prompts/keyboard_arrow_down.svg | 6 + .../keyboard_arrow_down.svg.import | 37 +++++ assets/input-prompts/keyboard_arrow_left.svg | 6 + .../keyboard_arrow_left.svg.import | 37 +++++ assets/input-prompts/keyboard_arrow_right.svg | 6 + .../keyboard_arrow_right.svg.import | 37 +++++ assets/input-prompts/keyboard_arrow_up.svg | 6 + .../keyboard_arrow_up.svg.import | 37 +++++ assets/input-prompts/keyboard_d.svg | 6 + assets/input-prompts/keyboard_d.svg.import | 37 +++++ assets/input-prompts/keyboard_s.svg | 6 + assets/input-prompts/keyboard_s.svg.import | 37 +++++ assets/input-prompts/keyboard_w.svg | 6 + assets/input-prompts/keyboard_w.svg.import | 37 +++++ assets/input-prompts/steamdeck_button_a.svg | 6 + .../steamdeck_button_a.svg.import | 37 +++++ assets/input-prompts/steamdeck_dpad_left.svg | 7 + .../steamdeck_dpad_left.svg.import | 37 +++++ assets/input-prompts/steamdeck_dpad_right.svg | 7 + .../steamdeck_dpad_right.svg.import | 37 +++++ hud.tscn | 156 ++++++++++++++++-- scripts/hud.gd | 11 ++ 24 files changed, 624 insertions(+), 18 deletions(-) create mode 100644 assets/input-prompts/keyboard_a.svg create mode 100644 assets/input-prompts/keyboard_a.svg.import create mode 100644 assets/input-prompts/keyboard_arrow_down.svg create mode 100644 assets/input-prompts/keyboard_arrow_down.svg.import create mode 100644 assets/input-prompts/keyboard_arrow_left.svg create mode 100644 assets/input-prompts/keyboard_arrow_left.svg.import create mode 100644 assets/input-prompts/keyboard_arrow_right.svg create mode 100644 assets/input-prompts/keyboard_arrow_right.svg.import create mode 100644 assets/input-prompts/keyboard_arrow_up.svg create mode 100644 assets/input-prompts/keyboard_arrow_up.svg.import create mode 100644 assets/input-prompts/keyboard_d.svg create mode 100644 assets/input-prompts/keyboard_d.svg.import create mode 100644 assets/input-prompts/keyboard_s.svg create mode 100644 assets/input-prompts/keyboard_s.svg.import create mode 100644 assets/input-prompts/keyboard_w.svg create mode 100644 assets/input-prompts/keyboard_w.svg.import create mode 100644 assets/input-prompts/steamdeck_button_a.svg create mode 100644 assets/input-prompts/steamdeck_button_a.svg.import create mode 100644 assets/input-prompts/steamdeck_dpad_left.svg create mode 100644 assets/input-prompts/steamdeck_dpad_left.svg.import create mode 100644 assets/input-prompts/steamdeck_dpad_right.svg create mode 100644 assets/input-prompts/steamdeck_dpad_right.svg.import diff --git a/assets/input-prompts/keyboard_a.svg b/assets/input-prompts/keyboard_a.svg new file mode 100644 index 0000000..63294cd --- /dev/null +++ b/assets/input-prompts/keyboard_a.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/input-prompts/keyboard_a.svg.import b/assets/input-prompts/keyboard_a.svg.import new file mode 100644 index 0000000..559bea3 --- /dev/null +++ b/assets/input-prompts/keyboard_a.svg.import @@ -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 diff --git a/assets/input-prompts/keyboard_arrow_down.svg b/assets/input-prompts/keyboard_arrow_down.svg new file mode 100644 index 0000000..c38c9a1 --- /dev/null +++ b/assets/input-prompts/keyboard_arrow_down.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/input-prompts/keyboard_arrow_down.svg.import b/assets/input-prompts/keyboard_arrow_down.svg.import new file mode 100644 index 0000000..73a621f --- /dev/null +++ b/assets/input-prompts/keyboard_arrow_down.svg.import @@ -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 diff --git a/assets/input-prompts/keyboard_arrow_left.svg b/assets/input-prompts/keyboard_arrow_left.svg new file mode 100644 index 0000000..9eb6d53 --- /dev/null +++ b/assets/input-prompts/keyboard_arrow_left.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/input-prompts/keyboard_arrow_left.svg.import b/assets/input-prompts/keyboard_arrow_left.svg.import new file mode 100644 index 0000000..06215c0 --- /dev/null +++ b/assets/input-prompts/keyboard_arrow_left.svg.import @@ -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 diff --git a/assets/input-prompts/keyboard_arrow_right.svg b/assets/input-prompts/keyboard_arrow_right.svg new file mode 100644 index 0000000..a484a5a --- /dev/null +++ b/assets/input-prompts/keyboard_arrow_right.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/input-prompts/keyboard_arrow_right.svg.import b/assets/input-prompts/keyboard_arrow_right.svg.import new file mode 100644 index 0000000..e77ae52 --- /dev/null +++ b/assets/input-prompts/keyboard_arrow_right.svg.import @@ -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 diff --git a/assets/input-prompts/keyboard_arrow_up.svg b/assets/input-prompts/keyboard_arrow_up.svg new file mode 100644 index 0000000..45b637d --- /dev/null +++ b/assets/input-prompts/keyboard_arrow_up.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/input-prompts/keyboard_arrow_up.svg.import b/assets/input-prompts/keyboard_arrow_up.svg.import new file mode 100644 index 0000000..9af7986 --- /dev/null +++ b/assets/input-prompts/keyboard_arrow_up.svg.import @@ -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 diff --git a/assets/input-prompts/keyboard_d.svg b/assets/input-prompts/keyboard_d.svg new file mode 100644 index 0000000..6d17ffe --- /dev/null +++ b/assets/input-prompts/keyboard_d.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/input-prompts/keyboard_d.svg.import b/assets/input-prompts/keyboard_d.svg.import new file mode 100644 index 0000000..4282592 --- /dev/null +++ b/assets/input-prompts/keyboard_d.svg.import @@ -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 diff --git a/assets/input-prompts/keyboard_s.svg b/assets/input-prompts/keyboard_s.svg new file mode 100644 index 0000000..f95f325 --- /dev/null +++ b/assets/input-prompts/keyboard_s.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/input-prompts/keyboard_s.svg.import b/assets/input-prompts/keyboard_s.svg.import new file mode 100644 index 0000000..ecea3f5 --- /dev/null +++ b/assets/input-prompts/keyboard_s.svg.import @@ -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 diff --git a/assets/input-prompts/keyboard_w.svg b/assets/input-prompts/keyboard_w.svg new file mode 100644 index 0000000..b6ff369 --- /dev/null +++ b/assets/input-prompts/keyboard_w.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/input-prompts/keyboard_w.svg.import b/assets/input-prompts/keyboard_w.svg.import new file mode 100644 index 0000000..ed06e4c --- /dev/null +++ b/assets/input-prompts/keyboard_w.svg.import @@ -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 diff --git a/assets/input-prompts/steamdeck_button_a.svg b/assets/input-prompts/steamdeck_button_a.svg new file mode 100644 index 0000000..3f3a1b5 --- /dev/null +++ b/assets/input-prompts/steamdeck_button_a.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/input-prompts/steamdeck_button_a.svg.import b/assets/input-prompts/steamdeck_button_a.svg.import new file mode 100644 index 0000000..7c4e185 --- /dev/null +++ b/assets/input-prompts/steamdeck_button_a.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cunoxrlkbl8f1" +path="res://.godot/imported/steamdeck_button_a.svg-c65385c304922812ecb720ee10dbf5d5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/input-prompts/steamdeck_button_a.svg" +dest_files=["res://.godot/imported/steamdeck_button_a.svg-c65385c304922812ecb720ee10dbf5d5.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 diff --git a/assets/input-prompts/steamdeck_dpad_left.svg b/assets/input-prompts/steamdeck_dpad_left.svg new file mode 100644 index 0000000..a2c5b50 --- /dev/null +++ b/assets/input-prompts/steamdeck_dpad_left.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/input-prompts/steamdeck_dpad_left.svg.import b/assets/input-prompts/steamdeck_dpad_left.svg.import new file mode 100644 index 0000000..aaf0d6d --- /dev/null +++ b/assets/input-prompts/steamdeck_dpad_left.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cw862nhkb5yck" +path="res://.godot/imported/steamdeck_dpad_left.svg-e91d9695814991be8c05a9b7ff4a9c34.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/input-prompts/steamdeck_dpad_left.svg" +dest_files=["res://.godot/imported/steamdeck_dpad_left.svg-e91d9695814991be8c05a9b7ff4a9c34.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 diff --git a/assets/input-prompts/steamdeck_dpad_right.svg b/assets/input-prompts/steamdeck_dpad_right.svg new file mode 100644 index 0000000..3272da8 --- /dev/null +++ b/assets/input-prompts/steamdeck_dpad_right.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/input-prompts/steamdeck_dpad_right.svg.import b/assets/input-prompts/steamdeck_dpad_right.svg.import new file mode 100644 index 0000000..e8db543 --- /dev/null +++ b/assets/input-prompts/steamdeck_dpad_right.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://kthlw3efc7k1" +path="res://.godot/imported/steamdeck_dpad_right.svg-f87ef46d3bb29a7dddf3be25a7b4a2c7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/input-prompts/steamdeck_dpad_right.svg" +dest_files=["res://.godot/imported/steamdeck_dpad_right.svg-f87ef46d3bb29a7dddf3be25a7b4a2c7.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 diff --git a/hud.tscn b/hud.tscn index 07fb021..534a974 100644 --- a/hud.tscn +++ b/hud.tscn @@ -1,41 +1,161 @@ -[gd_scene load_steps=9 format=3 uid="uid://jt80gv02u4f2"] +[gd_scene load_steps=20 format=3 uid="uid://jt80gv02u4f2"] [ext_resource type="Script" path="res://scripts/hud.gd" id="1_8msyy"] +[ext_resource type="Texture2D" uid="uid://bwt5tfdwi6444" path="res://assets/input-prompts/keyboard_arrow_left.svg" id="2_btdwd"] [ext_resource type="Texture2D" uid="uid://d3um1i1lgu153" path="res://assets/heart.png" id="2_yyptq"] [ext_resource type="Texture2D" uid="uid://c6ic03u2yvnk6" path="res://assets/controls/flatLightLeft.png" id="3_cxgb6"] +[ext_resource type="Texture2D" uid="uid://bvblole4tllwp" path="res://assets/input-prompts/keyboard_arrow_up.svg" id="3_dm1pp"] +[ext_resource type="Texture2D" uid="uid://ejrlpu5caxit" path="res://assets/input-prompts/keyboard_arrow_right.svg" id="4_pk5l0"] [ext_resource type="Texture2D" uid="uid://svp2vgo37htu" path="res://assets/controls/flatDarkLeft.png" id="4_w2trk"] [ext_resource type="Texture2D" uid="uid://dsght3iwomray" path="res://assets/controls/flatLightRight.png" id="4_x1c4s"] +[ext_resource type="Texture2D" uid="uid://c0jvv7knv0gkx" path="res://assets/input-prompts/keyboard_a.svg" id="5_46xsx"] +[ext_resource type="Texture2D" uid="uid://cw862nhkb5yck" path="res://assets/input-prompts/steamdeck_dpad_left.svg" id="5_dwb6l"] [ext_resource type="Texture2D" uid="uid://crocudarwwiec" path="res://assets/controls/flatLightA.png" id="5_p3p2e"] +[ext_resource type="Texture2D" uid="uid://kthlw3efc7k1" path="res://assets/input-prompts/steamdeck_dpad_right.svg" id="6_gl61p"] +[ext_resource type="Texture2D" uid="uid://brdwgpvrgx8dh" path="res://assets/input-prompts/keyboard_w.svg" id="6_p4rii"] [ext_resource type="Texture2D" uid="uid://cwxk6km6rqwl3" path="res://assets/controls/flatDarkRight.png" id="6_u38dk"] +[ext_resource type="Texture2D" uid="uid://cunoxrlkbl8f1" path="res://assets/input-prompts/steamdeck_button_a.svg" id="7_cae44"] +[ext_resource type="Texture2D" uid="uid://djskjyoqjltro" path="res://assets/input-prompts/keyboard_d.svg" id="7_idqt6"] [ext_resource type="Texture2D" uid="uid://vujn5y4v732w" path="res://assets/controls/flatDarkA.png" id="8_me7no"] +[sub_resource type="Theme" id="Theme_0yvta"] +default_font_size = 64 + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_b8smf"] + [node name="HUD" type="CanvasLayer"] script = ExtResource("1_8msyy") -[node name="Start" type="Label" parent="."] +[node name="Start" type="VBoxContainer" parent="."] unique_name_in_owner = true -top_level = true -anchors_preset = 8 +anchors_preset = 5 anchor_left = 0.5 -anchor_top = 0.5 anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -367.5 -offset_top = -487.0 -offset_right = 367.5 -offset_bottom = 56.0 +offset_left = -331.5 +offset_right = 331.5 +offset_bottom = 420.0 grow_horizontal = 2 -grow_vertical = 2 -size_flags_horizontal = 4 -theme_override_font_sizes/font_size = 64 -text = "Controls -Player One: Arrow Keys -Player Two: WASD +theme = SubResource("Theme_0yvta") +theme_override_constants/separation = 32 -Press any key -to Start" +[node name="Label" type="Label" parent="Start"] +layout_mode = 2 +text = "Controls" horizontal_alignment = 1 +[node name="GridContainer" type="GridContainer" parent="Start"] +layout_mode = 2 +size_flags_horizontal = 4 +theme_override_constants/h_separation = 24 +columns = 2 + +[node name="PlayerOneCaption" type="Label" parent="Start/GridContainer"] +layout_mode = 2 +text = "Player One:" + +[node name="PlayerOne" type="TabContainer" parent="Start/GridContainer"] +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxEmpty_b8smf") +current_tab = 1 +tabs_visible = false + +[node name="PlayerOneJoypad" type="HBoxContainer" parent="Start/GridContainer/PlayerOne"] +unique_name_in_owner = true +visible = false +layout_mode = 2 +metadata/_tab_index = 0 + +[node name="Left" type="TextureRect" parent="Start/GridContainer/PlayerOne/PlayerOneJoypad"] +layout_mode = 2 +texture = ExtResource("5_dwb6l") +stretch_mode = 5 + +[node name="A" type="TextureRect" parent="Start/GridContainer/PlayerOne/PlayerOneJoypad"] +layout_mode = 2 +texture = ExtResource("7_cae44") +stretch_mode = 5 + +[node name="Right" type="TextureRect" parent="Start/GridContainer/PlayerOne/PlayerOneJoypad"] +layout_mode = 2 +texture = ExtResource("6_gl61p") +stretch_mode = 5 + +[node name="PlayerOneKeyboard" type="HBoxContainer" parent="Start/GridContainer/PlayerOne"] +unique_name_in_owner = true +layout_mode = 2 +metadata/_tab_index = 1 + +[node name="Left" type="TextureRect" parent="Start/GridContainer/PlayerOne/PlayerOneKeyboard"] +layout_mode = 2 +texture = ExtResource("2_btdwd") +stretch_mode = 5 + +[node name="Up" type="TextureRect" parent="Start/GridContainer/PlayerOne/PlayerOneKeyboard"] +layout_mode = 2 +texture = ExtResource("3_dm1pp") +stretch_mode = 5 + +[node name="Right" type="TextureRect" parent="Start/GridContainer/PlayerOne/PlayerOneKeyboard"] +layout_mode = 2 +texture = ExtResource("4_pk5l0") +stretch_mode = 5 + +[node name="PlayerTwoCaption" type="Label" parent="Start/GridContainer"] +layout_mode = 2 +text = "Player Two:" + +[node name="PlayerTwo" type="TabContainer" parent="Start/GridContainer"] +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxEmpty_b8smf") +current_tab = 1 +tabs_visible = false + +[node name="PlayerTwoJoypad" type="HBoxContainer" parent="Start/GridContainer/PlayerTwo"] +unique_name_in_owner = true +visible = false +layout_mode = 2 +metadata/_tab_index = 0 + +[node name="Left" type="TextureRect" parent="Start/GridContainer/PlayerTwo/PlayerTwoJoypad"] +layout_mode = 2 +texture = ExtResource("5_dwb6l") +stretch_mode = 5 + +[node name="A" type="TextureRect" parent="Start/GridContainer/PlayerTwo/PlayerTwoJoypad"] +layout_mode = 2 +texture = ExtResource("7_cae44") +stretch_mode = 5 + +[node name="Right" type="TextureRect" parent="Start/GridContainer/PlayerTwo/PlayerTwoJoypad"] +layout_mode = 2 +texture = ExtResource("6_gl61p") +stretch_mode = 5 + +[node name="PlayerTwoKeyboard" type="HBoxContainer" parent="Start/GridContainer/PlayerTwo"] +unique_name_in_owner = true +layout_mode = 2 +metadata/_tab_index = 1 + +[node name="Left" type="TextureRect" parent="Start/GridContainer/PlayerTwo/PlayerTwoKeyboard"] +layout_mode = 2 +texture = ExtResource("5_46xsx") +stretch_mode = 5 + +[node name="Up" type="TextureRect" parent="Start/GridContainer/PlayerTwo/PlayerTwoKeyboard"] +layout_mode = 2 +texture = ExtResource("6_p4rii") +stretch_mode = 5 + +[node name="Right" type="TextureRect" parent="Start/GridContainer/PlayerTwo/PlayerTwoKeyboard"] +layout_mode = 2 +texture = ExtResource("7_idqt6") +stretch_mode = 5 + +[node name="Label2" type="Label" parent="Start"] +layout_mode = 2 +size_flags_horizontal = 4 +text = "Press any key to start" + [node name="WinEnding" type="Label" parent="."] unique_name_in_owner = true visible = false diff --git a/scripts/hud.gd b/scripts/hud.gd index e004ffa..d253cb3 100644 --- a/scripts/hud.gd +++ b/scripts/hud.gd @@ -24,6 +24,17 @@ func _ready(): Global.game_ended.connect(_on_game_ended) Global.timer_added.connect(_on_timer_added) + Input.joy_connection_changed.connect(_on_joy_connection_changed) + # TODO: hide entirely if touch controls are visible? + + +func _on_joy_connection_changed(index: int, connected: bool): + match index: + 0: + %PlayerOneJoypad.visible = connected + 1: + %PlayerTwoJoypad.visible = connected + func _unhandled_input(event): if (