diff options
author | tpart <tpart120@proton.me> | 2024-06-26 21:21:02 +0200 |
---|---|---|
committer | tpart <tpart120@proton.me> | 2024-06-26 21:21:02 +0200 |
commit | 542e9f44be4926a5b03756710b337daf410a3e2e (patch) | |
tree | d255386134e91f1d54f25097aa855c9906344b80 | |
parent | c1e3ea079c8e6679228a88f0da73deba67b9be94 (diff) | |
download | hurrycurry-542e9f44be4926a5b03756710b337daf410a3e2e.tar hurrycurry-542e9f44be4926a5b03756710b337daf410a3e2e.tar.bz2 hurrycurry-542e9f44be4926a5b03756710b337daf410a3e2e.tar.zst |
Improve controller support in menus (back button)
-rw-r--r-- | client/menu/character_menu.gd | 5 | ||||
-rw-r--r-- | client/menu/ingame_menu.tscn | 2 | ||||
-rw-r--r-- | client/menu/menu_manager.gd | 4 | ||||
-rw-r--r-- | client/project.godot | 6 |
4 files changed, 16 insertions, 1 deletions
diff --git a/client/menu/character_menu.gd b/client/menu/character_menu.gd index 3e535e71..347a0db1 100644 --- a/client/menu/character_menu.gd +++ b/client/menu/character_menu.gd @@ -17,12 +17,17 @@ extends Control @onready var character: Character = $Character @onready var num_hairstyles := character.hairstyles.keys().size() +@onready var back_button := $VBoxContainer/bottom_panel/back func _ready(): $VBoxContainer/top_panel/a/username.text = Global.profile["username"] character.select_hairstyle(Global.profile["character"]) Global.focus_first_button(self) +func _input(event): + if Input.is_action_just_pressed("ui_cancel"): + _on_back_pressed() + func _on_back_pressed(): $SceneTransition.transition_to("res://menu/menu_manager.tscn") diff --git a/client/menu/ingame_menu.tscn b/client/menu/ingame_menu.tscn index 79b4efb1..eba314ce 100644 --- a/client/menu/ingame_menu.tscn +++ b/client/menu/ingame_menu.tscn @@ -72,7 +72,7 @@ anchors_preset = 9 anchor_bottom = 1.0 offset_left = -400.0 offset_right = -90.0 -offset_bottom = 2592.0 +offset_bottom = 3240.0 grow_vertical = 2 [node name="Margin" type="MarginContainer" parent="Side"] diff --git a/client/menu/menu_manager.gd b/client/menu/menu_manager.gd index 69866377..7c958272 100644 --- a/client/menu/menu_manager.gd +++ b/client/menu/menu_manager.gd @@ -13,6 +13,10 @@ var menu_stack = ["main"] func _ready(): Global.focus_first_button(menus[menu_stack.back()]) +func _input(event): + if Input.is_action_just_pressed("ui_cancel") && menu_stack.size() > 1: + go_back() + func goto(menu_name: String): show_menu(menu_name) menu_stack.push_back(menu_name) diff --git a/client/project.godot b/client/project.godot index f8a060d1..e4198843 100644 --- a/client/project.godot +++ b/client/project.godot @@ -31,6 +31,12 @@ ui_accept={ , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null) ] } +ui_cancel={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":true,"script":null) +] +} forward={ "deadzone": 0.1, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null) |