From dcf27c71b75452ce5ca0bb849715ce4304ad694d Mon Sep 17 00:00:00 2001 From: Michael Alexsander Silva Dias Date: Tue, 7 May 2019 23:35:23 -0300 Subject: Make possible to create inherited scenes via the RMB menu in the FileSystem dock --- editor/editor_node.cpp | 8 ++++++++ editor/editor_node.h | 1 + editor/filesystem_dock.cpp | 22 ++++++++++++++++------ editor/filesystem_dock.h | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) (limited to 'editor') diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 23d1f25641..fed1f6b4fa 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3250,6 +3250,12 @@ InspectorDock *EditorNode::get_inspector_dock() { return inspector_dock; } +void EditorNode::_inherit_request(String p_file) { + + current_option = FILE_NEW_INHERITED_SCENE; + _dialog_action(p_file); +} + void EditorNode::_instance_request(const Vector &p_files) { request_instance_scenes(p_files); @@ -5023,6 +5029,7 @@ void EditorNode::_bind_methods() { ClassDB::bind_method("_get_scene_metadata", &EditorNode::_get_scene_metadata); ClassDB::bind_method("set_edited_scene", &EditorNode::set_edited_scene); ClassDB::bind_method("open_request", &EditorNode::open_request); + ClassDB::bind_method("_inherit_request", &EditorNode::_inherit_request); ClassDB::bind_method("_instance_request", &EditorNode::_instance_request); ClassDB::bind_method("_close_messages", &EditorNode::_close_messages); ClassDB::bind_method("_show_messages", &EditorNode::_show_messages); @@ -5991,6 +5998,7 @@ EditorNode::EditorNode() { filesystem_dock = memnew(FileSystemDock(this)); filesystem_dock->connect("open", this, "open_request"); + filesystem_dock->connect("inherit", this, "_inherit_request"); filesystem_dock->connect("instance", this, "_instance_request"); filesystem_dock->connect("display_mode_changed", this, "_save_docks"); diff --git a/editor/editor_node.h b/editor/editor_node.h index 0084d421f9..cfe8bf9ec4 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -474,6 +474,7 @@ private: int _next_unsaved_scene(bool p_valid_filename, int p_start = 0); void _discard_changes(const String &p_str = String()); + void _inherit_request(String p_file); void _instance_request(const Vector &p_files); void _display_top_editors(bool p_display); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 9e214935f1..5ce22154e0 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1505,6 +1505,13 @@ void FileSystemDock::_file_option(int p_option, const Vector p_selected) } } break; + case FILE_INHERIT: { + // Create a new scene inherited from the selected one + if (p_selected.size() == 1) { + emit_signal("inherit", p_selected[0]); + } + } break; + case FILE_INSTANCE: { // Instance all selected scenes Vector paths; @@ -2071,13 +2078,16 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector= 1) { - p_popup->add_item(TTR("Open Scene(s)"), FILE_OPEN); + if (all_files_scenes) { + if (filenames.size() == 1) { + p_popup->add_item(TTR("Open Scene"), FILE_OPEN); + p_popup->add_item(TTR("New Inherited Scene"), FILE_INHERIT); + } else { + p_popup->add_item(TTR("Open Scenes"), FILE_OPEN); + } p_popup->add_item(TTR("Instance"), FILE_INSTANCE); p_popup->add_separator(); - } - - if (!all_files_scenes && filenames.size() == 1) { + } else if (filenames.size() == 1) { p_popup->add_item(TTR("Open"), FILE_OPEN); p_popup->add_separator(); } @@ -2378,8 +2388,8 @@ void FileSystemDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_feature_profile_changed"), &FileSystemDock::_feature_profile_changed); + ADD_SIGNAL(MethodInfo("inherit", PropertyInfo(Variant::STRING, "file"))); ADD_SIGNAL(MethodInfo("instance", PropertyInfo(Variant::POOL_STRING_ARRAY, "files"))); - ADD_SIGNAL(MethodInfo("open")); ADD_SIGNAL(MethodInfo("file_removed", PropertyInfo(Variant::STRING, "file"))); ADD_SIGNAL(MethodInfo("folder_removed", PropertyInfo(Variant::STRING, "folder"))); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 8b27938c8a..9d20544ac2 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -73,6 +73,7 @@ public: private: enum FileMenu { FILE_OPEN, + FILE_INHERIT, FILE_INSTANCE, FILE_ADD_FAVORITE, FILE_REMOVE_FAVORITE, -- cgit v1.2.3