From 45cf485d9d56f9d7c35cea6a2b43bfca53e1a4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Wed, 29 Jun 2022 13:55:44 +0300 Subject: [PATCH] disable file tree context menu while server is running --- ServerUI.gd | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ServerUI.gd b/ServerUI.gd index 28e18d3..623dfe8 100644 --- a/ServerUI.gd +++ b/ServerUI.gd @@ -133,6 +133,11 @@ func _on_FileTree_item_selected() -> void: func _on_FileTree_item_rmb_selected(position: Vector2) -> void: current_tree_selection = file_tree.get_selected() file_tree_context_menu.rect_position = position + file_tree.rect_global_position + file_tree_context_menu.popup() + + if is_server_running: + return # the file tree can't be edited while the server is running, so disable moving items as well + if (current_tree_selection.get_metadata(0)["id"] as int) == 0: file_tree_context_menu.set_item_disabled(ContextMenuOptions.MOVE_UP, true) else: @@ -144,8 +149,6 @@ func _on_FileTree_item_rmb_selected(position: Vector2) -> void: file_tree_context_menu.set_item_disabled(ContextMenuOptions.MOVE_DOWN, false) - file_tree_context_menu.popup() - func _on_OpenServerFolderButton_pressed() -> void: server_folder_dialog.popup() @@ -159,6 +162,7 @@ func set_server_running(running: bool) -> void: document_title_lineedit.editable = !running document_input_textedit.readonly = running _set_file_tree_disabled(running) + _set_context_menu_disabled(running) server_status_label.text = SERVER_STATUS_TEXT[running] start_server_button.text = START_BUTTON_SERVER_TEXT[running] @@ -244,7 +248,8 @@ func _set_file_tree_disabled(disabled: bool) -> void: func _set_context_menu_disabled(disabled: bool) -> void: - pass + for i in file_tree_context_menu.get_item_count(): + file_tree_context_menu.set_item_disabled(i, disabled) func _on_FileTreeContextMenu_id_pressed(id: int) -> void: