diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index bb8dcd207..98444e866 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -641,10 +641,6 @@ var cel_button_scene: PackedScene = load("res://src/UI/Timeline/CelButton.tscn") ## The patterns popup dialog used to display patterns ## It has the [param PatternsPopup.gd] script attached. @onready var patterns_popup: Popup = control.find_child("PatternsPopup") -## Dialog used to navigate and open images and projects. -@onready var open_sprites_dialog: FileDialog = control.find_child("OpenSprite") -## Dialog used to save (.pxo) projects. -@onready var save_sprites_dialog: FileDialog = control.find_child("SaveSprite") ## Dialog used to export images. It has the [param ExportDialog.gd] script attached. @onready var export_dialog: AcceptDialog = control.find_child("ExportDialog") ## An error dialog to show errors. diff --git a/src/Autoload/OpenSave.gd b/src/Autoload/OpenSave.gd index 037fe503c..466c9275e 100644 --- a/src/Autoload/OpenSave.gd +++ b/src/Autoload/OpenSave.gd @@ -276,7 +276,6 @@ func open_pxo_file(path: String, is_backup := false, replace_empty := true) -> v # Loading a backup should not change window title and save path new_project.save_path = path get_window().title = new_project.name + " - Pixelorama " + Global.current_version - Global.save_sprites_dialog.current_path = path # Set last opened project path and save Global.config_cache.set_value("data", "current_dir", path.get_base_dir()) Global.config_cache.set_value("data", "last_project_path", path) diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index bb75514e3..fbfee1362 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -203,9 +203,6 @@ func change_project() -> void: Global.get_window().title = "%s - Pixelorama %s" % [name, Global.current_version] if has_changed: Global.get_window().title = Global.get_window().title + "(*)" - if export_directory_path != "": - Global.open_sprites_dialog.current_path = export_directory_path - Global.save_sprites_dialog.current_path = export_directory_path selection_map_changed() diff --git a/src/Main.gd b/src/Main.gd index 982e197df..521bbde1f 100644 --- a/src/Main.gd +++ b/src/Main.gd @@ -18,6 +18,9 @@ var splash_dialog: AcceptDialog: @onready var main_ui := $MenuAndUI/UI/DockableContainer as DockableContainer @onready var backup_confirmation: ConfirmationDialog = $Dialogs/BackupConfirmation +## Dialog used to open images and project (.pxo) files. +@onready var open_sprite_dialog := $Dialogs/OpenSprite as FileDialog +## Dialog used to save project (.pxo) files. @onready var save_sprite_dialog := $Dialogs/SaveSprite as FileDialog @onready var save_sprite_html5: ConfirmationDialog = $Dialogs/SaveSpriteHTML5 @onready var tile_mode_offsets_dialog: ConfirmationDialog = $Dialogs/TileModeOffsetsDialog @@ -157,6 +160,7 @@ some useful [SYSTEM OPTIONS] are: func _init() -> void: + Global.project_switched.connect(_project_switched) if not DirAccess.dir_exists_absolute("user://backups"): DirAccess.make_dir_recursive_absolute("user://backups") Global.shrink = _get_auto_display_scale() @@ -177,7 +181,7 @@ func _ready() -> void: quit_and_save_dialog.add_button("Exit without saving", false, "ExitWithoutSaving") - Global.open_sprites_dialog.current_dir = Global.config_cache.get_value( + open_sprite_dialog.current_dir = Global.config_cache.get_value( "data", "current_dir", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP) ) save_sprite_dialog.current_dir = Global.config_cache.get_value( @@ -203,6 +207,12 @@ func _input(event: InputEvent) -> void: get_viewport().gui_get_focus_owner().release_focus() +func _project_switched() -> void: + if Global.current_project.export_directory_path != "": + open_sprite_dialog.current_path = Global.current_project.export_directory_path + save_sprite_dialog.current_path = Global.current_project.export_directory_path + + # Taken from https://github.com/godotengine/godot/blob/3.x/editor/editor_settings.cpp#L1474 func _get_auto_display_scale() -> float: if OS.get_name() == "macOS": @@ -462,7 +472,7 @@ func save_project(path: String) -> void: ] var success := OpenSave.save_pxo_file(path, false, include_blended, project_to_save) if success: - Global.open_sprites_dialog.current_dir = path.get_base_dir() + open_sprite_dialog.current_dir = path.get_base_dir() if is_quitting_on_save: changed_projects_on_quit.pop_front() _save_on_quit_confirmation() diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index 5c591495f..a26b9acaa 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -3,7 +3,7 @@ extends Panel signal animation_started(forward: bool) signal animation_finished -enum LoopType {NO, CYCLE, PINGPONG} +enum LoopType { NO, CYCLE, PINGPONG } const FRAME_BUTTON_TSCN := preload("res://src/UI/Timeline/FrameButton.tscn") const LAYER_FX_SCENE_PATH := "res://src/UI/Timeline/LayerEffects/LayerEffectsSettings.tscn" diff --git a/src/UI/TopMenuContainer/TopMenuContainer.gd b/src/UI/TopMenuContainer/TopMenuContainer.gd index 9b3c6534a..f27505ef1 100644 --- a/src/UI/TopMenuContainer/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer/TopMenuContainer.gd @@ -535,7 +535,7 @@ func _open_project_file() -> void: if OS.get_name() == "Web": Html5FileExchange.load_image() else: - _popup_dialog(Global.open_sprites_dialog) + _popup_dialog(Global.control.open_sprite_dialog) Global.control.opensprite_file_selected = false