properly update and use server_dir from ServerUI

This commit is contained in:
Lera Elvoé 2022-07-02 13:41:15 +03:00
parent 8cbfffba94
commit 836c101e6f
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc
2 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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"]