From 542e9f44be4926a5b03756710b337daf410a3e2e Mon Sep 17 00:00:00 2001 From: tpart Date: Wed, 26 Jun 2024 21:21:02 +0200 Subject: Improve controller support in menus (back button) --- client/menu/character_menu.gd | 5 +++++ client/menu/ingame_menu.tscn | 2 +- client/menu/menu_manager.gd | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'client/menu') 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) -- cgit v1.2.3-70-g09d2 From fd5521667f38532a51b69be2aee8b0480dea1337 Mon Sep 17 00:00:00 2001 From: tpart Date: Wed, 26 Jun 2024 21:29:32 +0200 Subject: Fix not fading in --- client/global.gd | 2 ++ client/menu/character_menu.gd | 1 + client/menu/ingame_menu.tscn | 2 +- client/menu/menu_manager.gd | 4 ++++ client/menu/menu_manager.tscn | 9 +++------ client/menu/scene_transition.gd | 11 ++++++++++- 6 files changed, 21 insertions(+), 8 deletions(-) (limited to 'client/menu') diff --git a/client/global.gd b/client/global.gd index 6e12d0cf..ee1e3e96 100644 --- a/client/global.gd +++ b/client/global.gd @@ -40,6 +40,8 @@ var settings: Dictionary var server_url = "" var error_message = "" +var fade_next := false # Set true when transitioning from another scene (fade in requried) + func _ready(): profile = load_dict("user://profile", DEFAULT_PROFILE) settings = load_dict("user://settings", default_settings) diff --git a/client/menu/character_menu.gd b/client/menu/character_menu.gd index 347a0db1..80fcdcb6 100644 --- a/client/menu/character_menu.gd +++ b/client/menu/character_menu.gd @@ -29,6 +29,7 @@ func _input(event): _on_back_pressed() func _on_back_pressed(): + Global.fade_next = true $SceneTransition.transition_to("res://menu/menu_manager.tscn") func _on_username_text_changed(new_text): diff --git a/client/menu/ingame_menu.tscn b/client/menu/ingame_menu.tscn index eba314ce..7657a1ae 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 = 3240.0 +offset_bottom = 3888.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 7c958272..079f6e44 100644 --- a/client/menu/menu_manager.gd +++ b/client/menu/menu_manager.gd @@ -12,6 +12,10 @@ var menu_stack = ["main"] func _ready(): Global.focus_first_button(menus[menu_stack.back()]) + + if Global.fade_next: + Global.fade_next = false + transition.fade_in() func _input(event): if Input.is_action_just_pressed("ui_cancel") && menu_stack.size() > 1: diff --git a/client/menu/menu_manager.tscn b/client/menu/menu_manager.tscn index 6b2d7b33..18e13282 100644 --- a/client/menu/menu_manager.tscn +++ b/client/menu/menu_manager.tscn @@ -30,9 +30,6 @@ visible = false layout_mode = 1 [node name="SceneTransition" parent="." instance=ExtResource("6_p4u45")] -layout_mode = 0 -anchors_preset = 0 -anchor_right = 0.0 -anchor_bottom = 0.0 -grow_horizontal = 1 -grow_vertical = 1 +visible = false +layout_mode = 1 +auto_fade_in = false diff --git a/client/menu/scene_transition.gd b/client/menu/scene_transition.gd index 87a1ec1b..30c7e1df 100644 --- a/client/menu/scene_transition.gd +++ b/client/menu/scene_transition.gd @@ -19,8 +19,16 @@ extends ColorRect @onready var anim = $animation @export var ingame = false +@export var auto_fade_in := true + func _ready(): - self.visible = true + if auto_fade_in: + fade_in() + else: + visible = false + +func fade_in(): + visible = true anim.play("fade_in") func transition_to(path: String): @@ -35,6 +43,7 @@ func quit(): get_tree().quit() func out(): + visible = true if menu.visible: menu.anim.play_backwards("activate") await menu.anim.animation_finished -- cgit v1.2.3-70-g09d2 From b76c621c4080bee17124a1584621f9fc41bb09e1 Mon Sep 17 00:00:00 2001 From: tpart Date: Wed, 26 Jun 2024 21:30:24 +0200 Subject: Fix fade from in game menu to main menu --- client/menu/ingame_menu.gd | 1 + 1 file changed, 1 insertion(+) (limited to 'client/menu') diff --git a/client/menu/ingame_menu.gd b/client/menu/ingame_menu.gd index 4752c382..73f4dbb3 100644 --- a/client/menu/ingame_menu.gd +++ b/client/menu/ingame_menu.gd @@ -14,6 +14,7 @@ func deact(): hide() func _on_main_menu_pressed(): + Global.fade_next = true get_parent().transition_to("res://menu/menu_manager.tscn") func _on_quit_pressed(): -- cgit v1.2.3-70-g09d2 From cbe0201f67eaa751434786e23da3311761f5e776 Mon Sep 17 00:00:00 2001 From: tpart Date: Wed, 26 Jun 2024 21:30:51 +0200 Subject: Clarify ingame quit button --- client/menu/ingame_menu.tscn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client/menu') diff --git a/client/menu/ingame_menu.tscn b/client/menu/ingame_menu.tscn index 7657a1ae..725735ea 100644 --- a/client/menu/ingame_menu.tscn +++ b/client/menu/ingame_menu.tscn @@ -105,12 +105,12 @@ alignment = 0 [node name="MainMenu" type="Button" parent="Side/Margin/Options"] layout_mode = 2 -text = "Main Menu" +text = "Main menu" alignment = 0 [node name="Quit" type="Button" parent="Side/Margin/Options"] layout_mode = 2 -text = "Quit" +text = "Quit game" alignment = 0 [connection signal="pressed" from="Side/Margin/Options/Reconnect" to="." method="_on_reconnect_pressed"] -- cgit v1.2.3-70-g09d2