Clean up Brogether UI on shutdown
This commit is contained in:
@@ -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")
|
_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:
|
func _process(_delta: float) -> void:
|
||||||
if status_time_left > 0.0:
|
if status_time_left > 0.0:
|
||||||
status_time_left -= _delta
|
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)
|
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:
|
func _on_lobby_created(connect: int, created_lobby_id: int) -> void:
|
||||||
if connect != 1:
|
if connect != 1:
|
||||||
_log("lobby creation failed: %s" % connect)
|
_log("lobby creation failed: %s" % connect)
|
||||||
@@ -961,7 +992,36 @@ func _avatar_color(value: int) -> Color:
|
|||||||
func _clear_children(parent: Node) -> void:
|
func _clear_children(parent: Node) -> void:
|
||||||
for child in parent.get_children():
|
for child in parent.get_children():
|
||||||
parent.remove_child(child)
|
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:
|
func toggle_debug_panel() -> void:
|
||||||
|
|||||||
Reference in New Issue
Block a user