diff options
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/editor_node.cpp | 17 | ||||
| -rw-r--r-- | editor/editor_node.h | 2 | ||||
| -rw-r--r-- | editor/editor_properties.cpp | 2 | ||||
| -rw-r--r-- | editor/editor_resource_preview.cpp | 15 | ||||
| -rw-r--r-- | editor/editor_resource_preview.h | 2 | ||||
| -rw-r--r-- | editor/filesystem_dock.cpp | 44 | ||||
| -rw-r--r-- | editor/filesystem_dock.h | 7 | ||||
| -rw-r--r-- | editor/icons/icon_oriented_path_follow.svg | 5 | ||||
| -rw-r--r-- | editor/plugins/item_list_editor_plugin.cpp | 2 | ||||
| -rw-r--r-- | editor/scene_tree_dock.cpp | 14 |
10 files changed, 74 insertions, 36 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 9169227e8a..719130621e 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -494,7 +494,7 @@ void EditorNode::_fs_changed() { } } - get_tree()->quit(); + _exit_editor(); } } @@ -1120,7 +1120,7 @@ void EditorNode::save_all_scenes_and_restart() { to_reopen = get_tree()->get_edited_scene_root()->get_filename(); } - get_tree()->quit(); + _exit_editor(); String exec = OS::get_singleton()->get_executable_path(); List<String> args; @@ -2356,6 +2356,12 @@ int EditorNode::_next_unsaved_scene(bool p_valid_filename, int p_start) { return -1; } +void EditorNode::_exit_editor() { + exiting = true; + resource_preview->stop(); //stop early to avoid crashes + get_tree()->quit(); +} + void EditorNode::_discard_changes(const String &p_str) { switch (current_option) { @@ -2383,14 +2389,13 @@ void EditorNode::_discard_changes(const String &p_str) { case FILE_QUIT: { _menu_option_confirm(RUN_STOP, true); - exiting = true; - get_tree()->quit(); + _exit_editor(); + } break; case RUN_PROJECT_MANAGER: { _menu_option_confirm(RUN_STOP, true); - exiting = true; - get_tree()->quit(); + _exit_editor(); String exec = OS::get_singleton()->get_executable_path(); List<String> args; diff --git a/editor/editor_node.h b/editor/editor_node.h index d7d969fb16..13bebea5f0 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -470,6 +470,8 @@ private: void _dropped_files(const Vector<String> &p_files, int p_screen); String _recent_scene; + void _exit_editor(); + bool convert_old; void _unhandled_input(const Ref<InputEvent> &p_event); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 72545f6b19..e33b26d9cb 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2397,7 +2397,7 @@ void EditorPropertyResource::_update_menu() { void EditorPropertyResource::_sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool) { - emit_signal("property_keyed_with_value", String(get_edited_property()) + ":" + p_property, p_value); + emit_signal("property_keyed_with_value", String(get_edited_property()) + ":" + p_property, p_value, false); } void EditorPropertyResource::_sub_inspector_resource_selected(const RES &p_resource, const String &p_property) { diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 25139b0163..368efbc48f 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -416,6 +416,16 @@ void EditorResourcePreview::check_for_invalidation(const String &p_path) { } } +void EditorResourcePreview::stop() { + if (thread) { + exit = true; + preview_sem->post(); + Thread::wait_to_finish(thread); + memdelete(thread); + thread = NULL; + } +} + EditorResourcePreview::EditorResourcePreview() { singleton = this; preview_mutex = Mutex::create(); @@ -428,10 +438,7 @@ EditorResourcePreview::EditorResourcePreview() { EditorResourcePreview::~EditorResourcePreview() { - exit = true; - preview_sem->post(); - Thread::wait_to_finish(thread); - memdelete(thread); + stop(); memdelete(preview_mutex); memdelete(preview_sem); } diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index 055ecc6bbf..85ac78d58f 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -126,6 +126,8 @@ public: void remove_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator); void check_for_invalidation(const String &p_path); + void stop(); + EditorResourcePreview(); ~EditorResourcePreview(); }; diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 58af5285b9..1ac66fdd1d 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -51,7 +51,7 @@ Ref<Texture> FileSystemDock::_get_tree_item_icon(EditorFileSystemDirectory *p_di return file_icon; } -bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths) { +bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites) { bool parent_should_expand = false; @@ -66,7 +66,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory subdirectory_item->set_selectable(0, true); String lpath = p_dir->get_path(); subdirectory_item->set_metadata(0, lpath); - if (path == lpath || ((display_mode_setting == DISPLAY_MODE_SETTING_SPLIT) && path.get_base_dir() == lpath)) { + if (!p_select_in_favorites && (path == lpath || ((display_mode_setting == DISPLAY_MODE_SETTING_SPLIT) && path.get_base_dir() == lpath))) { subdirectory_item->select(0); } @@ -81,7 +81,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory // Create items for all subdirectories for (int i = 0; i < p_dir->get_subdir_count(); i++) - parent_should_expand = (_create_tree(subdirectory_item, p_dir->get_subdir(i), uncollapsed_paths) || parent_should_expand); + parent_should_expand = (_create_tree(subdirectory_item, p_dir->get_subdir(i), uncollapsed_paths, p_select_in_favorites) || parent_should_expand); // Create all items for the files in the subdirectory if (display_mode_setting == DISPLAY_MODE_SETTING_TREE_ONLY) { @@ -103,7 +103,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory file_item->set_icon(0, _get_tree_item_icon(p_dir, i)); String file_metadata = lpath.plus_file(file_name); file_item->set_metadata(0, file_metadata); - if (path == file_metadata) { + if (!p_select_in_favorites && path == file_metadata) { file_item->select(0); file_item->set_as_cursor(0); } @@ -156,7 +156,7 @@ Vector<String> FileSystemDock::_compute_uncollapsed_paths() { return uncollapsed_paths; } -void FileSystemDock::_update_tree(const Vector<String> p_uncollapsed_paths, bool p_uncollapse_root) { +void FileSystemDock::_update_tree(const Vector<String> p_uncollapsed_paths, bool p_uncollapse_root, bool p_select_in_favorites) { // Recreate the tree tree->clear(); @@ -205,6 +205,10 @@ void FileSystemDock::_update_tree(const Vector<String> p_uncollapsed_paths, bool ti->set_tooltip(0, fave); ti->set_selectable(0, true); ti->set_metadata(0, fave); + if (p_select_in_favorites && fave == path) { + ti->select(0); + ti->set_as_cursor(0); + } if (!fave.ends_with("/")) { Array udata; udata.push_back(tree_update_id); @@ -220,7 +224,7 @@ void FileSystemDock::_update_tree(const Vector<String> p_uncollapsed_paths, bool } // Create the remaining of the tree - _create_tree(root, EditorFileSystem::get_singleton()->get_filesystem(), uncollapsed_paths); + _create_tree(root, EditorFileSystem::get_singleton()->get_filesystem(), uncollapsed_paths, p_select_in_favorites); tree->ensure_cursor_is_visible(); updating_tree = false; } @@ -296,7 +300,7 @@ void FileSystemDock::_notification(int p_what) { file_list_popup->connect("id_pressed", this, "_file_list_rmb_option"); tree_popup->connect("id_pressed", this, "_tree_rmb_option"); - current_path->connect("text_entered", this, "navigate_to_path"); + current_path->connect("text_entered", this, "_navigate_to_path"); display_mode_setting = DisplayModeSetting(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode"))); always_show_folders = bool(EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders")); @@ -442,8 +446,7 @@ void FileSystemDock::_set_current_path_text(const String &p_path) { } } -void FileSystemDock::navigate_to_path(const String &p_path) { - +void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_favorites) { if (p_path == "Favorites") { path = p_path; } else { @@ -466,7 +469,7 @@ void FileSystemDock::navigate_to_path(const String &p_path) { _set_current_path_text(path); _push_to_history(); - _update_tree(_compute_uncollapsed_paths()); + _update_tree(_compute_uncollapsed_paths(), false, p_select_in_favorites); if (display_mode == DISPLAY_MODE_SPLIT) { _update_file_list(false); } @@ -483,6 +486,10 @@ void FileSystemDock::navigate_to_path(const String &p_path) { } } +void FileSystemDock::navigate_to_path(const String &p_path) { + _navigate_to_path(p_path); +} + void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) { if ((file_list_vb->is_visible_in_tree() || path == p_path.get_base_dir()) && p_preview.is_valid()) { @@ -790,7 +797,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { } } -void FileSystemDock::_select_file(const String p_path) { +void FileSystemDock::_select_file(const String p_path, bool p_select_in_favorites) { String fpath = p_path; if (fpath.ends_with("/")) { if (fpath != "res://") { @@ -803,17 +810,21 @@ void FileSystemDock::_select_file(const String p_path) { editor->load_resource(fpath); } } - navigate_to_path(fpath); + _navigate_to_path(fpath, p_select_in_favorites); } void FileSystemDock::_tree_activate_file() { TreeItem *selected = tree->get_selected(); if (selected) { - call_deferred("_select_file", selected->get_metadata(0)); + String path = selected->get_metadata(0); + TreeItem *parent = selected->get_parent(); + bool is_favorite = parent != NULL && parent->get_metadata(0) == "Favorites"; - if (path.ends_with("/") || path == "Favorites") { + if ((!is_favorite && path.ends_with("/")) || path == "Favorites") { bool collapsed = selected->is_collapsed(); selected->set_collapsed(!collapsed); + } else { + _select_file(path, is_favorite && !path.ends_with("/")); } } } @@ -2141,7 +2152,7 @@ void FileSystemDock::_file_list_rmb_pressed(const Vector2 &p_pos) { void FileSystemDock::select_file(const String &p_file) { - navigate_to_path(p_file); + _navigate_to_path(p_file); } void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) { @@ -2292,7 +2303,7 @@ void FileSystemDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_file_list_activate_file"), &FileSystemDock::_file_list_activate_file); ClassDB::bind_method(D_METHOD("_tree_activate_file"), &FileSystemDock::_tree_activate_file); ClassDB::bind_method(D_METHOD("_select_file"), &FileSystemDock::_select_file); - ClassDB::bind_method(D_METHOD("navigate_to_path"), &FileSystemDock::navigate_to_path); + ClassDB::bind_method(D_METHOD("_navigate_to_path"), &FileSystemDock::_navigate_to_path); ClassDB::bind_method(D_METHOD("_change_file_display"), &FileSystemDock::_change_file_display); ClassDB::bind_method(D_METHOD("_fw_history"), &FileSystemDock::_fw_history); ClassDB::bind_method(D_METHOD("_bw_history"), &FileSystemDock::_bw_history); @@ -2310,6 +2321,7 @@ void FileSystemDock::_bind_methods() { ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &FileSystemDock::get_drag_data_fw); ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &FileSystemDock::can_drop_data_fw); ClassDB::bind_method(D_METHOD("drop_data_fw"), &FileSystemDock::drop_data_fw); + ClassDB::bind_method(D_METHOD("navigate_to_path"), &FileSystemDock::navigate_to_path); ClassDB::bind_method(D_METHOD("_preview_invalidated"), &FileSystemDock::_preview_invalidated); ClassDB::bind_method(D_METHOD("_file_multi_selected"), &FileSystemDock::_file_multi_selected); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 1f8ae698a3..237413acc4 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -178,9 +178,10 @@ private: bool import_dock_needs_update; Ref<Texture> _get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx); - bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths); + bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites); Vector<String> _compute_uncollapsed_paths(); - void _update_tree(const Vector<String> p_uncollapsed_paths = Vector<String>(), bool p_uncollapse_root = false); + void _update_tree(const Vector<String> p_uncollapsed_paths = Vector<String>(), bool p_uncollapse_root = false, bool p_select_in_favorites = false); + void _navigate_to_path(const String &p_path, bool p_select_in_favorites = false); void _file_list_gui_input(Ref<InputEvent> p_event); void _tree_gui_input(Ref<InputEvent> p_event); @@ -192,7 +193,7 @@ private: void _tree_toggle_collapsed(); - void _select_file(const String p_path); + void _select_file(const String p_path, bool p_select_in_favorites = false); void _tree_activate_file(); void _file_list_activate_file(int p_idx); void _file_multi_selected(int p_index, bool p_selected); diff --git a/editor/icons/icon_oriented_path_follow.svg b/editor/icons/icon_oriented_path_follow.svg deleted file mode 100644 index bd3f585e54..0000000000 --- a/editor/icons/icon_oriented_path_follow.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1036.4)"> -<path transform="translate(0 1036.4)" d="m13 0l-3 4h1.9473c-0.1385 1.3203-0.5583 1.9074-1.084 2.2754-0.64426 0.451-1.7129 0.60547-2.9629 0.73047s-2.6814 0.22053-3.9121 1.082c-0.89278 0.62493-1.5321 1.6522-1.8184 3.0957a2 2 0 0 0 -1.1699 1.8164 2 2 0 0 0 2 2 2 2 0 0 0 2 -2 2 2 0 0 0 -0.84961 -1.6328c0.19235-0.88496 0.55306-1.3373 0.98633-1.6406 0.64426-0.451 1.7129-0.60547 2.9629-0.73047s2.6814-0.22053 3.9121-1.082c1.0528-0.73697 1.7552-2.032 1.9375-3.9141h2.0508l-3-4z" fill="#fc9c9c" fill-opacity=".99608"/> -</g> -</svg> diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index d9861c91e0..db0816064c 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -109,7 +109,7 @@ void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const { int flags = get_flags(); if (flags & FLAG_CHECKABLE) { - p_list->push_back(PropertyInfo(Variant::BOOL, base + "checkable", PROPERTY_HINT_ENUM, "No,As checkbox,As radio button")); + p_list->push_back(PropertyInfo(Variant::INT, base + "checkable", PROPERTY_HINT_ENUM, "No,As checkbox,As radio button")); p_list->push_back(PropertyInfo(Variant::BOOL, base + "checked")); } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index daa7f92dcf..be1c4a36bd 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -563,6 +563,20 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (node == root) return; + //check that from node to root, all owners are right + + if (node->get_owner() != root) { + accept->set_text(TTR("Node must belong to the edited scene to become root.")); + accept->popup_centered_minsize(); + return; + } + + if (node->get_filename() != String()) { + accept->set_text(TTR("Instantiated scenes can't become root")); + accept->popup_centered_minsize(); + return; + } + editor_data->get_undo_redo().create_action("Make node as Root"); editor_data->get_undo_redo().add_do_method(node->get_parent(), "remove_child", node); editor_data->get_undo_redo().add_do_method(root->get_parent(), "remove_child", root); |