Browse Source

tools: pass ProjectStore instead of Project

It'll become useful in later commits.
Daniele Bartolini 1 year ago
parent
commit
b607413aa2

+ 4 - 1
tools/level_editor/level_editor.vala

@@ -2413,7 +2413,10 @@ public class LevelEditorApplication : Gtk.Application
 	{
 		string? destination_dir = param == null ? null : param.get_string();
 
-		ImportResult ec = _project.import(destination_dir, on_import_result, this.active_window);
+		ImportResult ec = _project.import(destination_dir
+			, on_import_result
+			, _project_store
+			);
 		if (ec != ImportResult.CALLBACK)
 			on_import_result(ec);
 	}

+ 11 - 5
tools/level_editor/project.vala

@@ -19,7 +19,11 @@ public class Project
 {
 	public const string LEVEL_EDITOR_TEST_NAME = "_level_editor_test";
 
-	public delegate ImportResult ImporterDelegate(Project project, string destination_dir, SList<string> filenames, Import import_result);
+	public delegate ImportResult ImporterDelegate(ProjectStore project_store
+		, string destination_dir
+		, SList<string> filenames
+		, Import import_result
+		);
 
 	[Compact]
 	public struct ImporterData
@@ -518,8 +522,10 @@ public class Project
 		return Path.build_filename(prefix, resource_path);
 	}
 
-	public static ImportResult import_all_extensions(Project project, string destination_dir, SList<string> filenames, Import import_result)
+	public static ImportResult import_all_extensions(ProjectStore project_store, string destination_dir, SList<string> filenames, Import import_result)
 	{
+		Project project = project_store._project;
+
 		Gee.ArrayList<string> paths = new Gee.ArrayList<string>();
 		foreach (var item in filenames)
 			paths.add(item);
@@ -559,7 +565,7 @@ public class Project
 			foreach (var item in importables)
 				importables_list.append(item);
 
-			result = importer.delegate(project, destination_dir, importables_list, import_result);
+			result = importer.delegate(project_store, destination_dir, importables_list, import_result);
 		}
 
 		return result;
@@ -647,7 +653,7 @@ public class Project
 		return find_importer_for_extension(type) != null;
 	}
 
