diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 12 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 19 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 20 | ||||
-rw-r--r-- | editor/scene_tree_dock.h | 1 |
4 files changed, 39 insertions, 13 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index bb6cc50a31..9643881f96 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -4713,7 +4713,7 @@ Dictionary Node3DEditor::get_state() const { continue; } int state = gizmos_menu->get_item_state(gizmos_menu->get_item_index(i)); - String name = gizmo_plugins_by_name[i]->get_name(); + String name = gizmo_plugins_by_name[i]->get_gizmo_name(); gizmos_status[name] = state; } @@ -4839,7 +4839,7 @@ void Node3DEditor::set_state(const Dictionary &p_state) { } int state = EditorNode3DGizmoPlugin::VISIBLE; for (int i = 0; i < keys.size(); i++) { - if (gizmo_plugins_by_name.write[j]->get_name() == String(keys[i])) { + if (gizmo_plugins_by_name.write[j]->get_gizmo_name() == String(keys[i])) { state = gizmos_status[keys[i]]; break; } @@ -5750,7 +5750,7 @@ void Node3DEditor::_update_gizmos_menu() { if (!gizmo_plugins_by_name[i]->can_be_hidden()) { continue; } - String plugin_name = gizmo_plugins_by_name[i]->get_name(); + String plugin_name = gizmo_plugins_by_name[i]->get_gizmo_name(); const int plugin_state = gizmo_plugins_by_name[i]->get_state(); gizmos_menu->add_multistate_item(plugin_name, 3, plugin_state, i); const int idx = gizmos_menu->get_item_index(i); @@ -7252,7 +7252,7 @@ void Node3DEditorPlugin::snap_cursor_to_plane(const Plane &p_plane) { struct _GizmoPluginPriorityComparator { bool operator()(const Ref<EditorNode3DGizmoPlugin> &p_a, const Ref<EditorNode3DGizmoPlugin> &p_b) const { if (p_a->get_priority() == p_b->get_priority()) { - return p_a->get_name() < p_b->get_name(); + return p_a->get_gizmo_name() < p_b->get_gizmo_name(); } return p_a->get_priority() > p_b->get_priority(); } @@ -7260,7 +7260,7 @@ struct _GizmoPluginPriorityComparator { struct _GizmoPluginNameComparator { bool operator()(const Ref<EditorNode3DGizmoPlugin> &p_a, const Ref<EditorNode3DGizmoPlugin> &p_b) const { - return p_a->get_name() < p_b->get_name(); + return p_a->get_gizmo_name() < p_b->get_gizmo_name(); } }; @@ -7471,7 +7471,7 @@ void EditorNode3DGizmoPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorNode3DGizmoPlugin::get_material, DEFVAL(Ref<EditorNode3DGizmo>())); - BIND_VMETHOD(MethodInfo(Variant::STRING, "get_name")); + BIND_VMETHOD(MethodInfo(Variant::STRING, "get_gizmo_name")); BIND_VMETHOD(MethodInfo(Variant::INT, "get_priority")); BIND_VMETHOD(MethodInfo(Variant::BOOL, "can_be_hidden")); BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_selectable_when_hidden")); diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 6a16aa28a9..74b01b3c36 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -40,9 +40,12 @@ void TileMapEditor::_node_removed(Node *p_node) { if (p_node == node && node) { - // Fixes #44824, which describes a situation where you can reselect a TileMap node without first de-selecting it when switching scenes. - node->disconnect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed)); + Callable callable_tileset_settings_changed = callable_mp(this, &TileMapEditor::_tileset_settings_changed); + if (node->is_connected("settings_changed", callable_tileset_settings_changed)) { + // Fixes #44824, which describes a situation where you can reselect a TileMap node without first de-selecting it when switching scenes. + node->disconnect("settings_changed", callable_tileset_settings_changed); + } node = nullptr; } } @@ -1870,7 +1873,11 @@ void TileMapEditor::edit(Node *p_tile_map) { } if (node) { - node->disconnect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed)); + Callable callable_tileset_settings_changed = callable_mp(this, &TileMapEditor::_tileset_settings_changed); + + if (node->is_connected("settings_changed", callable_tileset_settings_changed)) { + node->disconnect("settings_changed", callable_tileset_settings_changed); + } } if (p_tile_map) { node = Object::cast_to<TileMap>(p_tile_map); @@ -1897,7 +1904,11 @@ void TileMapEditor::edit(Node *p_tile_map) { } if (node) { - node->connect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed)); + Callable callable_tileset_settings_changed = callable_mp(this, &TileMapEditor::_tileset_settings_changed); + + if (!node->is_connected("settings_changed", callable_tileset_settings_changed)) { + node->connect("settings_changed", callable_tileset_settings_changed); + } } _clear_bucket_cache(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 58589467a8..0975decefb 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2321,10 +2321,14 @@ void SceneTreeDock::_new_scene_from(String p_file) { Node *base = selection.front()->get(); - Map<Node *, Node *> reown; - reown[editor_data->get_edited_scene_root()] = base; - Node *copy = base->duplicate_and_reown(reown); + Map<const Node *, Node *> duplimap; + Node *copy = base->duplicate_from_editor(duplimap); + if (copy) { + for (int i = 0; i < copy->get_child_count(); i++) { + _set_node_owner_recursive(copy->get_child(i), copy); + } + Ref<PackedScene> sdata = memnew(PackedScene); Error err = sdata->pack(copy); memdelete(copy); @@ -2354,6 +2358,16 @@ void SceneTreeDock::_new_scene_from(String p_file) { } } +void SceneTreeDock::_set_node_owner_recursive(Node *p_node, Node *p_owner) { + if (!p_node->get_owner()) { + p_node->set_owner(p_owner); + } + + for (int i = 0; i < p_node->get_child_count(); i++) { + _set_node_owner_recursive(p_node->get_child(i), p_owner); + } +} + static bool _is_node_visible(Node *p_node) { if (!p_node->get_owner()) { return false; diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 3779b61c60..807e922418 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -203,6 +203,7 @@ class SceneTreeDock : public VBoxContainer { void _import_subscene(); void _new_scene_from(String p_file); + void _set_node_owner_recursive(Node *p_node, Node *p_owner); bool _validate_no_foreign(); bool _validate_no_instance(); |