From c84c6a19d746e94de561d08b3354f0896a2bf850 Mon Sep 17 00:00:00 2001
From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com>
Date: Sat, 30 May 2020 00:28:17 +0300
Subject: [PATCH] Renamed handle_running_pixelorama_with_arguments() to
handle_loading_files()
handle_loading_files() is also used for _on_files_dropped()
---
CHANGELOG.md | 1 +
src/Main.gd | 34 ++++++++++++++--------------------
2 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5572e796b..a5353a5ff 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ Igor Santarek (jegor377)
### Added
- Ability to remove the current palette
+- You can now drag & drop files into the program while it's running to open them.
## [v0.7] - 2020-05-16
diff --git a/src/Main.gd b/src/Main.gd
index 1f37c9e3b..caaef5107 100644
--- a/src/Main.gd
+++ b/src/Main.gd
@@ -40,7 +40,10 @@ func _ready() -> void:
handle_backup()
- handle_running_pixelorama_with_arguments()
+ # If the user wants to run Pixelorama with arguments in terminal mode
+ # or open files with Pixelorama directly, then handle that
+ if OS.get_cmdline_args():
+ handle_loading_files(OS.get_cmdline_args())
get_tree().connect("files_dropped", self, "_on_files_dropped")
@@ -219,25 +222,7 @@ func handle_backup() -> void:
load_last_project()
-func handle_running_pixelorama_with_arguments() -> void:
- # If user want to run Pixelorama with arguments in terminal mode then handle that
- if OS.get_cmdline_args():
- for arg in OS.get_cmdline_args():
- if arg.get_extension().to_lower() == "pxo":
- _on_OpenSprite_file_selected(arg)
- else:
- if arg == OS.get_cmdline_args()[0]:
- $ImportSprites.new_frame = false
- $ImportSprites._on_ImportSprites_files_selected([arg])
- $ImportSprites.new_frame = true
-
-
-func _notification(what : int) -> void:
- if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit
- show_quit_dialog()
-
-
-func _on_files_dropped(files : PoolStringArray, screen : int) -> void:
+func handle_loading_files(files : PoolStringArray) -> void:
for file in files:
if file.get_extension().to_lower() == "pxo":
_on_OpenSprite_file_selected(file)
@@ -248,6 +233,15 @@ func _on_files_dropped(files : PoolStringArray, screen : int) -> void:
$ImportSprites.new_frame = true
+func _notification(what : int) -> void:
+ if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit
+ show_quit_dialog()
+
+
+func _on_files_dropped(files : PoolStringArray, _screen : int) -> void:
+ handle_loading_files(files)
+
+
func on_new_project_file_menu_option_pressed(id : int) -> void:
if Global.project_has_changed:
unsaved_canvas_state = id