You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Merge pull request #5821 from TheHX/issue-5795
Improved FileSystem dock "Instance" option
This commit is contained in:
@@ -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() {
|
FileSystemDock *EditorNode::get_scenes_dock() {
|
||||||
|
|
||||||
return scenes_dock;
|
return scenes_dock;
|
||||||
@@ -3831,10 +3836,9 @@ SceneTreeDock *EditorNode::get_scene_tree_dock() {
|
|||||||
return 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_scenes(p_files);
|
||||||
request_instance_scene(p_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::_property_keyed(const String& p_keyed,const Variant& p_value,bool p_advance) {
|
void EditorNode::_property_keyed(const String& p_keyed,const Variant& p_value,bool p_advance) {
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ private:
|
|||||||
void _save_scene(String p_file, int idx = -1);
|
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 _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);
|
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; }
|
static VSplitContainer *get_top_split() { return singleton->top_split; }
|
||||||
|
|
||||||
void request_instance_scene(const String &p_path);
|
void request_instance_scene(const String &p_path);
|
||||||
|
void request_instance_scenes(const Vector<String>& p_files);
|
||||||
FileSystemDock *get_scenes_dock();
|
FileSystemDock *get_scenes_dock();
|
||||||
SceneTreeDock *get_scene_tree_dock();
|
SceneTreeDock *get_scene_tree_dock();
|
||||||
static UndoRedo* get_undo_redo() { return &singleton->editor_data.get_undo_redo(); }
|
static UndoRedo* get_undo_redo() { return &singleton->editor_data.get_undo_redo(); }
|
||||||
|
|||||||
@@ -950,14 +950,20 @@ void FileSystemDock::_file_option(int p_option) {
|
|||||||
} break;
|
} break;
|
||||||
case FILE_INSTANCE: {
|
case FILE_INSTANCE: {
|
||||||
|
|
||||||
|
Vector<String> paths;
|
||||||
|
|
||||||
for (int i = 0; i<files->get_item_count(); i++) {
|
for (int i = 0; i<files->get_item_count(); i++) {
|
||||||
if (!files->is_selected(i))
|
if (!files->is_selected(i))
|
||||||
continue;
|
continue;
|
||||||
String path =files->get_item_metadata(i);
|
String path =files->get_item_metadata(i);
|
||||||
if (EditorFileSystem::get_singleton()->get_file_type(path)=="PackedScene") {
|
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;
|
} break;
|
||||||
case FILE_DEPENDENCIES: {
|
case FILE_DEPENDENCIES: {
|
||||||
|
|
||||||
@@ -1596,7 +1602,7 @@ void FileSystemDock::_bind_methods() {
|
|||||||
ObjectTypeDB::bind_method(_MD("_preview_invalidated"),&FileSystemDock::_preview_invalidated);
|
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"));
|
ADD_SIGNAL(MethodInfo("open"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,11 +106,30 @@ void SceneTreeDock::instance(const String& p_file) {
|
|||||||
|
|
||||||
Vector<String> scenes;
|
Vector<String> scenes;
|
||||||
scenes.push_back(p_file);
|
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;
|
int to_pos=-1;
|
||||||
_normalize_drop(node,to_pos,p_type);
|
_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) {
|
void SceneTreeDock::_nodes_dragged(Array p_nodes,NodePath p_to,int p_type) {
|
||||||
|
|||||||
@@ -148,6 +148,8 @@ class SceneTreeDock : public VBoxContainer {
|
|||||||
|
|
||||||
void _filter_changed(const String& p_filter);
|
void _filter_changed(const String& p_filter);
|
||||||
|
|
||||||
|
void _perform_instance_scenes(const Vector<String>& p_files,Node* parent,int p_pos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
@@ -160,7 +162,7 @@ public:
|
|||||||
void import_subscene();
|
void import_subscene();
|
||||||
void set_edited_scene(Node* p_scene);
|
void set_edited_scene(Node* p_scene);
|
||||||
void instance(const String& p_path);
|
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 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 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);
|
void perform_node_renames(Node* p_base,List<Pair<NodePath,NodePath> > *p_renames, Map<Ref<Animation>, Set<int> > *r_rem_anims=NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user