From 395c25b1fbe51f42decf402f97e51eabcc8c0a77 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 18 Jun 2023 16:43:22 +0200 Subject: Godot v3 -> v4 --- Network/Lobby.gd | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'Network/Lobby.gd') diff --git a/Network/Lobby.gd b/Network/Lobby.gd index be045b0..67a1f34 100644 --- a/Network/Lobby.gd +++ b/Network/Lobby.gd @@ -2,15 +2,17 @@ extends Control func _ready(): - Network.connect("connection_succeeded", self, "_on_connection_succeeded") - Network.connect("connection_failed", self, "_on_connection_failed") - Network.connect("player_list_changed", self, "refresh_lobby") - Network.connect("game_error", self, "_on_game_error") - Network.connect("game_ended", self, "_on_game_ended") - $HTTPRequest.connect("request_completed", self, '_set_remote_ip') + Network.connect("connection_succeeded", Callable(self, "_on_connection_succeeded")) + Network.connect("connection_failed", Callable(self, "_on_connection_failed")) + Network.connect("player_list_changed", Callable(self, "refresh_lobby")) + Network.connect("game_error", Callable(self, "_on_game_error")) + Network.connect("game_ended", Callable(self, "_on_game_ended")) + $HTTPRequest.connect("request_completed", Callable(self, '_set_remote_ip')) if OS.has_environment("USERNAME"): $Connect/Name.text = OS.get_environment("USERNAME") + elif OS.has_environment("USER"): + $Connect/Name.text = OS.get_environment("USER") else: var desktop_path = OS.get_system_dir(0).replace("\\", "/").split("/") $Connect/Name.text = desktop_path[desktop_path.size() - 2] @@ -36,7 +38,7 @@ func refresh_lobby(): for p in players: $Players/List.add_item(p.name) - $Players/Start.disabled = not get_tree().is_network_server() + $Players/Start.disabled = not multiplayer.is_server() func set_ip(): @@ -53,7 +55,7 @@ func set_remote_ip(): $Players/RemoteIP.text = "" $HTTPRequest.request("https://ipv4.icanhazip.com/") -func _set_remote_ip(result, response_code, headers, body): +func _set_remote_ip(_result, response_code, _headers, body): if response_code == 200: $Players/RemoteIP.text = body.get_string_from_utf8() else: @@ -73,7 +75,7 @@ func _on_connection_failed(): func _on_game_error(error): $ErrorDialog.dialog_text = error - $ErrorDialog.popup_centered_minsize() + $ErrorDialog.popup_centered_clamped() self.disable_connect_buttons() -- cgit v1.2.3