From 174b9a5f9e2382508df320f6ee1188fd3572c44b Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Thu, 17 Mar 2016 12:30:13 +0800 Subject: [PATCH 1/2] Allow select multiple files in ResourcePreloaderEditor --- .../resource_preloader_editor_plugin.cpp | 62 ++++++++++--------- .../resource_preloader_editor_plugin.h | 2 +- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.cpp b/tools/editor/plugins/resource_preloader_editor_plugin.cpp index 442046b069e..5b9a096c776 100644 --- a/tools/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/tools/editor/plugins/resource_preloader_editor_plugin.cpp @@ -60,36 +60,40 @@ void ResourcePreloaderEditor::_notification(int p_what) { } } -void ResourcePreloaderEditor::_file_load_request(const String& p_path) { +void ResourcePreloaderEditor::_files_load_request(const Vector& p_path) { + + for(int i=0;iset_text("ERROR: Couldn't load resource!"); + dialog->set_title("Error!"); + //dialog->get_cancel()->set_text("Close"); + dialog->get_ok()->set_text("Close"); + dialog->popup_centered_minsize(); + return; ///beh should show an error i guess + } - RES resource; + String basename = path.get_file().basename(); + String name=basename; + int counter=1; + while(preloader->has_resource(name)) { + counter++; + name=basename+" "+itos(counter); + } - resource = ResourceLoader::load(p_path); - - if (resource.is_null()) { - dialog->set_text("ERROR: Couldn't load resource!"); - dialog->set_title("Error!"); - //dialog->get_cancel()->set_text("Close"); - dialog->get_ok()->set_text("Close"); - dialog->popup_centered_minsize(); - return; ///beh should show an error i guess + undo_redo->create_action("Add Resource"); + undo_redo->add_do_method(preloader,"add_resource",name,resource); + undo_redo->add_undo_method(preloader,"remove_resource",name); + undo_redo->add_do_method(this,"_update_library"); + undo_redo->add_undo_method(this,"_update_library"); + undo_redo->commit_action(); } - - String basename = p_path.get_file().basename(); - String name=basename; - int counter=1; - while(preloader->has_resource(name)) { - counter++; - name=basename+" "+itos(counter); - } - - undo_redo->create_action("Add Resource"); - undo_redo->add_do_method(preloader,"add_resource",name,resource); - undo_redo->add_undo_method(preloader,"remove_resource",name); - undo_redo->add_do_method(this,"_update_library"); - undo_redo->add_undo_method(this,"_update_library"); - undo_redo->commit_action(); } void ResourcePreloaderEditor::_load_pressed() { @@ -102,7 +106,7 @@ void ResourcePreloaderEditor::_load_pressed() { for(int i=0;iadd_filter("*."+extensions[i]); - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file->set_mode(EditorFileDialog::MODE_OPEN_FILES); file->popup_centered_ratio(); @@ -283,7 +287,7 @@ void ResourcePreloaderEditor::_bind_methods() { ObjectTypeDB::bind_method(_MD("_delete_pressed"),&ResourcePreloaderEditor::_delete_pressed); ObjectTypeDB::bind_method(_MD("_paste_pressed"),&ResourcePreloaderEditor::_paste_pressed); ObjectTypeDB::bind_method(_MD("_delete_confirm_pressed"),&ResourcePreloaderEditor::_delete_confirm_pressed); - ObjectTypeDB::bind_method(_MD("_file_load_request"),&ResourcePreloaderEditor::_file_load_request); + ObjectTypeDB::bind_method(_MD("_files_load_request"),&ResourcePreloaderEditor::_files_load_request); ObjectTypeDB::bind_method(_MD("_update_library"),&ResourcePreloaderEditor::_update_library); } @@ -330,7 +334,7 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() { load->connect("pressed", this,"_load_pressed"); _delete->connect("pressed", this,"_delete_pressed"); paste->connect("pressed", this,"_paste_pressed"); - file->connect("file_selected", this,"_file_load_request"); + file->connect("files_selected", this,"_files_load_request"); //dialog->connect("confirmed", this,"_delete_confirm_pressed"); tree->connect("item_edited", this,"_item_edited"); loading_scene=false; diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.h b/tools/editor/plugins/resource_preloader_editor_plugin.h index 53436797a9e..756fefeb040 100644 --- a/tools/editor/plugins/resource_preloader_editor_plugin.h +++ b/tools/editor/plugins/resource_preloader_editor_plugin.h @@ -58,7 +58,7 @@ class ResourcePreloaderEditor : public PanelContainer { void _load_pressed(); void _load_scene_pressed(); - void _file_load_request(const String& p_path); + void _files_load_request(const Vector& p_path); void _paste_pressed(); void _delete_pressed(); void _delete_confirm_pressed(); From e13e343c9ceac6be272347f5aba5e3fc59d63fba Mon Sep 17 00:00:00 2001 From: sanikoyes Date: Fri, 18 Mar 2016 18:26:02 +0800 Subject: [PATCH 2/2] Rename path to paths --- tools/editor/plugins/resource_preloader_editor_plugin.cpp | 6 +++--- tools/editor/plugins/resource_preloader_editor_plugin.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.cpp b/tools/editor/plugins/resource_preloader_editor_plugin.cpp index 5b9a096c776..0459ed85bda 100644 --- a/tools/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/tools/editor/plugins/resource_preloader_editor_plugin.cpp @@ -60,11 +60,11 @@ void ResourcePreloaderEditor::_notification(int p_what) { } } -void ResourcePreloaderEditor::_files_load_request(const Vector& p_path) { +void ResourcePreloaderEditor::_files_load_request(const Vector& p_paths) { - for(int i=0;i& p_path); + void _files_load_request(const Vector& p_paths); void _paste_pressed(); void _delete_pressed(); void _delete_confirm_pressed();