diff --git a/ServerUI.gd b/ServerUI.gd index 3706547..503f05a 100644 --- a/ServerUI.gd +++ b/ServerUI.gd @@ -1,8 +1,13 @@ extends Control const SERVER_STATUS_TEXT: Dictionary = { - "RUNNING": "Server is running!", - "NOT_RUNNING": "Server is not running." + true: "Server is running!", + false: "Server is not running.", +} + +const START_BUTTON_SERVER_TEXT: Dictionary = { + true: "Stop server", + false: "Start server", } const ACCEPTED_FILE_FORMATS := ["md"] # server should ignore these file types when adding endpoints @@ -148,23 +153,15 @@ func _on_OpenServerFolderButton_pressed() -> void: func set_server_running(running: bool) -> void: is_server_running = running - if is_server_running: - server_status_label.text = SERVER_STATUS_TEXT.RUNNING - start_server_button.text = "Stop server" - port_spin_box.editable = false - document_date_lineedit.editable = false - document_title_lineedit.editable = false - document_input_textedit.readonly = true - _set_file_tree_disabled(true) - else: - server_status_label.text = SERVER_STATUS_TEXT.NOT_RUNNING - start_server_button.text = "Start server" - port_spin_box.editable = !false - document_date_lineedit.editable = !false - document_title_lineedit.editable = !false - document_input_textedit.readonly = !true - _set_file_tree_disabled(false) + port_spin_box.editable = !running + document_date_lineedit.editable = !running + document_title_lineedit.editable = !running + document_input_textedit.readonly = running + _set_file_tree_disabled(running) + + server_status_label.text = SERVER_STATUS_TEXT[running] + start_server_button.text = START_BUTTON_SERVER_TEXT[running] func _generate_filestxt():