FunkPanion/scripts/xmle/save.gd

22 lines
747 B
GDScript

extends Button
@onready var root = get_tree().root
func save(content:String) -> void:
var file_dialog = FileDialog.new()
file_dialog.use_native_dialog = true
file_dialog.file_mode = FileDialog.FILE_MODE_SAVE_FILE
file_dialog.add_filter("*.xml", "Sparrow spritesheet")
file_dialog.access = FileDialog.ACCESS_FILESYSTEM
file_dialog.current_path = OS.get_data_dir().path_join("FunkPanion/")
file_dialog.file_selected.connect(func(path_string: String):
var file = FileAccess.open(path_string, FileAccess.WRITE)
file.store_string(content)
file_dialog.queue_free()
)
file_dialog.canceled.connect(func(path_string: String):
root.remove_child(file_dialog)
file_dialog.queue_free()
)
root.add_child(file_dialog)
file_dialog.popup()