mirror of
https://github.com/godotengine/godot.git
synced 2025-10-26 03:04:31 +00:00
Fixed renaming/moving of nodes with exported NodePaths
(cherry picked from commit fdec257e58)
This commit is contained in:
parent
c43e8d8fbd
commit
b426e58acd
1 changed files with 25 additions and 10 deletions
|
|
@ -1329,29 +1329,33 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
|
||||||
|
|
||||||
List<PropertyInfo> properties;
|
List<PropertyInfo> properties;
|
||||||
si->get_property_list(&properties);
|
si->get_property_list(&properties);
|
||||||
|
NodePath root_path = p_base->get_path();
|
||||||
|
|
||||||
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
|
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
|
||||||
|
|
||||||
String propertyname = E->get().name;
|
String propertyname = E->get().name;
|
||||||
Variant p = p_base->get(propertyname);
|
Variant p = p_base->get(propertyname);
|
||||||
if (p.get_type() == Variant::NODE_PATH) {
|
if (p.get_type() == Variant::NODE_PATH) {
|
||||||
|
NodePath root_path_new = root_path;
|
||||||
|
for (List<Pair<NodePath, NodePath> >::Element *F = p_renames->front(); F; F = F->next()) {
|
||||||
|
if (root_path == F->get().first) {
|
||||||
|
root_path_new = F->get().second;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Goes through all paths to check if its matching
|
// Goes through all paths to check if its matching
|
||||||
for (List<Pair<NodePath, NodePath> >::Element *F = p_renames->front(); F; F = F->next()) {
|
for (List<Pair<NodePath, NodePath> >::Element *F = p_renames->front(); F; F = F->next()) {
|
||||||
|
|
||||||
NodePath root_path = p_base->get_path();
|
|
||||||
|
|
||||||
NodePath rel_path_old = root_path.rel_path_to(F->get().first);
|
NodePath rel_path_old = root_path.rel_path_to(F->get().first);
|
||||||
|
|
||||||
NodePath rel_path_new = F->get().second;
|
|
||||||
|
|
||||||
// if not empty, get new relative path
|
|
||||||
if (F->get().second != NodePath()) {
|
|
||||||
rel_path_new = root_path.rel_path_to(F->get().second);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if old path detected, then it needs to be replaced with the new one
|
// if old path detected, then it needs to be replaced with the new one
|
||||||
if (p == rel_path_old) {
|
if (p == rel_path_old) {
|
||||||
|
NodePath rel_path_new = F->get().second;
|
||||||
|
|
||||||
|
// if not empty, get new relative path
|
||||||
|
if (!rel_path_new.is_empty()) {
|
||||||
|
rel_path_new = root_path_new.rel_path_to(F->get().second);
|
||||||
|
}
|
||||||
|
|
||||||
editor_data->get_undo_redo().add_do_property(p_base, propertyname, rel_path_new);
|
editor_data->get_undo_redo().add_do_property(p_base, propertyname, rel_path_new);
|
||||||
editor_data->get_undo_redo().add_undo_property(p_base, propertyname, rel_path_old);
|
editor_data->get_undo_redo().add_undo_property(p_base, propertyname, rel_path_old);
|
||||||
|
|
@ -1359,6 +1363,17 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP
|
||||||
p_base->set(propertyname, rel_path_new);
|
p_base->set(propertyname, rel_path_new);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update if the node itself moved up/down the tree hirarchy
|
||||||
|
if (root_path == F->get().first) {
|
||||||
|
NodePath abs_path = NodePath(String(root_path).plus_file(p)).simplified();
|
||||||
|
NodePath rel_path_new = F->get().second.rel_path_to(abs_path);
|
||||||
|
|
||||||
|
editor_data->get_undo_redo().add_do_property(p_base, propertyname, rel_path_new);
|
||||||
|
editor_data->get_undo_redo().add_undo_property(p_base, propertyname, p);
|
||||||
|
|
||||||
|
p_base->set(propertyname, rel_path_new);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue