From 836c101e6f7e38617b052778f756e342ce06690b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Sat, 2 Jul 2022 13:41:15 +0300 Subject: [PATCH] properly update and use server_dir from ServerUI --- Main.gd | 6 +++++- Main.tscn | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Main.gd b/Main.gd index 35ee2b9..f697e15 100644 --- a/Main.gd +++ b/Main.gd @@ -66,7 +66,7 @@ func _serve_file(_request: HTTPServer.Request, response: HTTPServer.Response, bi var file_name: String = binds[0] as String var f := File.new() - var success = f.open("res://server_files/%s" % file_name, File.READ) + var success = f.open(server_dir.plus_file(file_name), File.READ) if success == OK: var mime := mime_types.get(file_name) @@ -88,3 +88,7 @@ func _on_ServerUI_start_server_button_pressed(port: int, new_dir: String) -> voi func _on_ServerUI_stop_server_button_pressed() -> void: _stop_server() + + +func _on_ServerUI_server_folder_changed(new_path: String) -> void: + server_dir = new_path diff --git a/Main.tscn b/Main.tscn index b8e1662..6d7f9e4 100644 --- a/Main.tscn +++ b/Main.tscn @@ -10,5 +10,6 @@ script = ExtResource( 1 ) [node name="ServerUI" parent="." instance=ExtResource( 2 )] +[connection signal="server_folder_changed" from="ServerUI" to="." method="_on_ServerUI_server_folder_changed"] [connection signal="start_server_button_pressed" from="ServerUI" to="." method="_on_ServerUI_start_server_button_pressed"] [connection signal="stop_server_button_pressed" from="ServerUI" to="." method="_on_ServerUI_stop_server_button_pressed"]