瀏覽代碼

Quick open now can open multiple scenes and scripts

Franklin Sobrinho 9 年之前
父節點
當前提交
7fa3bd4e78
共有 4 個文件被更改,包括 50 次插入15 次删除
  1. 17 10
      tools/editor/editor_node.cpp
  2. 1 1
      tools/editor/editor_node.h
  3. 28 3
      tools/editor/quick_open.cpp
  4. 4 1
      tools/editor/quick_open.h

+ 17 - 10
tools/editor/editor_node.cpp

@@ -2076,21 +2076,21 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
 		} break;
 		case FILE_QUICK_OPEN_SCENE: {
 
-			quick_open->popup("PackedScene");
+			quick_open->popup("PackedScene", true);
 			quick_open->set_title("Quick Open Scene..");
 
 		} break;
 		case FILE_QUICK_OPEN_SCRIPT: {
 
 
-			quick_open->popup("Script");
+			quick_open->popup("Script", true);
 			quick_open->set_title("Quick Open Script..");
 
 		} break;
 		case FILE_QUICK_OPEN_FILE: {
 
 
-			quick_open->popup("Resource",false,true);
+			quick_open->popup("Resource", false, true);
 			quick_open->set_title("Quick Search File..");
 
 		} break;
@@ -3927,19 +3927,26 @@ void EditorNode::hide_animation_player_editors() {
 	emit_signal("hide_animation_player_editors");
 }
 
-void EditorNode::_quick_opened(const String& p_resource) {
+void EditorNode::_quick_opened() {
 
 	if (current_option==FILE_QUICK_OPEN_FILE) {
-		scenes_dock->open(p_resource);
+		String res_path = quick_open->get_selected();
+
+		scenes_dock->open(res_path);
 		return;
 	}
 
-	if (quick_open->get_base_type()=="PackedScene") {
-		open_request(p_resource);
-	} else {
-		load_resource(p_resource);
-	}
+	Vector<String> files = quick_open->get_selected_files();
+
+	for (int i = 0; i < files.size(); i++) {
+		String res_path = files[i];
 
+		if (quick_open->get_base_type()=="PackedScene") {
+			open_request(res_path);
+		} else {
+			load_resource(res_path);
+		}
+	}
 }
 
 void EditorNode::_quick_run(const String& p_resource) {

+ 1 - 1
tools/editor/editor_node.h

@@ -440,7 +440,7 @@ class EditorNode : public Node {
 
 	void _update_keying();
 	void _hide_top_editors();
-	void _quick_opened(const String& p_resource);
+	void _quick_opened();
 	void _quick_run(const String& p_resource);
 
 	void _run(bool p_current=false, const String &p_custom="");

+ 28 - 3
tools/editor/quick_open.cpp

@@ -30,7 +30,7 @@
 #include "os/keyboard.h"
 
 
-void EditorQuickOpen::popup(const StringName &p_base, bool p_dontclear, bool p_add_dirs) {
+void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) {
 
 	add_directories=p_add_dirs;
 	popup_centered_ratio(0.6);
@@ -38,13 +38,38 @@ void EditorQuickOpen::popup(const StringName &p_base, bool p_dontclear, bool p_a
 		search_box->select_all();
 	else
 		search_box->clear();
+	if (p_enable_multi)
+		search_options->set_select_mode(Tree::SELECT_MULTI);
+	else
+		search_options->set_select_mode(Tree::SELECT_SINGLE);
 	search_box->grab_focus();
 	base_type=p_base;
 	_update_search();
+}
+
+String EditorQuickOpen::get_selected() const {
 
+	TreeItem *ti = search_options->get_selected();
+	if (!ti)
+		return String();
 
+	return "res://" + ti->get_text(0);
 }
 
+Vector<String> EditorQuickOpen::get_selected_files() const {
+
+	Vector<String> files;
+
+	TreeItem* item = search_options->get_next_selected(search_options->get_root());
+	while (item) {
+
+		files.push_back("res://"+item->get_text(0));
+
+		item = search_options->get_next_selected(item);
+	}
+
+	return files;
+}
 
 void EditorQuickOpen::_text_changed(const String& p_newtext) {
 
@@ -132,7 +157,7 @@ void EditorQuickOpen::_confirmed() {
 	TreeItem *ti = search_options->get_selected();
 	if (!ti)
 		return;
-	emit_signal("quick_open","res://"+ti->get_text(0));
+	emit_signal("quick_open");
 	hide();
 }
 
@@ -156,7 +181,7 @@ void EditorQuickOpen::_bind_methods() {
 	ObjectTypeDB::bind_method(_MD("_confirmed"),&EditorQuickOpen::_confirmed);
 	ObjectTypeDB::bind_method(_MD("_sbox_input"),&EditorQuickOpen::_sbox_input);
 
-	ADD_SIGNAL(MethodInfo("quick_open",PropertyInfo(Variant::STRING,"respath")));
+	ADD_SIGNAL(MethodInfo("quick_open"));
 
 }
 

+ 4 - 1
tools/editor/quick_open.h

@@ -61,7 +61,10 @@ public:
 
 	StringName get_base_type() const;
 
-	void popup(const StringName& p_base,bool p_dontclear=false,bool p_add_dirs=false);
+	String get_selected() const;
+	Vector<String> get_selected_files() const;
+
+	void popup(const StringName& p_base,bool p_enable_multi=false,bool p_add_dirs=false,bool p_dontclear=false);
 	EditorQuickOpen();
 };