"FileSystem" dock now instance all selected scenes in one action

This commit is contained in:
Franklin Sobrinho 2016-07-20 14:09:03 -03:00
parent 4abc945466
commit 53beeb774b
5 changed files with 42 additions and 10 deletions

View file

@ -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) {

View file

@ -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(); }

View file

@ -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"));
}

View file

@ -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) {

View file

@ -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);