mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-22 13:33:13 +00:00
Add ZSTD compression to save files. Move clear_canvases() to Global.gd
This commit is contained in:
parent
237b8c1507
commit
99f847e732
3 changed files with 20 additions and 18 deletions
|
@ -30,7 +30,7 @@ func _on_CreateNewImage_confirmed() -> void:
|
||||||
var width : int = width_value.value
|
var width : int = width_value.value
|
||||||
var height : int = height_value.value
|
var height : int = height_value.value
|
||||||
var fill_color : Color = fill_color_node.color
|
var fill_color : Color = fill_color_node.color
|
||||||
Global.control.clear_canvases()
|
Global.clear_canvases()
|
||||||
Global.layers.clear()
|
Global.layers.clear()
|
||||||
# Store [Layer name (0), Layer visibility boolean (1), Layer lock boolean (2), Frame container (3),
|
# Store [Layer name (0), Layer visibility boolean (1), Layer lock boolean (2), Frame container (3),
|
||||||
# will new frames be linked boolean (4), Array of linked frames (5)]
|
# will new frames be linked boolean (4), Array of linked frames (5)]
|
||||||
|
|
|
@ -499,6 +499,17 @@ func canvases_changed(value : Array) -> void:
|
||||||
|
|
||||||
layers[i][3].add_child(frame_button)
|
layers[i][3].add_child(frame_button)
|
||||||
|
|
||||||
|
func clear_canvases() -> void:
|
||||||
|
for child in Global.canvas_parent.get_children():
|
||||||
|
if child is Canvas:
|
||||||
|
child.queue_free()
|
||||||
|
Global.canvases.clear()
|
||||||
|
Global.animation_tags.clear()
|
||||||
|
Global.animation_tags = Global.animation_tags # To execute animation_tags_changed()
|
||||||
|
|
||||||
|
Global.window_title = "(" + tr("untitled") + ") - Pixelorama"
|
||||||
|
Global.undo_redo.clear_history(false)
|
||||||
|
|
||||||
func layers_changed(value : Array) -> void:
|
func layers_changed(value : Array) -> void:
|
||||||
layers = value
|
layers = value
|
||||||
if layers_changed_skip:
|
if layers_changed_skip:
|
||||||
|
|
|
@ -4,8 +4,11 @@ var current_save_path := ""
|
||||||
|
|
||||||
func open_pxo_file(path : String) -> void:
|
func open_pxo_file(path : String) -> void:
|
||||||
var file := File.new()
|
var file := File.new()
|
||||||
var err := file.open(path, File.READ)
|
var err := file.open_compressed(path, File.READ, File.COMPRESSION_ZSTD)
|
||||||
if err != OK: # An error occured
|
if err == ERR_FILE_UNRECOGNIZED:
|
||||||
|
err = file.open(path, File.READ) # If the file is not compressed open it raw (pre-v0.7)
|
||||||
|
|
||||||
|
if err != OK:
|
||||||
file.close()
|
file.close()
|
||||||
OS.alert("Can't load file")
|
OS.alert("Can't load file")
|
||||||
return
|
return
|
||||||
|
@ -15,7 +18,7 @@ func open_pxo_file(path : String) -> void:
|
||||||
var file_minor_version = int(file_version.substr(3, 1))
|
var file_minor_version = int(file_version.substr(3, 1))
|
||||||
|
|
||||||
if file_major_version == 0 and file_minor_version < 5:
|
if file_major_version == 0 and file_minor_version < 5:
|
||||||
OS.alert("File is from an older version of Pixelorama, as such it might not work properly")
|
Global.notification_label("File is from an older version of Pixelorama, as such it might not work properly")
|
||||||
|
|
||||||
var frame := 0
|
var frame := 0
|
||||||
Global.layers.clear()
|
Global.layers.clear()
|
||||||
|
@ -34,7 +37,7 @@ func open_pxo_file(path : String) -> void:
|
||||||
global_layer_line = file.get_line()
|
global_layer_line = file.get_line()
|
||||||
|
|
||||||
var frame_line := file.get_line()
|
var frame_line := file.get_line()
|
||||||
clear_canvases()
|
Global.clear_canvases()
|
||||||
while frame_line == "--": # Load frames
|
while frame_line == "--": # Load frames
|
||||||
var canvas : Canvas = load("res://Prefabs/Canvas.tscn").instance()
|
var canvas : Canvas = load("res://Prefabs/Canvas.tscn").instance()
|
||||||
Global.canvas = canvas
|
Global.canvas = canvas
|
||||||
|
@ -137,7 +140,7 @@ func save_pxo_file(path : String) -> void:
|
||||||
current_save_path = path
|
current_save_path = path
|
||||||
|
|
||||||
var file := File.new()
|
var file := File.new()
|
||||||
var err := file.open(path, File.WRITE)
|
var err := file.open_compressed(path, File.WRITE, File.COMPRESSION_ZSTD)
|
||||||
if err == OK:
|
if err == OK:
|
||||||
# Store Pixelorama version
|
# Store Pixelorama version
|
||||||
file.store_line(ProjectSettings.get_setting("application/config/Version"))
|
file.store_line(ProjectSettings.get_setting("application/config/Version"))
|
||||||
|
@ -212,15 +215,3 @@ func save_pxo_file(path : String) -> void:
|
||||||
|
|
||||||
Global.window_title = current_save_path.get_file() + " - Pixelorama"
|
Global.window_title = current_save_path.get_file() + " - Pixelorama"
|
||||||
Global.notification_label("File saved")
|
Global.notification_label("File saved")
|
||||||
|
|
||||||
|
|
||||||
func clear_canvases() -> void:
|
|
||||||
for child in Global.canvas_parent.get_children():
|
|
||||||
if child is Canvas:
|
|
||||||
child.queue_free()
|
|
||||||
Global.canvases.clear()
|
|
||||||
Global.animation_tags.clear()
|
|
||||||
Global.animation_tags = Global.animation_tags # To execute animation_tags_changed()
|
|
||||||
|
|
||||||
Global.window_title = "(" + tr("untitled") + ") - Pixelorama"
|
|
||||||
Global.undo_redo.clear_history(false)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue