mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Don't create an UndoRedo action if Autoload order doesn't change after Drag & Drop
This commit is contained in:
committed by
Rémi Verschelde
parent
1aaf20b1f1
commit
4cadfd3eb9
@@ -715,6 +715,15 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &
|
|||||||
Dictionary drop_data = p_data;
|
Dictionary drop_data = p_data;
|
||||||
PackedStringArray autoloads = drop_data["autoloads"];
|
PackedStringArray autoloads = drop_data["autoloads"];
|
||||||
|
|
||||||
|
// Store the initial order of the autoloads for comparison.
|
||||||
|
Vector<int> initial_orders;
|
||||||
|
initial_orders.resize(autoload_cache.size());
|
||||||
|
int idx = 0;
|
||||||
|
for (const AutoloadInfo &F : autoload_cache) {
|
||||||
|
initial_orders.write[idx++] = F.order;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform the drag-and-drop operation.
|
||||||
Vector<int> orders;
|
Vector<int> orders;
|
||||||
orders.resize(autoload_cache.size());
|
orders.resize(autoload_cache.size());
|
||||||
|
|
||||||
@@ -734,10 +743,14 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
idx = 0;
|
||||||
|
|
||||||
for (const AutoloadInfo &F : autoload_cache) {
|
for (const AutoloadInfo &F : autoload_cache) {
|
||||||
orders.write[i++] = F.order;
|
orders.write[idx++] = F.order;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the order didn't change, we shouldn't create undo/redo actions.
|
||||||
|
if (orders == initial_orders) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
orders.sort();
|
orders.sort();
|
||||||
@@ -746,10 +759,9 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &
|
|||||||
|
|
||||||
undo_redo->create_action(TTR("Rearrange Autoloads"));
|
undo_redo->create_action(TTR("Rearrange Autoloads"));
|
||||||
|
|
||||||
i = 0;
|
idx = 0;
|
||||||
|
|
||||||
for (const AutoloadInfo &F : autoload_cache) {
|
for (const AutoloadInfo &F : autoload_cache) {
|
||||||
undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, orders[i++]);
|
undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, orders[idx++]);
|
||||||
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, F.order);
|
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, F.order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user