summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/editor_node.cpp10
-rw-r--r--tools/editor/editor_node.h3
-rw-r--r--tools/editor/filesystem_dock.cpp10
-rw-r--r--tools/editor/scene_tree_dock.cpp25
-rw-r--r--tools/editor/scene_tree_dock.h4
5 files changed, 42 insertions, 10 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 8b55e73ee7..30b89cacc5 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -3822,6 +3822,11 @@ void EditorNode::request_instance_scene(const String &p_path) {
}
+void EditorNode::request_instance_scenes(const Vector<String>& p_files) {
+
+ scene_tree_dock->instance_scenes(p_files);
+}
+
FileSystemDock *EditorNode::get_scenes_dock() {
return scenes_dock;
@@ -3831,10 +3836,9 @@ SceneTreeDock *EditorNode::get_scene_tree_dock() {
return scene_tree_dock;
}
-void EditorNode::_instance_request(const String& p_path){
-
+void EditorNode::_instance_request(const Vector<String>& p_files) {
- request_instance_scene(p_path);
+ request_instance_scenes(p_files);
}
void EditorNode::_property_keyed(const String& p_keyed,const Variant& p_value,bool p_advance) {
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index 9a227d3644..793c148671 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -452,7 +452,7 @@ private:
void _save_scene(String p_file, int idx = -1);
- void _instance_request(const String& p_path);
+ void _instance_request(const Vector<String>& p_files);
void _property_keyed(const String& p_keyed, const Variant& p_value, bool p_advance);
void _transform_keyed(Object *sp,const String& p_sub,const Transform& p_key);
@@ -666,6 +666,7 @@ public:
static VSplitContainer *get_top_split() { return singleton->top_split; }
void request_instance_scene(const String &p_path);
+ void request_instance_scenes(const Vector<String>& p_files);
FileSystemDock *get_scenes_dock();
SceneTreeDock *get_scene_tree_dock();
static UndoRedo* get_undo_redo() { return &singleton->editor_data.get_undo_redo(); }
diff --git a/tools/editor/filesystem_dock.cpp b/tools/editor/filesystem_dock.cpp
index 3be122cc7d..378edd6667 100644
--- a/tools/editor/filesystem_dock.cpp
+++ b/tools/editor/filesystem_dock.cpp
@@ -950,14 +950,20 @@ void FileSystemDock::_file_option(int p_option) {
} break;
case FILE_INSTANCE: {
+ Vector<String> paths;
+
for (int i = 0; i<files->get_item_count(); i++) {
if (!files->is_selected(i))
continue;
String path =files->get_item_metadata(i);
if (EditorFileSystem::get_singleton()->get_file_type(path)=="PackedScene") {
- emit_signal("instance",path);
+ paths.push_back(path);
}
}
+
+ if (!paths.empty()) {
+ emit_signal("instance", paths);
+ }
} break;
case FILE_DEPENDENCIES: {
@@ -1596,7 +1602,7 @@ void FileSystemDock::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_preview_invalidated"),&FileSystemDock::_preview_invalidated);
- ADD_SIGNAL(MethodInfo("instance"));
+ ADD_SIGNAL(MethodInfo("instance", PropertyInfo(Variant::STRING_ARRAY, "files")));
ADD_SIGNAL(MethodInfo("open"));
}
diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp
index a240b575aa..35ddb49465 100644
--- a/tools/editor/scene_tree_dock.cpp
+++ b/tools/editor/scene_tree_dock.cpp
@@ -106,11 +106,30 @@ void SceneTreeDock::instance(const String& p_file) {
Vector<String> scenes;
scenes.push_back(p_file);
- instance_scenes(scenes,parent,-1);
+ _perform_instance_scenes(scenes,parent,-1);
}
-void SceneTreeDock::instance_scenes(const Vector<String>& p_files,Node* parent,int p_pos) {
+void SceneTreeDock::instance_scenes(const Vector<String>& p_files, Node *p_parent) {
+
+ Node *parent = p_parent;
+
+ if (!parent) {
+ parent = scene_tree->get_selected();
+ }
+
+ if (!parent || !edited_scene) {
+
+ accept->get_ok()->set_text(TTR("OK"));
+ accept->set_text(TTR("No parent to instance the scenes at."));
+ accept->popup_centered_minsize();
+ return;
+ };
+
+ _perform_instance_scenes(p_files, parent, -1);
+}
+
+void SceneTreeDock::_perform_instance_scenes(const Vector<String>& p_files,Node* parent,int p_pos) {
@@ -1677,7 +1696,7 @@ void SceneTreeDock::_files_dropped(Vector<String> p_files,NodePath p_to,int p_ty
int to_pos=-1;
_normalize_drop(node,to_pos,p_type);
- instance_scenes(p_files,node,to_pos);
+ _perform_instance_scenes(p_files,node,to_pos);
}
void SceneTreeDock::_nodes_dragged(Array p_nodes,NodePath p_to,int p_type) {
diff --git a/tools/editor/scene_tree_dock.h b/tools/editor/scene_tree_dock.h
index 51041a235b..04ed16967f 100644
--- a/tools/editor/scene_tree_dock.h
+++ b/tools/editor/scene_tree_dock.h
@@ -148,6 +148,8 @@ class SceneTreeDock : public VBoxContainer {
void _filter_changed(const String& p_filter);
+ void _perform_instance_scenes(const Vector<String>& p_files,Node* parent,int p_pos);
+
protected:
void _notification(int p_what);
@@ -160,7 +162,7 @@ public:
void import_subscene();
void set_edited_scene(Node* p_scene);
void instance(const String& p_path);
- void instance_scenes(const Vector<String>& p_files,Node* parent,int p_pos);
+ void instance_scenes(const Vector<String>& p_files, Node *p_parent=NULL);
void set_selected(Node *p_node, bool p_emit_selected=false);
void fill_path_renames(Node* p_node, Node *p_new_parent, List<Pair<NodePath,NodePath> > *p_renames);
void perform_node_renames(Node* p_base,List<Pair<NodePath,NodePath> > *p_renames, Map<Ref<Animation>, Set<int> > *r_rem_anims=NULL);