From fd7b1b9c5eaa0329547c3e3fe0172cb097e73edd Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 22 May 2018 20:04:36 -0400 Subject: [PATCH] Add back buttons to all submenus --- scenes/custom_game.tscn | 26 +++++++++++++++++++++++++- scenes/lobby.tscn | 24 ++++++++++++++++++++++++ scenes/menu.tscn | 24 ++++++++++++++++++++++++ scripts/custom_game.gd | 2 +- scripts/lobby.gd | 5 +++++ scripts/menu.gd | 1 + 6 files changed, 80 insertions(+), 2 deletions(-) diff --git a/scenes/custom_game.tscn b/scenes/custom_game.tscn index 799f501..1bc0d28 100644 --- a/scenes/custom_game.tscn +++ b/scenes/custom_game.tscn @@ -36,7 +36,7 @@ anchor_bottom = 0.0 margin_left = 498.0 margin_top = 140.0 margin_right = 518.0 -margin_bottom = 563.0 +margin_bottom = 481.0 rect_pivot_offset = Vector2( 0, 0 ) mouse_filter = 0 mouse_default_cursor_shape = 0 @@ -205,4 +205,28 @@ percent_visible = 1.0 lines_skipped = 0 max_lines_visible = -1 +[node name="Back" type="Button" parent="." index="8"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 437.0 +margin_top = 509.0 +margin_right = 581.0 +margin_bottom = 537.0 +rect_pivot_offset = Vector2( 0, 0 ) +focus_mode = 2 +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +toggle_mode = false +enabled_focus_mode = 2 +shortcut = null +group = null +text = "Back to menu" +flat = false +align = 1 + diff --git a/scenes/lobby.tscn b/scenes/lobby.tscn index 66f376c..2458770 100644 --- a/scenes/lobby.tscn +++ b/scenes/lobby.tscn @@ -317,5 +317,29 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 +[node name="Back" type="Button" parent="." index="10"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 834.0 +margin_top = 443.0 +margin_right = 978.0 +margin_bottom = 471.0 +rect_pivot_offset = Vector2( 0, 0 ) +focus_mode = 2 +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +toggle_mode = false +enabled_focus_mode = 2 +shortcut = null +group = null +text = "Exit to menu" +flat = false +align = 1 + [editable path="HeroSelect"] diff --git a/scenes/menu.tscn b/scenes/menu.tscn index 830d17b..ce87646 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -139,4 +139,28 @@ text = "Practice Range" flat = false align = 1 +[node name="Quit" type="Button" parent="Center" index="3"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = -252.0 +margin_top = 200.0 +margin_right = 298.0 +margin_bottom = 266.0 +rect_pivot_offset = Vector2( 0, 0 ) +focus_mode = 2 +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +toggle_mode = false +enabled_focus_mode = 2 +shortcut = null +group = null +text = "Quit" +flat = false +align = 1 + diff --git a/scripts/custom_game.gd b/scripts/custom_game.gd index ec77fb5..996d758 100644 --- a/scripts/custom_game.gd +++ b/scripts/custom_game.gd @@ -3,6 +3,7 @@ extends Control func _ready(): get_node("Server").connect("pressed", self, "_start_server") get_node("Client").connect("pressed", self, "_start_client") + get_node("Back").connect("pressed", get_tree(), "change_scene", ["res://scenes/menu.tscn"]) func _start_server(): # Custom Game can assume we're playing as well @@ -11,4 +12,3 @@ func _start_server(): func _start_client(): var ip = get_node("IP").text networking.start_client(ip) - diff --git a/scripts/lobby.gd b/scripts/lobby.gd index 31fff35..d96f8d8 100644 --- a/scripts/lobby.gd +++ b/scripts/lobby.gd @@ -16,6 +16,7 @@ func _ready(): get_node("Spectating").connect("toggled", self, "_set_info_callback", ["spectating"]) ready_button.connect("toggled", self, "_set_info_callback", ["ready"]) start_game_button.connect("pressed", networking, "start_game") + get_node("Back").connect("pressed", self, "_exit_to_menu") # Shown, maybe, in _check_begun start_game_button.hide() if get_tree().is_network_server(): @@ -97,3 +98,7 @@ func render_player_list(): list += "\n" get_node("PlayerList").set_text(list) +func _exit_to_menu(): + get_tree().network_peer.close_connection() + get_tree().change_scene("res://scenes/menu.tscn") + diff --git a/scripts/menu.gd b/scripts/menu.gd index 95b6299..e11b912 100644 --- a/scripts/menu.gd +++ b/scripts/menu.gd @@ -11,6 +11,7 @@ func _gui_setup(): get_node("Center/Play").connect("pressed", self, "_find_game") get_node("Center/CustomGame").connect("pressed", self, "_custom_game") get_node("Center/Singleplayer").connect("pressed", self, "_singleplayer") + get_node("Center/Quit").connect("pressed", get_tree(), "quit") func _find_game(): # var ip = networking.global_server_ip