Skip to content

Commit

Permalink
Always open the import dialog when opening images from File > Open
Browse files Browse the repository at this point in the history
  • Loading branch information
OverloadedOrama committed Feb 9, 2025
1 parent 0ae1cb3 commit c7c79f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/Autoload/OpenSave.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func _ready() -> void:
update_autosave()


func handle_loading_file(file: String) -> void:
func handle_loading_file(file: String, force_import_dialog_on_images := false) -> void:
file = file.replace("\\", "/")
var file_ext := file.get_extension().to_lower()
if file_ext == "pxo": # Pixelorama project file
Expand Down Expand Up @@ -74,7 +74,7 @@ func handle_loading_file(file: String) -> void:
var file_name: String = file.get_file()
Global.popup_error(tr("Can't load file '%s'.") % [file_name])
return
handle_loading_image(file, image)
handle_loading_image(file, image, force_import_dialog_on_images)


func add_import_option(import_name: StringName, import_scene: PackedScene) -> int:
Expand Down Expand Up @@ -118,8 +118,12 @@ func load_image_from_buffer(buffer: PackedByteArray) -> Image:
return image


func handle_loading_image(file: String, image: Image) -> void:
if Global.projects.size() <= 1 and Global.current_project.is_empty():
func handle_loading_image(file: String, image: Image, force_import_dialog := false) -> void:
if (
Global.projects.size() <= 1
and Global.current_project.is_empty()
and not force_import_dialog
):
open_image_as_new_tab(file, image)
return
var preview_dialog := preview_dialog_tscn.instantiate() as ImportPreviewDialog
Expand Down
2 changes: 1 addition & 1 deletion src/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func load_recent_project_file(path: String) -> void:

func _on_OpenSprite_files_selected(paths: PackedStringArray) -> void:
for path in paths:
OpenSave.handle_loading_file(path)
OpenSave.handle_loading_file(path, true)
save_sprite_dialog.current_dir = paths[0].get_base_dir()


Expand Down

0 comments on commit c7c79f9

Please sign in to comment.