-	public ImportResult import(string? destination_dir, Import import_result, Gtk.Window? parent_window = null)
+	public ImportResult import(string? destination_dir, Import import_result, ProjectStore project_store, Gtk.Window? parent_window = null)
 	{
 		Gtk.FileChooserDialog src = new Gtk.FileChooserDialog("Import..."
 			, parent_window
@@ -708,7 +714,7 @@ public class Project
 		if (importer == null)
 			importer = _all_extensions_importer_data.delegate;
 
-		return importer(this, out_dir, filenames, import_result);
+		return importer(project_store, out_dir, filenames, import_result);
 	}
 
 	public void delete_tree(GLib.File file) throws Error

+ 2 - 1
tools/resource/font_resource.vala

@@ -7,8 +7,9 @@ namespace Crown
 {
 public class FontResource
 {
-	public static ImportResult import(Project project, string destination_dir, SList<string> filenames)
+	public static ImportResult import(ProjectStore project_store, string destination_dir, SList<string> filenames)
 	{
+		Project project = project_store._project;
 		Hashtable importer_settings = null;
 		string importer_settings_path = null;
 		string font_path;

+ 6 - 4
tools/resource/mesh_resource.vala

@@ -87,8 +87,10 @@ namespace MeshResource
 		}
 	}
 
-	public static ImportResult do_import(Project project, string destination_dir, SList<string> filenames)
+	public static ImportResult do_import(ProjectStore project_store, string destination_dir, SList<string> filenames)
 	{
+		Project project = project_store._project;
+
 		foreach (unowned string filename_i in filenames) {
 			GLib.File file_src = File.new_for_path(filename_i);
 
@@ -198,7 +200,7 @@ namespace MeshResource
 		return ImportResult.SUCCESS;
 	}
 
-	public static ImportResult import(Project project, string destination_dir, SList<string> filenames, Import import_result)
+	public static ImportResult import(ProjectStore project_store, string destination_dir, SList<string> filenames, Import import_result)
 	{
 		SList<string> fbx_filenames = new SList<string>();
 		SList<string> mesh_filenames = new SList<string>();
@@ -214,9 +216,9 @@ namespace MeshResource
 
 		ImportResult res = ImportResult.SUCCESS;
 		if (mesh_filenames != null)
-			res = MeshResource.do_import(project, destination_dir, mesh_filenames);
+			res = MeshResource.do_import(project_store, destination_dir, mesh_filenames);
 		if (res == ImportResult.SUCCESS && fbx_filenames != null)
-			res = FBXImporter.import(project, destination_dir, fbx_filenames, import_result);
+			res = FBXImporter.import(project_store, destination_dir, fbx_filenames, import_result);
 		return res;
 	}
 

+ 4 - 4
tools/resource/mesh_resource_fbx.vala

@@ -161,9 +161,9 @@ public class FBXImportDialog : Gtk.Window
 	public Gtk.Button _cancel;
 	public Gtk.HeaderBar _header_bar;
 
-	public FBXImportDialog(Project project, string destination_dir, GLib.SList<string> filenames, Import import_result)
+	public FBXImportDialog(ProjectStore project_store, string destination_dir, GLib.SList<string> filenames, Import import_result)
 	{
-		_project = project;
+		_project = project_store._project;
 		_destination_dir = destination_dir;
 		_filenames = new Gee.ArrayList<string>();
 		foreach (var f in filenames)
@@ -621,9 +621,9 @@ public class FBXImporter
 		return ImportResult.SUCCESS;
 	}
 
-	public static ImportResult import(Project project, string destination_dir, GLib.SList<string> filenames, Import import_result)
+	public static ImportResult import(ProjectStore project_store, string destination_dir, GLib.SList<string> filenames, Import import_result)
 	{
-		FBXImportDialog dialog = new FBXImportDialog(project, destination_dir, filenames, import_result);
+		FBXImportDialog dialog = new FBXImportDialog(project_store, destination_dir, filenames, import_result);
 		dialog.show_all();
 		dialog.present();
 		return ImportResult.CALLBACK;

+ 3 - 1
tools/resource/sound_resource.vala

@@ -9,8 +9,10 @@ namespace Crown
 {
 public class SoundResource
 {
-	public static ImportResult import(Project project, string destination_dir, SList<string> filenames)
+	public static ImportResult import(ProjectStore project_store, string destination_dir, SList<string> filenames)
 	{
+		Project project = project_store._project;
+
 		foreach (unowned string filename_i in filenames) {
 			GLib.File file_src = File.new_for_path(filename_i);
 

+ 2 - 1
tools/resource/sprite_resource.vala

@@ -7,8 +7,9 @@ namespace Crown
 {
 public class SpriteResource
 {
-	public static ImportResult import(Project project, string destination_dir, SList<string> filenames)
+	public static ImportResult import(ProjectStore project_store, string destination_dir, SList<string> filenames)
 	{
+		Project project = project_store._project;
 		Hashtable importer_settings = null;
 		string importer_settings_path = null;
 		string image_path;

+ 3 - 1
tools/resource/texture_resource.vala

@@ -98,8 +98,10 @@ public struct TextureResource
 		_db.save(project.absolute_path(resource_name) + ".texture", _id);
 	}
 
-	public static ImportResult import(Project project, string destination_dir, SList<string> filenames)
+	public static ImportResult import(ProjectStore project_store, string destination_dir, SList<string> filenames)
 	{
+		Project project = project_store._project;
+
 		foreach (unowned string filename_i in filenames) {
 			GLib.File file_src = File.new_for_path(filename_i);