diff options
author | Daniel Weipert <code@drogueronin.de> | 2021-02-14 15:05:25 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2021-02-14 15:05:25 +0100 |
commit | 98948258e0e67fafead130728448a43cc97989ee (patch) | |
tree | 0b799ac7b0f2a01d76626384d732a76befb84c7a /Network/Lobby.gd | |
parent | 7115379ccf5714816eeb91fc16d3a63e019c8082 (diff) |
Shows lobby if we're already connected somewhere
Diffstat (limited to 'Network/Lobby.gd')
-rw-r--r-- | Network/Lobby.gd | 19 |
1 files 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) |