From 8dcda6711960aed5abe6c6ae58c35de69d8275bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= Date: Fri, 16 Oct 2026 15:20:56 -0300 Subject: [PATCH] Touch: Add Back button to Credits, Storybook and Pause screens These scenes have local input hints (unlike in the global HUD). Hide them when the device has a touchscreen. Also add a TouchBackButton, which will be visible in touchscreens only. Fix https://github.com/endlessm/threadbare/issues/3025 --- .../user_interface/back-touch-button.png | 3 ++ .../back-touch-button.png.import | 40 +++++++++++++++++++ .../back-touch-button_pressed.png | 3 ++ .../back-touch-button_pressed.png.import | 40 +++++++++++++++++++ scenes/globals/pause/pause_overlay.gd | 6 +++ scenes/globals/pause/pause_overlay.tscn | 26 +++++++----- .../menus/storybook/components/storybook.gd | 7 ++++ scenes/menus/storybook/storybook.tscn | 26 +++++++----- scenes/menus/title/components/credits.gd | 5 +++ scenes/menus/title/components/credits.tscn | 18 +++++---- .../components/touch_back_button.gd | 18 +++++++++ .../components/touch_back_button.gd.uid | 1 + .../touch_controls/touch_back_button.tscn | 29 ++++++++++++++ 13 files changed, 195 insertions(+), 27 deletions(-) create mode 100644 assets/first_party/user_interface/back-touch-button.png create mode 100644 assets/first_party/user_interface/back-touch-button.png.import create mode 100644 assets/first_party/user_interface/back-touch-button_pressed.png create mode 100644 assets/first_party/user_interface/back-touch-button_pressed.png.import create mode 100644 scenes/ui_elements/touch_controls/components/touch_back_button.gd create mode 100644 scenes/ui_elements/touch_controls/components/touch_back_button.gd.uid create mode 100644 scenes/ui_elements/touch_controls/touch_back_button.tscn diff --git a/assets/first_party/user_interface/back-touch-button.png b/assets/first_party/user_interface/back-touch-button.png new file mode 100644 index 0000000000..83a604e7ef --- /dev/null +++ b/assets/first_party/user_interface/back-touch-button.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b809a9eb08cc747b5b55582a4818ebbf369eba75f3f160f063f18ba87d31c848 +size 1945 diff --git a/assets/first_party/user_interface/back-touch-button.png.import b/assets/first_party/user_interface/back-touch-button.png.import new file mode 100644 index 0000000000..90046019ca --- /dev/null +++ b/assets/first_party/user_interface/back-touch-button.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://8yhl38p13lka" +path="res://.godot/imported/back-touch-button.png-1248bb5d5d61f90515d9c6fc55fb27c9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/first_party/user_interface/back-touch-button.png" +dest_files=["res://.godot/imported/back-touch-button.png-1248bb5d5d61f90515d9c6fc55fb27c9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 diff --git a/assets/first_party/user_interface/back-touch-button_pressed.png b/assets/first_party/user_interface/back-touch-button_pressed.png new file mode 100644 index 0000000000..ae449175a8 --- /dev/null +++ b/assets/first_party/user_interface/back-touch-button_pressed.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04aa09e6f188d82af286847aab69d28efa3eb0207dba23bebab1a761f06d09fd +size 1966 diff --git a/assets/first_party/user_interface/back-touch-button_pressed.png.import b/assets/first_party/user_interface/back-touch-button_pressed.png.import new file mode 100644 index 0000000000..c827363cad --- /dev/null +++ b/assets/first_party/user_interface/back-touch-button_pressed.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c4b4gth4ivudd" +path="res://.godot/imported/back-touch-button_pressed.png-8b9d2e5d41044e7fe870178484d91142.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/first_party/user_interface/back-touch-button_pressed.png" +dest_files=["res://.godot/imported/back-touch-button_pressed.png-8b9d2e5d41044e7fe870178484d91142.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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 diff --git a/scenes/globals/pause/pause_overlay.gd b/scenes/globals/pause/pause_overlay.gd index ac67f74dbc..c26416df35 100644 --- a/scenes/globals/pause/pause_overlay.gd +++ b/scenes/globals/pause/pause_overlay.gd @@ -15,12 +15,18 @@ var home_scene: String @onready var options: Control = %Options @onready var abandon_quest_button: Button = %AbandonQuestButton @onready var skip_tutorial_button: Button = %SkipTutorialButton +@onready var hints_container: Control = %HintsContainer func _ready() -> void: home_scene = ThreadbareProjectSettings.get_setting(ThreadbareProjectSettings.HOME_SCENE) visible = false + # On touchscreens, the tabs can be tapped instead, and there is a touch + # button to go back. + if DisplayServer.is_touchscreen_available(): + hints_container.hide() + func _unhandled_input(event: InputEvent) -> void: if event.is_action_pressed(&"pause"): diff --git a/scenes/globals/pause/pause_overlay.tscn b/scenes/globals/pause/pause_overlay.tscn index 76ee149f4f..b0763c136c 100644 --- a/scenes/globals/pause/pause_overlay.tscn +++ b/scenes/globals/pause/pause_overlay.tscn @@ -12,6 +12,7 @@ [ext_resource type="Texture2D" uid="uid://xe25gqovxxpe" path="res://assets/first_party/icons/left_arrow.png" id="8_ywskk"] [ext_resource type="Script" uid="uid://cbj0406q05dly" path="res://scenes/game_elements/props/hint/input_key/interact_input.gd" id="9_fh64e"] [ext_resource type="Texture2D" uid="uid://dgfsrkr8a370h" path="res://assets/third_party/kenney_input_prompts/steam-deck_sheet_default.png" id="10_fh64e"] +[ext_resource type="PackedScene" uid="uid://hs4x784e2st8" path="res://scenes/ui_elements/touch_controls/touch_back_button.tscn" id="13_n2h80"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1tcw0"] @@ -131,10 +132,14 @@ theme_override_constants/margin_right = 8 custom_minimum_size = Vector2(200, 0) layout_mode = 2 -[node name="PauseContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer" unique_id=300043409] +[node name="HintsContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer" unique_id=1399339993] +unique_name_in_owner = true +layout_mode = 2 + +[node name="PauseContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/HintsContainer" unique_id=300043409] layout_mode = 2 -[node name="PauseHint" type="TextureRect" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/PauseContainer" unique_id=1079672650] +[node name="PauseHint" type="TextureRect" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/HintsContainer/PauseContainer" unique_id=1079672650] material = ExtResource("7_bwxj8") layout_mode = 2 size_flags_horizontal = 8 @@ -143,16 +148,16 @@ texture = SubResource("AtlasTexture_ywskk") script = ExtResource("9_fh64e") action_name = &"pause" -[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/PauseContainer" unique_id=762214617] +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/HintsContainer/PauseContainer" unique_id=762214617] layout_mode = 2 theme_type_variation = &"HintLabel" theme_override_font_sizes/font_size = 25 text = "Resume" -[node name="PreviousTabContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer" unique_id=165681227] +[node name="PreviousTabContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/HintsContainer" unique_id=165681227] layout_mode = 2 -[node name="PreviousTabHint" type="TextureRect" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/PreviousTabContainer" unique_id=1994017251] +[node name="PreviousTabHint" type="TextureRect" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/HintsContainer/PreviousTabContainer" unique_id=1994017251] material = ExtResource("7_bwxj8") layout_mode = 2 size_flags_horizontal = 8 @@ -161,16 +166,16 @@ texture = SubResource("AtlasTexture_fh64e") script = ExtResource("9_fh64e") action_name = &"previous_tab" -[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/PreviousTabContainer" unique_id=703188421] +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/HintsContainer/PreviousTabContainer" unique_id=703188421] layout_mode = 2 theme_type_variation = &"HintLabel" theme_override_font_sizes/font_size = 25 text = "Previous" -[node name="NextTabContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer" unique_id=2863309] +[node name="NextTabContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/HintsContainer" unique_id=2863309] layout_mode = 2 -[node name="NextTabHint" type="TextureRect" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/NextTabContainer" unique_id=1788019381] +[node name="NextTabHint" type="TextureRect" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/HintsContainer/NextTabContainer" unique_id=1788019381] material = ExtResource("7_bwxj8") layout_mode = 2 size_flags_horizontal = 8 @@ -179,7 +184,7 @@ texture = SubResource("AtlasTexture_mn3wt") script = ExtResource("9_fh64e") action_name = &"next_tab" -[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/NextTabContainer" unique_id=1814948712] +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/HintsContainer/NextTabContainer" unique_id=1814948712] layout_mode = 2 theme_type_variation = &"HintLabel" theme_override_font_sizes/font_size = 25 @@ -197,6 +202,9 @@ theme_override_colors/font_color = Color(1, 1, 1, 1) text = "0123456789" script = ExtResource("3_m62bn") +[node name="TouchBackButton" parent="." unique_id=1130237194 instance=ExtResource("13_n2h80")] +action = &"pause" + [connection signal="back" from="MarginContainer/VBoxContainer/TabContainer/Inventory" to="." method="_on_inventory_back"] [connection signal="back" from="MarginContainer/VBoxContainer/TabContainer/Options" to="." method="_on_options_back"] [connection signal="visibility_changed" from="MarginContainer/VBoxContainer/TabContainer/Menu" to="." method="_on_menu_visibility_changed"] diff --git a/scenes/menus/storybook/components/storybook.gd b/scenes/menus/storybook/components/storybook.gd index 5c45782eab..92e903dfb6 100644 --- a/scenes/menus/storybook/components/storybook.gd +++ b/scenes/menus/storybook/components/storybook.gd @@ -40,6 +40,8 @@ var _show_language_bookmarks: bool @onready var en_bookmark_button: Button = %ENBookmark @onready var es_bookmark_button: Button = %ESBookmark +@onready var hints_container: Control = %HintsContainer + func _fade_out_ui() -> void: var tween := create_tween() @@ -55,6 +57,11 @@ func _fade_in_ui() -> void: func _ready() -> void: + # On touchscreens, the bookmarks can be tapped instead, and there is a + # touch button to go back. + if DisplayServer.is_touchscreen_available(): + hints_container.hide() + animated_book.animation_finished.connect(_on_animation_finished) _quests_per_language = {} diff --git a/scenes/menus/storybook/storybook.tscn b/scenes/menus/storybook/storybook.tscn index 7c5ee77cee..515881528d 100644 --- a/scenes/menus/storybook/storybook.tscn +++ b/scenes/menus/storybook/storybook.tscn @@ -8,6 +8,7 @@ [ext_resource type="Material" uid="uid://cruf3tlajs4jo" path="res://scenes/ui_elements/input_hints/components/drop_shadow_material.tres" id="9_xkl6m"] [ext_resource type="Texture2D" uid="uid://dgfsrkr8a370h" path="res://assets/third_party/kenney_input_prompts/steam-deck_sheet_default.png" id="10_p0vqm"] [ext_resource type="Script" uid="uid://cbj0406q05dly" path="res://scenes/game_elements/props/hint/input_key/interact_input.gd" id="11_nkrro"] +[ext_resource type="PackedScene" uid="uid://hs4x784e2st8" path="res://scenes/ui_elements/touch_controls/touch_back_button.tscn" id="9_p0elk"] [sub_resource type="AtlasTexture" id="AtlasTexture_mwfoq"] atlas = ExtResource("10_p0vqm") @@ -138,14 +139,15 @@ theme_override_constants/margin_left = -5 layout_mode = 2 theme_override_constants/margin_right = 8 -[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer" unique_id=59792364] +[node name="HintsContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer" unique_id=59792364] +unique_name_in_owner = true custom_minimum_size = Vector2(200, 0) layout_mode = 2 -[node name="BackContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer/HBoxContainer" unique_id=1752840391] +[node name="BackContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer/HintsContainer" unique_id=1752840391] layout_mode = 2 -[node name="BackHint" type="TextureRect" parent="VBoxContainer/MarginContainer/HBoxContainer/BackContainer" unique_id=1694299884] +[node name="BackHint" type="TextureRect" parent="VBoxContainer/MarginContainer/HintsContainer/BackContainer" unique_id=1694299884] material = ExtResource("9_xkl6m") layout_mode = 2 size_flags_horizontal = 8 @@ -154,16 +156,16 @@ texture = SubResource("AtlasTexture_mwfoq") script = ExtResource("11_nkrro") action_name = &"ui_cancel" -[node name="Label" type="Label" parent="VBoxContainer/MarginContainer/HBoxContainer/BackContainer" unique_id=1130735496] +[node name="Label" type="Label" parent="VBoxContainer/MarginContainer/HintsContainer/BackContainer" unique_id=1130735496] layout_mode = 2 theme_type_variation = &"HintLabel" theme_override_font_sizes/font_size = 25 text = "Back" -[node name="PreviousTabContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer/HBoxContainer" unique_id=2058995622] +[node name="PreviousTabContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer/HintsContainer" unique_id=2058995622] layout_mode = 2 -[node name="PreviousTabHint" type="TextureRect" parent="VBoxContainer/MarginContainer/HBoxContainer/PreviousTabContainer" unique_id=1517575812] +[node name="PreviousTabHint" type="TextureRect" parent="VBoxContainer/MarginContainer/HintsContainer/PreviousTabContainer" unique_id=1517575812] material = ExtResource("9_xkl6m") layout_mode = 2 size_flags_horizontal = 8 @@ -172,16 +174,16 @@ texture = SubResource("AtlasTexture_f7prj") script = ExtResource("11_nkrro") action_name = &"previous_tab" -[node name="Label" type="Label" parent="VBoxContainer/MarginContainer/HBoxContainer/PreviousTabContainer" unique_id=421872458] +[node name="Label" type="Label" parent="VBoxContainer/MarginContainer/HintsContainer/PreviousTabContainer" unique_id=421872458] layout_mode = 2 theme_type_variation = &"HintLabel" theme_override_font_sizes/font_size = 25 text = "Previous" -[node name="NextTabContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer/HBoxContainer" unique_id=1727455504] +[node name="NextTabContainer" type="HBoxContainer" parent="VBoxContainer/MarginContainer/HintsContainer" unique_id=1727455504] layout_mode = 2 -[node name="NextTabHint" type="TextureRect" parent="VBoxContainer/MarginContainer/HBoxContainer/NextTabContainer" unique_id=859735797] +[node name="NextTabHint" type="TextureRect" parent="VBoxContainer/MarginContainer/HintsContainer/NextTabContainer" unique_id=859735797] material = ExtResource("9_xkl6m") layout_mode = 2 size_flags_horizontal = 8 @@ -190,13 +192,13 @@ texture = SubResource("AtlasTexture_m2ghf") script = ExtResource("11_nkrro") action_name = &"next_tab" -[node name="Label" type="Label" parent="VBoxContainer/MarginContainer/HBoxContainer/NextTabContainer" unique_id=1060314095] +[node name="Label" type="Label" parent="VBoxContainer/MarginContainer/HintsContainer/NextTabContainer" unique_id=1060314095] layout_mode = 2 theme_type_variation = &"HintLabel" theme_override_font_sizes/font_size = 25 text = "Next" -[node name="Spacer" type="Control" parent="VBoxContainer/MarginContainer/HBoxContainer" unique_id=1841759060] +[node name="Spacer" type="Control" parent="VBoxContainer/MarginContainer/HintsContainer" unique_id=1841759060] editor_description = "This empty control expands to fill the center of the hbox, pushing any controls packed after it to the right margin." layout_mode = 2 size_flags_horizontal = 3 @@ -222,4 +224,6 @@ unique_name_in_owner = true layout_mode = 2 text = "ES" +[node name="TouchBackButton" parent="." unique_id=676859704 instance=ExtResource("9_p0elk")] + [connection signal="selected" from="VBoxContainer/CenterContainer/StoryBookContent/StorybookPage" to="." method="_on_storybook_page_selected"] diff --git a/scenes/menus/title/components/credits.gd b/scenes/menus/title/components/credits.gd index 0fa3935f23..f553083278 100644 --- a/scenes/menus/title/components/credits.gd +++ b/scenes/menus/title/components/credits.gd @@ -20,9 +20,14 @@ var _current_scroll_pos: float = 0.0 @onready var background_anim_player: AnimationPlayer = %AnimationPlayer @onready var scroll_container: ScrollContainer = %ScrollContainer @onready var scroll_content: VBoxContainer = %ScrollContent +@onready var hints_container: Control = %HintsContainer func _ready() -> void: + # On touchscreens, there is a touch button to go back. + if DisplayServer.is_touchscreen_available(): + hints_container.hide() + if not visibility_changed.is_connected(_on_visibility_changed): visibility_changed.connect(_on_visibility_changed) diff --git a/scenes/menus/title/components/credits.tscn b/scenes/menus/title/components/credits.tscn index 5b225015fa..0dcbd4b86f 100644 --- a/scenes/menus/title/components/credits.tscn +++ b/scenes/menus/title/components/credits.tscn @@ -15,6 +15,7 @@ [ext_resource type="Texture2D" uid="uid://dgfsrkr8a370h" path="res://assets/third_party/kenney_input_prompts/steam-deck_sheet_default.png" id="14_jslai"] [ext_resource type="Script" uid="uid://cbj0406q05dly" path="res://scenes/game_elements/props/hint/input_key/interact_input.gd" id="15_jqrcw"] [ext_resource type="Script" uid="uid://bcx7jadxu27en" path="res://scenes/game_elements/props/hint/input_key/directional_input_hint.gd" id="20_5ojsv"] +[ext_resource type="PackedScene" uid="uid://hs4x784e2st8" path="res://scenes/ui_elements/touch_controls/touch_back_button.tscn" id="16_bxkgu"] [sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_3srqy"] @@ -450,7 +451,8 @@ layout_mode = 2 theme_override_constants/separation = 175 theme_override_styles/separator = SubResource("StyleBoxEmpty_rcvat") -[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=437285397] +[node name="HintsContainer" type="HBoxContainer" parent="." unique_id=437285397] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 2 anchor_top = 1.0 @@ -459,10 +461,10 @@ offset_top = -64.0 offset_right = 104.0 grow_vertical = 0 -[node name="BackContainer" type="HBoxContainer" parent="HBoxContainer" unique_id=1686403549] +[node name="BackContainer" type="HBoxContainer" parent="HintsContainer" unique_id=1686403549] layout_mode = 2 -[node name="BackHint" type="TextureRect" parent="HBoxContainer/BackContainer" unique_id=141326489] +[node name="BackHint" type="TextureRect" parent="HintsContainer/BackContainer" unique_id=141326489] material = ExtResource("13_lqn5t") layout_mode = 2 size_flags_vertical = 4 @@ -470,22 +472,22 @@ texture = SubResource("AtlasTexture_v7bap") script = ExtResource("15_jqrcw") action_name = &"ui_cancel" -[node name="Label" type="Label" parent="HBoxContainer/BackContainer" unique_id=1149974646] +[node name="Label" type="Label" parent="HintsContainer/BackContainer" unique_id=1149974646] layout_mode = 2 theme_type_variation = &"HintLabel" text = "Back" -[node name="ScrollContainer" type="HBoxContainer" parent="HBoxContainer" unique_id=1677351625] +[node name="ScrollContainer" type="HBoxContainer" parent="HintsContainer" unique_id=1677351625] layout_mode = 2 -[node name="DirectionalInputHint" type="TextureRect" parent="HBoxContainer/ScrollContainer" unique_id=1178532151] +[node name="DirectionalInputHint" type="TextureRect" parent="HintsContainer/ScrollContainer" unique_id=1178532151] material = ExtResource("13_lqn5t") layout_mode = 2 size_flags_vertical = 4 texture = SubResource("AtlasTexture_mhuej") script = ExtResource("20_5ojsv") -[node name="Label" type="Label" parent="HBoxContainer/ScrollContainer" unique_id=442669212] +[node name="Label" type="Label" parent="HintsContainer/ScrollContainer" unique_id=442669212] layout_mode = 2 theme_type_variation = &"HintLabel" text = "Scroll" @@ -494,3 +496,5 @@ text = "Scroll" unique_name_in_owner = true libraries/ = SubResource("AnimationLibrary_ir5dn") speed_scale = 0.5 + +[node name="TouchBackButton" parent="." unique_id=617734215 instance=ExtResource("16_bxkgu")] diff --git a/scenes/ui_elements/touch_controls/components/touch_back_button.gd b/scenes/ui_elements/touch_controls/components/touch_back_button.gd new file mode 100644 index 0000000000..b13c8c4e07 --- /dev/null +++ b/scenes/ui_elements/touch_controls/components/touch_back_button.gd @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: The Threadbare Authors +# SPDX-License-Identifier: MPL-2.0 +extends Control +## A button to go back, for touchscreens only. +## +## Add it to scenes that show an input hint to go back, like the credits or the +## storybook. It's in the same place as the pause button of the touch controls, +## which are hidden while these scenes are shown. + +## The input action that the button presses, which should be the action of the +## input hint to go back. +@export var action: StringName = &"ui_cancel" + +@onready var back_button: TouchScreenButton = %BackButton + + +func _ready() -> void: + back_button.action = action diff --git a/scenes/ui_elements/touch_controls/components/touch_back_button.gd.uid b/scenes/ui_elements/touch_controls/components/touch_back_button.gd.uid new file mode 100644 index 0000000000..0fee696d88 --- /dev/null +++ b/scenes/ui_elements/touch_controls/components/touch_back_button.gd.uid @@ -0,0 +1 @@ +uid://bxl4ylg4kwme diff --git a/scenes/ui_elements/touch_controls/touch_back_button.tscn b/scenes/ui_elements/touch_controls/touch_back_button.tscn new file mode 100644 index 0000000000..4a5fdabe3b --- /dev/null +++ b/scenes/ui_elements/touch_controls/touch_back_button.tscn @@ -0,0 +1,29 @@ +[gd_scene format=3 uid="uid://hs4x784e2st8"] + +[ext_resource type="Script" uid="uid://bxl4ylg4kwme" path="res://scenes/ui_elements/touch_controls/components/touch_back_button.gd" id="1_sdwbk"] +[ext_resource type="Texture2D" uid="uid://8yhl38p13lka" path="res://assets/first_party/user_interface/back-touch-button.png" id="2_m9pc5"] +[ext_resource type="Texture2D" uid="uid://c4b4gth4ivudd" path="res://assets/first_party/user_interface/back-touch-button_pressed.png" id="3_yhv2v"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_j06we"] +size = Vector2(128, 128) + +[node name="TouchBackButton" type="Control" unique_id=1065505802] +custom_minimum_size = Vector2(148, 148) +layout_mode = 3 +anchors_preset = 0 +offset_right = 156.0 +offset_bottom = 148.0 +mouse_filter = 2 +script = ExtResource("1_sdwbk") + +[node name="BoxContainer" type="BoxContainer" parent="." unique_id=1668805159] +layout_mode = 1 +mouse_filter = 2 + +[node name="BackButton" type="TouchScreenButton" parent="BoxContainer" unique_id=1634160833] +unique_name_in_owner = true +position = Vector2(16, 16) +texture_normal = ExtResource("2_m9pc5") +texture_pressed = ExtResource("3_yhv2v") +shape = SubResource("RectangleShape2D_j06we") +visibility_mode = 1