From 98948258e0e67fafead130728448a43cc97989ee Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 14 Feb 2021 15:05:25 +0100 Subject: Shows lobby if we're already connected somewhere --- Network/Lobby.gd | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Network/Lobby.gd b/Network/Lobby.gd index d192640..15f27ba 100644 --- a/Network/Lobby.gd +++ b/Network/Lobby.gd @@ -13,6 +13,12 @@ func _ready(): else: var desktop_path = OS.get_system_dir(0).replace("\\", "/").split("/") $Connect/Name.text = desktop_path[desktop_path.size() - 2] + + # show lobby if we're already connected somewhere + if Network.peer != null: + self._on_connection_succeeded() + self.set_ip() + self.refresh_lobby() func disable_connect_buttons(is_disabled = true): @@ -32,6 +38,12 @@ func refresh_lobby(): $Players/Start.disabled = not get_tree().is_network_server() +func set_ip(): + for ip in IP.get_local_addresses(): + if ip.begins_with("192.168"): + $Players/IP.text = ip + break + func _on_connection_succeeded(): $Connect.hide() $Players.show() @@ -60,10 +72,7 @@ func _on_Host_pressed(): $Players.show() $Connect/Error.text = "" - for ip in IP.get_local_addresses(): - if ip.begins_with("192.168"): - $Players/IP.text = ip - break + self.set_ip() var player_name = $Connect/Name.text Network.host_game(player_name) @@ -79,7 +88,7 @@ func _on_Join_pressed(): $Connect/Error.text = "" self.disable_connect_buttons(false) - $Players/IP.text = IP.get_local_addresses()[6] + self.set_ip() var player_name = $Connect/Name.text Network.join_game(ip, player_name) -- cgit v1.2.3