diff --git a/ServerUI.gd b/ServerUI.gd index 8584394..31a265e 100644 --- a/ServerUI.gd +++ b/ServerUI.gd @@ -37,12 +37,12 @@ onready var content_preview_richtextlabel := $"%ContentPreviewRichTextLabel" onready var server_folder_dialog := $"%ServerFolderDialog" signal server_folder_changed(new_path) # new_path: String -signal server_port_changed(new_port) # new_port: int signal start_server_button_pressed(port, path) # port: int, path: String signal stop_server_button_pressed() # emit from %StartServerButton, when the server is not running. -signal open_browser_button_pressed(port) # port: int -signal files_selection_changed(new_files) # new_files: Array +#signal server_port_changed(new_port) # new_port: int +#signal open_browser_button_pressed(port) # port: int +#signal files_selection_changed(new_files) # new_files: Array var server_dir: String setget set_server_dir var is_server_running: bool = false setget set_server_running @@ -73,9 +73,10 @@ func set_server_dir(dir: String) -> void: var directory := Directory.new() if directory.open(dir) == OK: - directory.list_dir_begin() + if directory.list_dir_begin() != OK: + push_error("Directory error") # TODO: show a user-facing error + var file_name: String = directory.get_next() - var idx: int = 0 while file_name != "": if !directory.current_is_dir() && (file_name.get_extension() in ACCEPTED_FILE_FORMATS): var fd = FileDef(file_name, false) @@ -89,13 +90,12 @@ func set_server_dir(dir: String) -> void: fd.title = file_metadata["title"] fd.date = file_metadata["date"] - idx += 1 - file_name = directory.get_next() directory.list_dir_end() _reconstruct_tree_from_working_files() + emit_signal("server_folder_changed", server_dir) func _reconstruct_tree_from_working_files() -> void: @@ -149,7 +149,6 @@ func _on_FileTree_item_rmb_selected(position: Vector2) -> void: file_tree_context_menu.set_item_disabled(ContextMenuOptions.MOVE_DOWN, false) - func _on_OpenServerFolderButton_pressed() -> void: server_folder_dialog.popup() @@ -287,6 +286,7 @@ func _on_DocInputTextEdit_text_changed() -> void: t.one_shot = true current_file.timer = t add_child(t) +# warning-ignore:return_value_discarded t.connect("timeout", self, "_on_EditedTimeout_timeout", [t, current_file]) else: current_file.timer.stop()