From 03813b41c57131efb84b244b09c3e34d52af4e25 Mon Sep 17 00:00:00 2001 From: Variable <77773850+Variable-ind@users.noreply.github.com> Date: Tue, 20 Sep 2022 22:28:35 +0500 Subject: [PATCH] Remember last choice in import options (#754) * Remember last choice in import options Implements 2nd point of "Minor UX improvements #735" * formatting --- src/Autoload/OpenSave.gd | 1 + src/UI/Dialogs/PreviewDialog.gd | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/Autoload/OpenSave.gd b/src/Autoload/OpenSave.gd index 7a554f0b7..5107ab42d 100644 --- a/src/Autoload/OpenSave.gd +++ b/src/Autoload/OpenSave.gd @@ -5,6 +5,7 @@ var current_save_paths := [] # Array of strings var backup_save_paths := [] # Array of strings var preview_dialog_tscn = preload("res://src/UI/Dialogs/PreviewDialog.tscn") var preview_dialogs := [] # Array of preview dialogs +var last_dialog_option: int = 0 onready var autosave_timer: Timer diff --git a/src/UI/Dialogs/PreviewDialog.gd b/src/UI/Dialogs/PreviewDialog.gd index 14ac0e10c..63f200442 100644 --- a/src/UI/Dialogs/PreviewDialog.gd +++ b/src/UI/Dialogs/PreviewDialog.gd @@ -53,6 +53,10 @@ func _on_PreviewDialog_about_to_show() -> void: import_options.add_item("New brush") import_options.add_item("New pattern") + # Select the option that the preview dialog before it had selected + import_options.select(OpenSave.last_dialog_option) + import_options.emit_signal("item_selected", OpenSave.last_dialog_option) + var img_texture := ImageTexture.new() img_texture.create_from_image(image, 0) texture_rect.texture = img_texture @@ -227,6 +231,7 @@ func synchronize() -> void: func _on_ImportOption_item_selected(id: int) -> void: current_import_option = id + OpenSave.last_dialog_option = current_import_option frame_size_label.visible = false spritesheet_tab_options.visible = false spritesheet_lay_opt.visible = false