1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Fix tilemap live editing while game is running

This commit is contained in:
pancelor
2023-10-11 07:01:55 -07:00
parent 918f046354
commit d66b1752b8
2 changed files with 24 additions and 21 deletions

View File

@@ -71,9 +71,7 @@ bool UndoRedo::_redo(bool p_execute) {
} }
current_action++; current_action++;
if (p_execute) { _process_operation_list(actions.write[current_action].do_ops.front(), p_execute);
_process_operation_list(actions.write[current_action].do_ops.front());
}
version++; version++;
emit_signal(SNAME("version_changed")); emit_signal(SNAME("version_changed"));
@@ -321,7 +319,7 @@ void UndoRedo::commit_action(bool p_execute) {
} }
} }
void UndoRedo::_process_operation_list(List<Operation>::Element *E) { void UndoRedo::_process_operation_list(List<Operation>::Element *E, bool p_execute) {
const int PREALLOCATE_ARGS_COUNT = 16; const int PREALLOCATE_ARGS_COUNT = 16;
LocalVector<const Variant *> args; LocalVector<const Variant *> args;
@@ -337,6 +335,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
switch (op.type) { switch (op.type) {
case Operation::TYPE_METHOD: { case Operation::TYPE_METHOD: {
if (p_execute) {
Callable::CallError ce; Callable::CallError ce;
Variant ret; Variant ret;
op.callable.callp(nullptr, 0, ret, ce); op.callable.callp(nullptr, 0, ret, ce);
@@ -349,6 +348,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
res->set_edited(true); res->set_edited(true);
} }
#endif #endif
}
if (method_callback) { if (method_callback) {
Vector<Variant> binds; Vector<Variant> binds;
@@ -373,6 +373,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
} }
} break; } break;
case Operation::TYPE_PROPERTY: { case Operation::TYPE_PROPERTY: {
if (p_execute) {
obj->set(op.name, op.value); obj->set(op.name, op.value);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
Resource *res = Object::cast_to<Resource>(obj); Resource *res = Object::cast_to<Resource>(obj);
@@ -380,6 +381,8 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
res->set_edited(true); res->set_edited(true);
} }
#endif #endif
}
if (property_callback) { if (property_callback) {
property_callback(prop_callback_ud, obj, op.name, op.value); property_callback(prop_callback_ud, obj, op.name, op.value);
} }
@@ -400,7 +403,7 @@ bool UndoRedo::undo() {
if (current_action < 0) { if (current_action < 0) {
return false; //nothing to redo return false; //nothing to redo
} }
_process_operation_list(actions.write[current_action].undo_ops.front()); _process_operation_list(actions.write[current_action].undo_ops.front(), true);
current_action--; current_action--;
version--; version--;
emit_signal(SNAME("version_changed")); emit_signal(SNAME("version_changed"));

View File

@@ -85,7 +85,7 @@ private:
uint64_t version = 1; uint64_t version = 1;
void _pop_history_tail(); void _pop_history_tail();
void _process_operation_list(List<Operation>::Element *E); void _process_operation_list(List<Operation>::Element *E, bool p_execute);
void _discard_redo(); void _discard_redo();
bool _redo(bool p_execute); bool _redo(bool p_execute);