mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 07:14:42 -04:00
Add a "Use ZSTD Compression" checkbox on Save Sprite dialog
This commit is contained in:
parent
671536cbd7
commit
d31509035f
4 changed files with 32 additions and 7 deletions
|
@ -264,9 +264,14 @@ func open_old_pxo_file(file : File, new_project : Project, first_line : String)
|
|||
tag_line = file.get_line()
|
||||
|
||||
|
||||
func save_pxo_file(path : String, autosave : bool, project : Project = Global.current_project) -> void:
|
||||
var file := File.new()
|
||||
var err := file.open_compressed(path, File.WRITE, File.COMPRESSION_ZSTD)
|
||||
func save_pxo_file(path : String, autosave : bool, use_zstd_compression := true, project : Project = Global.current_project) -> void:
|
||||
var file : File = File.new()
|
||||
var err
|
||||
if use_zstd_compression:
|
||||
err = file.open_compressed(path, File.WRITE, File.COMPRESSION_ZSTD)
|
||||
else:
|
||||
err = file.open(path, File.WRITE)
|
||||
|
||||
if err == OK:
|
||||
if !autosave:
|
||||
project.name = path.get_file()
|
||||
|
@ -284,7 +289,7 @@ func save_pxo_file(path : String, autosave : bool, project : Project = Global.cu
|
|||
file.close()
|
||||
|
||||
if OS.get_name() == "HTML5" and !autosave:
|
||||
err = file.open_compressed(path, File.READ, File.COMPRESSION_ZSTD)
|
||||
err = file.open(path, File.READ)
|
||||
if !err:
|
||||
var file_data = Array(file.get_buffer(file.get_len()))
|
||||
JavaScript.eval("download('%s', %s, '');" % [path.get_file(), str(file_data)], true)
|
||||
|
@ -460,7 +465,7 @@ func _on_Autosave_timeout() -> void:
|
|||
backup_save_paths[i] = "user://backup-" + String(OS.get_unix_time()) + "-%s" % i
|
||||
|
||||
store_backup_path(i)
|
||||
save_pxo_file(backup_save_paths[i], true, Global.projects[i])
|
||||
save_pxo_file(backup_save_paths[i], true, true, Global.projects[i])
|
||||
|
||||
|
||||
# Backup paths are stored in two ways:
|
||||
|
|
12
src/Main.gd
12
src/Main.gd
|
@ -22,6 +22,13 @@ func _ready() -> void:
|
|||
$QuitAndSaveDialog.add_button("Save & Exit", false, "Save")
|
||||
$QuitAndSaveDialog.get_ok().text = "Exit without saving"
|
||||
|
||||
var zstd_checkbox := CheckBox.new()
|
||||
zstd_checkbox.name = "ZSTDCompression"
|
||||
zstd_checkbox.pressed = true
|
||||
zstd_checkbox.text = "Use ZSTD Compression"
|
||||
zstd_checkbox.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
$SaveSprite.get_vbox().add_child(zstd_checkbox)
|
||||
|
||||
if not Global.config_cache.has_section_key("preferences", "startup"):
|
||||
Global.config_cache.set_value("preferences", "startup", true)
|
||||
show_splash_screen()
|
||||
|
@ -136,7 +143,8 @@ func _on_OpenSprite_file_selected(path : String) -> void:
|
|||
|
||||
|
||||
func _on_SaveSprite_file_selected(path : String) -> void:
|
||||
OpenSave.save_pxo_file(path, false)
|
||||
var zstd = Global.save_sprites_dialog.get_vbox().get_node("ZSTDCompression").pressed
|
||||
OpenSave.save_pxo_file(path, false, zstd)
|
||||
|
||||
if is_quitting_on_save:
|
||||
_on_QuitDialog_confirmed()
|
||||
|
@ -146,7 +154,7 @@ func _on_SaveSpriteHTML5_confirmed() -> void:
|
|||
var file_name = Global.save_sprites_html5_dialog.get_node("FileNameContainer/FileNameLineEdit").text
|
||||
file_name += ".pxo"
|
||||
var path = "user://".plus_file(file_name)
|
||||
OpenSave.save_pxo_file(path, false)
|
||||
OpenSave.save_pxo_file(path, false, false)
|
||||
|
||||
|
||||
func _on_OpenSprite_popup_hide() -> void:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue