implement refresh button
This commit is contained in:
parent
815aae5a4d
commit
68b4a03a3f
28
ServerUI.gd
28
ServerUI.gd
@ -253,6 +253,12 @@ func _set_context_menu_disabled(disabled: bool) -> void:
|
||||
file_tree_context_menu.set_item_disabled(i, disabled)
|
||||
|
||||
|
||||
func _commit_all_files() -> void:
|
||||
for file in working_files:
|
||||
file = file as FileDef
|
||||
file.commit(server_dir)
|
||||
|
||||
|
||||
func _on_FileTreeContextMenu_id_pressed(id: int) -> void:
|
||||
var idx = current_tree_selection.get_metadata(0)["id"] as int
|
||||
var fd = working_files[idx] as FileDef
|
||||
@ -282,6 +288,12 @@ func _on_OpenBrowserButton_pressed() -> void:
|
||||
push_error("Error opening browser!") # TODO: show a user-facing error
|
||||
|
||||
|
||||
func _on_RefreshFilesButton_pressed() -> void:
|
||||
_commit_all_files()
|
||||
_generate_filestxt()
|
||||
self.server_dir = server_dir
|
||||
|
||||
|
||||
func _on_DocInputTextEdit_text_changed() -> void:
|
||||
if current_file:
|
||||
var new_text: String = document_input_textedit.text
|
||||
@ -304,9 +316,7 @@ func _on_EditedTimeout_timeout(timer: Timer, file: FileDef) -> void:
|
||||
file.timer = null
|
||||
timer.queue_free()
|
||||
|
||||
var f := File.new()
|
||||
if f.open(server_dir.plus_file(file.file_path), File.WRITE) == OK:
|
||||
f.store_string(file.content)
|
||||
file.commit(server_dir)
|
||||
|
||||
|
||||
func FileDef(
|
||||
@ -332,3 +342,15 @@ class FileDef:
|
||||
var content: String
|
||||
|
||||
var timer: Timer
|
||||
|
||||
func commit(server_dir: String) -> void:
|
||||
var f := File.new()
|
||||
var open := f.open(server_dir.plus_file(file_path), File.WRITE)
|
||||
if open == OK:
|
||||
f.store_string(content)
|
||||
|
||||
if timer && !timer.is_stopped(): # if there's an autosave pending, stop it since we're setting it here.
|
||||
timer.stop()
|
||||
|
||||
else:
|
||||
push_error("Error committing file %s, code %s" % [file_path, open]) # TODO: show a user-facing error
|
||||
|
@ -78,11 +78,13 @@ margin_bottom = 23.0
|
||||
text = "Server is not running."
|
||||
|
||||
[node name="OpenBrowserButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_left = 922.0
|
||||
margin_right = 1040.0
|
||||
margin_bottom = 32.0
|
||||
rect_min_size = Vector2( 0, 32 )
|
||||
size_flags_horizontal = 12
|
||||
disabled = true
|
||||
text = "Open in browser"
|
||||
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="VBoxContainer"]
|
||||
@ -248,6 +250,8 @@ items = [ "Move Up", null, 0, false, false, 0, 0, null, "", false, "Move Down",
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/OpenServerFolderButton" to="." method="_on_OpenServerFolderButton_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/StartServerButton" to="." method="_on_StartServerButton_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/OpenBrowserButton" to="." method="_on_OpenBrowserButton_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/HSplitContainer/VBoxContainer2/HBoxContainer2/RefreshFilesButton" to="." method="_on_RefreshFilesButton_pressed"]
|
||||
[connection signal="item_edited" from="VBoxContainer/HSplitContainer/VBoxContainer2/FileTree" to="." method="_on_FileTree_item_edited"]
|
||||
[connection signal="item_rmb_selected" from="VBoxContainer/HSplitContainer/VBoxContainer2/FileTree" to="." method="_on_FileTree_item_rmb_selected"]
|
||||
[connection signal="item_selected" from="VBoxContainer/HSplitContainer/VBoxContainer2/FileTree" to="." method="_on_FileTree_item_selected"]
|
||||
|
Loading…
Reference in New Issue
Block a user