mirror of
https://github.com/Relintai/draw_gd.git
synced 2025-02-08 15:30:05 +01:00
OpenSave in no longer a singleton either.
This commit is contained in:
parent
6219747c16
commit
caf6ba1e0d
@ -122,7 +122,6 @@ driver="Dummy"
|
|||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
DrawGD="*res://src/Autoload/Global.gd"
|
DrawGD="*res://src/Autoload/Global.gd"
|
||||||
OpenSave="*res://src/Autoload/OpenSave.gd"
|
|
||||||
|
|
||||||
[debug]
|
[debug]
|
||||||
|
|
||||||
|
@ -169,6 +169,8 @@ onready var current_version : String = ProjectSettings.get_setting("application/
|
|||||||
var tools_script = preload("res://src/Autoload/Tools.gd")
|
var tools_script = preload("res://src/Autoload/Tools.gd")
|
||||||
var tools = null
|
var tools = null
|
||||||
|
|
||||||
|
var opensave_script = preload("res://src/Autoload/OpenSave.gd")
|
||||||
|
var opensave = null
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
randomize()
|
randomize()
|
||||||
@ -179,6 +181,9 @@ func _ready() -> void:
|
|||||||
|
|
||||||
tools = tools_script.new()
|
tools = tools_script.new()
|
||||||
add_child(tools)
|
add_child(tools)
|
||||||
|
|
||||||
|
opensave = opensave_script.new()
|
||||||
|
add_child(opensave)
|
||||||
|
|
||||||
# The fact that root_dir is set earlier than this is important
|
# The fact that root_dir is set earlier than this is important
|
||||||
# XDGDataDirs depends on it nyaa
|
# XDGDataDirs depends on it nyaa
|
||||||
@ -507,5 +512,5 @@ func _exit_tree() -> void:
|
|||||||
var i := 0
|
var i := 0
|
||||||
for project in projects:
|
for project in projects:
|
||||||
project.undo_redo.free()
|
project.undo_redo.free()
|
||||||
OpenSave.remove_backup(i)
|
DrawGD.opensave.remove_backup(i)
|
||||||
i += 1
|
i += 1
|
||||||
|
@ -44,8 +44,8 @@ func _init(_frames := [], _name := tr("untitled"), _size := Vector2(64, 64)) ->
|
|||||||
undo_redo = UndoRedo.new()
|
undo_redo = UndoRedo.new()
|
||||||
|
|
||||||
DrawGD.tabs.add_tab(name)
|
DrawGD.tabs.add_tab(name)
|
||||||
OpenSave.current_save_paths.append("")
|
DrawGD.opensave.current_save_paths.append("")
|
||||||
OpenSave.backup_save_paths.append("")
|
DrawGD.opensave.backup_save_paths.append("")
|
||||||
|
|
||||||
x_symmetry_point = size.x / 2
|
x_symmetry_point = size.x / 2
|
||||||
y_symmetry_point = size.y / 2
|
y_symmetry_point = size.y / 2
|
||||||
@ -185,7 +185,7 @@ func change_project() -> void:
|
|||||||
if has_changed:
|
if has_changed:
|
||||||
DrawGD.window_title = DrawGD.window_title + "(*)"
|
DrawGD.window_title = DrawGD.window_title + "(*)"
|
||||||
|
|
||||||
var save_path = OpenSave.current_save_paths[DrawGD.current_project_index]
|
var save_path = DrawGD.opensave.current_save_paths[DrawGD.current_project_index]
|
||||||
if save_path != "":
|
if save_path != "":
|
||||||
DrawGD.open_sprites_dialog.current_path = save_path
|
DrawGD.open_sprites_dialog.current_path = save_path
|
||||||
DrawGD.save_sprites_dialog.current_path = save_path
|
DrawGD.save_sprites_dialog.current_path = save_path
|
||||||
@ -262,7 +262,7 @@ func serialize() -> Dictionary:
|
|||||||
"name" : name,
|
"name" : name,
|
||||||
"size_x" : size.x,
|
"size_x" : size.x,
|
||||||
"size_y" : size.y,
|
"size_y" : size.y,
|
||||||
"save_path" : OpenSave.current_save_paths[DrawGD.projects.find(self)],
|
"save_path" : DrawGD.opensave.current_save_paths[DrawGD.projects.find(self)],
|
||||||
"layers" : layer_data,
|
"layers" : layer_data,
|
||||||
"tags" : tag_data,
|
"tags" : tag_data,
|
||||||
"guides" : guide_data,
|
"guides" : guide_data,
|
||||||
@ -285,7 +285,7 @@ func deserialize(dict : Dictionary) -> void:
|
|||||||
size.y = dict.size_y
|
size.y = dict.size_y
|
||||||
select_all_pixels()
|
select_all_pixels()
|
||||||
if dict.has("save_path"):
|
if dict.has("save_path"):
|
||||||
OpenSave.current_save_paths[DrawGD.projects.find(self)] = dict.save_path
|
DrawGD.opensave.current_save_paths[DrawGD.projects.find(self)] = dict.save_path
|
||||||
if dict.has("frames"):
|
if dict.has("frames"):
|
||||||
for frame in dict.frames:
|
for frame in dict.frames:
|
||||||
var cels := []
|
var cels := []
|
||||||
|
28
src/Main.gd
28
src/Main.gd
@ -42,7 +42,7 @@ func _ready() -> void:
|
|||||||
# If the user wants to run Pixelorama with arguments in terminal mode
|
# If the user wants to run Pixelorama with arguments in terminal mode
|
||||||
# or open files with Pixelorama directly, then handle that
|
# or open files with Pixelorama directly, then handle that
|
||||||
if OS.get_cmdline_args():
|
if OS.get_cmdline_args():
|
||||||
OpenSave.handle_loading_files(OS.get_cmdline_args())
|
DrawGD.opensave.handle_loading_files(OS.get_cmdline_args())
|
||||||
get_tree().connect("files_dropped", self, "_on_files_dropped")
|
get_tree().connect("files_dropped", self, "_on_files_dropped")
|
||||||
|
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ func handle_backup() -> void:
|
|||||||
for p_path in project_paths:
|
for p_path in project_paths:
|
||||||
backup_paths.append(DrawGD.config_cache.get_value("backups", p_path))
|
backup_paths.append(DrawGD.config_cache.get_value("backups", p_path))
|
||||||
# Temporatily stop autosave until user confirms backup
|
# Temporatily stop autosave until user confirms backup
|
||||||
OpenSave.autosave_timer.stop()
|
DrawGD.opensave.autosave_timer.stop()
|
||||||
backup_confirmation.dialog_text = tr(backup_confirmation.dialog_text) % project_paths
|
backup_confirmation.dialog_text = tr(backup_confirmation.dialog_text) % project_paths
|
||||||
backup_confirmation.connect("confirmed", self, "_on_BackupConfirmation_confirmed", [project_paths, backup_paths])
|
backup_confirmation.connect("confirmed", self, "_on_BackupConfirmation_confirmed", [project_paths, backup_paths])
|
||||||
backup_confirmation.get_cancel().connect("pressed", self, "_on_BackupConfirmation_delete", [project_paths, backup_paths])
|
backup_confirmation.get_cancel().connect("pressed", self, "_on_BackupConfirmation_delete", [project_paths, backup_paths])
|
||||||
@ -120,7 +120,7 @@ func _notification(what : int) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_files_dropped(_files : PoolStringArray, _screen : int) -> void:
|
func _on_files_dropped(_files : PoolStringArray, _screen : int) -> void:
|
||||||
OpenSave.handle_loading_files(_files)
|
DrawGD.opensave.handle_loading_files(_files)
|
||||||
|
|
||||||
|
|
||||||
func load_last_project() -> void:
|
func load_last_project() -> void:
|
||||||
@ -132,7 +132,7 @@ func load_last_project() -> void:
|
|||||||
var file_path = DrawGD.config_cache.get_value("preferences", "last_project_path")
|
var file_path = DrawGD.config_cache.get_value("preferences", "last_project_path")
|
||||||
var file_check := File.new()
|
var file_check := File.new()
|
||||||
if file_check.file_exists(file_path): # If yes then load the file
|
if file_check.file_exists(file_path): # If yes then load the file
|
||||||
OpenSave.open_pxo_file(file_path)
|
DrawGD.opensave.open_pxo_file(file_path)
|
||||||
else:
|
else:
|
||||||
# If file doesn't exist on disk then warn user about this
|
# If file doesn't exist on disk then warn user about this
|
||||||
DrawGD.error_dialog.set_text("Cannot find last project file.")
|
DrawGD.error_dialog.set_text("Cannot find last project file.")
|
||||||
@ -141,12 +141,12 @@ func load_last_project() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_OpenSprite_file_selected(path : String) -> void:
|
func _on_OpenSprite_file_selected(path : String) -> void:
|
||||||
OpenSave.handle_loading_files([path])
|
DrawGD.opensave.handle_loading_files([path])
|
||||||
|
|
||||||
|
|
||||||
func _on_SaveSprite_file_selected(path : String) -> void:
|
func _on_SaveSprite_file_selected(path : String) -> void:
|
||||||
var zstd = DrawGD.save_sprites_dialog.get_vbox().get_node("ZSTDCompression").pressed
|
var zstd = DrawGD.save_sprites_dialog.get_vbox().get_node("ZSTDCompression").pressed
|
||||||
OpenSave.save_pxo_file(path, false, zstd)
|
DrawGD.opensave.save_pxo_file(path, false, zstd)
|
||||||
|
|
||||||
if is_quitting_on_save:
|
if is_quitting_on_save:
|
||||||
_on_QuitDialog_confirmed()
|
_on_QuitDialog_confirmed()
|
||||||
@ -156,7 +156,7 @@ func _on_SaveSpriteHTML5_confirmed() -> void:
|
|||||||
var file_name = DrawGD.save_sprites_html5_dialog.get_node("FileNameContainer/FileNameLineEdit").text
|
var file_name = DrawGD.save_sprites_html5_dialog.get_node("FileNameContainer/FileNameLineEdit").text
|
||||||
file_name += ".pxo"
|
file_name += ".pxo"
|
||||||
var path = "user://".plus_file(file_name)
|
var path = "user://".plus_file(file_name)
|
||||||
OpenSave.save_pxo_file(path, false, false)
|
DrawGD.opensave.save_pxo_file(path, false, false)
|
||||||
|
|
||||||
|
|
||||||
func _on_OpenSprite_popup_hide() -> void:
|
func _on_OpenSprite_popup_hide() -> void:
|
||||||
@ -194,19 +194,19 @@ func _on_QuitDialog_confirmed() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_BackupConfirmation_confirmed(project_paths : Array, backup_paths : Array) -> void:
|
func _on_BackupConfirmation_confirmed(project_paths : Array, backup_paths : Array) -> void:
|
||||||
OpenSave.reload_backup_file(project_paths, backup_paths)
|
DrawGD.opensave.reload_backup_file(project_paths, backup_paths)
|
||||||
OpenSave.autosave_timer.start()
|
DrawGD.opensave.autosave_timer.start()
|
||||||
Export.file_name = OpenSave.current_save_paths[0].get_file().trim_suffix(".pxo")
|
Export.file_name = DrawGD.opensave.current_save_paths[0].get_file().trim_suffix(".pxo")
|
||||||
Export.directory_path = OpenSave.current_save_paths[0].get_base_dir()
|
Export.directory_path = DrawGD.opensave.current_save_paths[0].get_base_dir()
|
||||||
Export.was_exported = false
|
Export.was_exported = false
|
||||||
DrawGD.file_menu.get_popup().set_item_text(3, tr("Save") + " %s" % OpenSave.current_save_paths[0].get_file())
|
DrawGD.file_menu.get_popup().set_item_text(3, tr("Save") + " %s" % DrawGD.opensave.current_save_paths[0].get_file())
|
||||||
DrawGD.file_menu.get_popup().set_item_text(5, tr("Export"))
|
DrawGD.file_menu.get_popup().set_item_text(5, tr("Export"))
|
||||||
|
|
||||||
|
|
||||||
func _on_BackupConfirmation_delete(project_paths : Array, backup_paths : Array) -> void:
|
func _on_BackupConfirmation_delete(project_paths : Array, backup_paths : Array) -> void:
|
||||||
for i in range(project_paths.size()):
|
for i in range(project_paths.size()):
|
||||||
OpenSave.remove_backup_by_path(project_paths[i], backup_paths[i])
|
DrawGD.opensave.remove_backup_by_path(project_paths[i], backup_paths[i])
|
||||||
OpenSave.autosave_timer.start()
|
DrawGD.opensave.autosave_timer.start()
|
||||||
# Reopen last project
|
# Reopen last project
|
||||||
if DrawGD.open_last_project:
|
if DrawGD.open_last_project:
|
||||||
load_last_project()
|
load_last_project()
|
||||||
|
@ -113,7 +113,7 @@ func _on_Preference_item_selected(id : int, prop : String, default_value, restor
|
|||||||
|
|
||||||
func preference_update(prop : String) -> void:
|
func preference_update(prop : String) -> void:
|
||||||
if prop in ["autosave_interval", "enable_autosave"]:
|
if prop in ["autosave_interval", "enable_autosave"]:
|
||||||
OpenSave.update_autosave()
|
DrawGD.opensave.update_autosave()
|
||||||
autosave_interval.editable = DrawGD.enable_autosave
|
autosave_interval.editable = DrawGD.enable_autosave
|
||||||
if autosave_interval.editable:
|
if autosave_interval.editable:
|
||||||
autosave_interval.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
autosave_interval.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||||
|
@ -42,18 +42,18 @@ func _on_PreviewDialog_popup_hide() -> void:
|
|||||||
|
|
||||||
func _on_PreviewDialog_confirmed() -> void:
|
func _on_PreviewDialog_confirmed() -> void:
|
||||||
if current_import_option == ImageImportOptions.NEW_TAB:
|
if current_import_option == ImageImportOptions.NEW_TAB:
|
||||||
OpenSave.open_image_as_new_tab(path, image)
|
DrawGD.opensave.open_image_as_new_tab(path, image)
|
||||||
|
|
||||||
elif current_import_option == ImageImportOptions.SPRITESHEET:
|
elif current_import_option == ImageImportOptions.SPRITESHEET:
|
||||||
OpenSave.open_image_as_spritesheet(path, image, spritesheet_horizontal, spritesheet_vertical)
|
DrawGD.opensave.open_image_as_spritesheet(path, image, spritesheet_horizontal, spritesheet_vertical)
|
||||||
|
|
||||||
elif current_import_option == ImageImportOptions.NEW_FRAME:
|
elif current_import_option == ImageImportOptions.NEW_FRAME:
|
||||||
var layer_index : int = new_frame_options.get_node("AtLayerSpinbox").value
|
var layer_index : int = new_frame_options.get_node("AtLayerSpinbox").value
|
||||||
OpenSave.open_image_as_new_frame(image, layer_index)
|
DrawGD.opensave.open_image_as_new_frame(image, layer_index)
|
||||||
|
|
||||||
elif current_import_option == ImageImportOptions.NEW_LAYER:
|
elif current_import_option == ImageImportOptions.NEW_LAYER:
|
||||||
var frame_index : int = new_layer_options.get_node("AtFrameSpinbox").value - 1
|
var frame_index : int = new_layer_options.get_node("AtFrameSpinbox").value - 1
|
||||||
OpenSave.open_image_as_new_layer(image, path.get_basename().get_file(), frame_index)
|
DrawGD.opensave.open_image_as_new_layer(image, path.get_basename().get_file(), frame_index)
|
||||||
|
|
||||||
elif current_import_option == ImageImportOptions.PALETTE:
|
elif current_import_option == ImageImportOptions.PALETTE:
|
||||||
DrawGD.palette_container.import_image_palette(path, image)
|
DrawGD.palette_container.import_image_palette(path, image)
|
||||||
|
@ -24,20 +24,20 @@ func _on_Tabs_reposition_active_tab_request(idx_to : int) -> void:
|
|||||||
DrawGD.projects.insert(idx_to, temp)
|
DrawGD.projects.insert(idx_to, temp)
|
||||||
|
|
||||||
# Change save paths
|
# Change save paths
|
||||||
var temp_save_path = OpenSave.current_save_paths[DrawGD.current_project_index]
|
var temp_save_path = DrawGD.opensave.current_save_paths[DrawGD.current_project_index]
|
||||||
OpenSave.current_save_paths[DrawGD.current_project_index] = OpenSave.current_save_paths[idx_to]
|
DrawGD.opensave.current_save_paths[DrawGD.current_project_index] = DrawGD.opensave.current_save_paths[idx_to]
|
||||||
OpenSave.current_save_paths[idx_to] = temp_save_path
|
DrawGD.opensave.current_save_paths[idx_to] = temp_save_path
|
||||||
var temp_backup_path = OpenSave.backup_save_paths[DrawGD.current_project_index]
|
var temp_backup_path = DrawGD.opensave.backup_save_paths[DrawGD.current_project_index]
|
||||||
OpenSave.backup_save_paths[DrawGD.current_project_index] = OpenSave.backup_save_paths[idx_to]
|
DrawGD.opensave.backup_save_paths[DrawGD.current_project_index] = DrawGD.opensave.backup_save_paths[idx_to]
|
||||||
OpenSave.backup_save_paths[idx_to] = temp_backup_path
|
DrawGD.opensave.backup_save_paths[idx_to] = temp_backup_path
|
||||||
|
|
||||||
|
|
||||||
func delete_tab(tab : int) -> void:
|
func delete_tab(tab : int) -> void:
|
||||||
remove_tab(tab)
|
remove_tab(tab)
|
||||||
DrawGD.projects[tab].undo_redo.free()
|
DrawGD.projects[tab].undo_redo.free()
|
||||||
OpenSave.remove_backup(tab)
|
DrawGD.opensave.remove_backup(tab)
|
||||||
OpenSave.current_save_paths.remove(tab)
|
DrawGD.opensave.current_save_paths.remove(tab)
|
||||||
OpenSave.backup_save_paths.remove(tab)
|
DrawGD.opensave.backup_save_paths.remove(tab)
|
||||||
DrawGD.projects.remove(tab)
|
DrawGD.projects.remove(tab)
|
||||||
if tab > 0:
|
if tab > 0:
|
||||||
DrawGD.current_project_index -= 1
|
DrawGD.current_project_index -= 1
|
||||||
|
@ -155,7 +155,7 @@ func on_open_last_project_file_menu_option_pressed() -> void:
|
|||||||
|
|
||||||
func save_project_file() -> void:
|
func save_project_file() -> void:
|
||||||
DrawGD.control.is_quitting_on_save = false
|
DrawGD.control.is_quitting_on_save = false
|
||||||
var path = OpenSave.current_save_paths[DrawGD.current_project_index]
|
var path = DrawGD.opensave.current_save_paths[DrawGD.current_project_index]
|
||||||
if path == "":
|
if path == "":
|
||||||
if OS.get_name() == "HTML5":
|
if OS.get_name() == "HTML5":
|
||||||
DrawGD.save_sprites_html5_dialog.popup_centered()
|
DrawGD.save_sprites_html5_dialog.popup_centered()
|
||||||
|
Loading…
Reference in New Issue
Block a user