From a706caef02ce21eaf76f665428717b70fa22ccd5 Mon Sep 17 00:00:00 2001 From: Kroonk Date: Sat, 23 May 2026 01:09:32 +0200 Subject: [PATCH] Clean up Brogether UI on shutdown --- .../Brogether-Brogether/mod_main.gd | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/mods-unpacked/Brogether-Brogether/mod_main.gd b/src/mods-unpacked/Brogether-Brogether/mod_main.gd index 5ed439f..dd1ff61 100644 --- a/src/mods-unpacked/Brogether-Brogether/mod_main.gd +++ b/src/mods-unpacked/Brogether-Brogether/mod_main.gd @@ -59,6 +59,21 @@ func _ready() -> void: _log("loaded. F5=toggle modal, F6=create lobby, F7=find/join lobby, F9=leave, F10=ping, F11=loopback test") +func _exit_tree() -> void: + set_process(false) + set_process_input(false) + _disconnect_steam_signals() + if steam != null and lobby_id != 0 and steam.has_method("leaveLobby"): + steam.call("leaveLobby", lobby_id) + lobby_id = 0 + is_host = false + lobby_members.clear() + available_lobbies.clear() + current_players.clear() + _free_ui() + steam = null + + func _process(_delta: float) -> void: if status_time_left > 0.0: status_time_left -= _delta @@ -271,6 +286,22 @@ func _connect_steam_signal(signal_name: String, method_name: String) -> void: steam.connect(signal_name, self, method_name) +func _disconnect_steam_signals() -> void: + _disconnect_steam_signal("lobby_created", "_on_lobby_created") + _disconnect_steam_signal("lobby_joined", "_on_lobby_joined") + _disconnect_steam_signal("lobby_match_list", "_on_lobby_match_list") + _disconnect_steam_signal("lobby_chat_update", "_on_lobby_chat_update") + _disconnect_steam_signal("p2p_session_request", "_on_p2p_session_request") + _disconnect_steam_signal("p2p_session_connect_fail", "_on_p2p_session_connect_fail") + + +func _disconnect_steam_signal(signal_name: String, method_name: String) -> void: + if steam == null: + return + if steam.has_signal(signal_name) and steam.is_connected(signal_name, self, method_name): + steam.disconnect(signal_name, self, method_name) + + func _on_lobby_created(connect: int, created_lobby_id: int) -> void: if connect != 1: _log("lobby creation failed: %s" % connect) @@ -961,7 +992,36 @@ func _avatar_color(value: int) -> Color: func _clear_children(parent: Node) -> void: for child in parent.get_children(): parent.remove_child(child) - child.queue_free() + child.free() + + +func _free_ui() -> void: + if panel != null and panel.visible: + get_tree().paused = restore_paused_value + restore_focus_control = null + if status_layer != null and is_instance_valid(status_layer): + if status_layer.get_parent() != null: + status_layer.get_parent().remove_child(status_layer) + status_layer.free() + status_layer = null + status_label = null + dim_background = null + panel = null + panel_status_label = null + panel_log_label = null + panel_default_focus = null + browser_view = null + lobby_view = null + lobby_list_container = null + lobby_empty_label = null + lobby_name_input = null + lobby_password_input = null + lobby_password_check = null + join_password_input = null + selected_lobby_label = null + lobby_members_container = null + lobby_title_label = null + lobby_detail_label = null func toggle_debug_panel() -> void: