Quellcode durchsuchen

tools: empty destination dir is a valid dir

This should be better handled with a "maybe variant" I guess.
Unfortunately though, putting "ms" as parameter_type to the
"import" action causes the editor to close on startup.

Fixes: #174
Daniele Bartolini vor 1 Jahr
Ursprung
Commit
7362fb9b1a

+ 1 - 0
docs/changelog.rst

@@ -28,6 +28,7 @@ Changelog
 * Fixed mouse click in the Editor View not selecting the correct sprite in some circumnstances.
 * Added the ability to drag & drop units from the ProjectBrowser to the EditorView.
 * Added thumbnails for .unit, .material, .texture and .sound resources in the Project Browser.
+* Fixed importing resources in the source directory's root asking for destination directory.
 
 **Lua API**
 

+ 3 - 2
tools/level_editor/level_editor.vala

@@ -330,6 +330,7 @@ public class LevelEditorApplication : Gtk.Application
 		{ "save",          on_save,          null, null },
 		{ "save-as",       on_save_as,       null, null },
 		{ "import",        on_import,        "s",  null },
+		{ "import-null",   on_import,        null, null },
 		{ "preferences",   on_preferences,   null, null },
 		{ "deploy",        on_deploy,        null, null },
 		{ "close",         on_close,         null, null },
@@ -2048,9 +2049,9 @@ public class LevelEditorApplication : Gtk.Application
 
 	private void on_import(GLib.SimpleAction action, GLib.Variant? param)
 	{
-		string destination_dir = param.get_string();
+		string? destination_dir = param == null ? null : param.get_string();
 
-		ImportResult ec = _project.import(destination_dir != "" ? destination_dir : null, this.active_window);
+		ImportResult ec = _project.import(destination_dir, this.active_window);
 		if (ec == ImportResult.ERROR) {
 			loge("Failed to import resource(s)");
 			return;

+ 1 - 2
tools/level_editor/resources/gtk/menus.ui

@@ -39,8 +39,7 @@
       <section>
         <item>
           <attribute name="label" translatable="yes">Import...</attribute>
-          <attribute name="action">app.import</attribute>
-          <attribute name="target"></attribute>
+          <attribute name="action">app.import-null</attribute>
           <attribute name="accel">&lt;Primary&gt;I</attribute>
         </item>
       </section>