Extend UndoRedo handling of Resource to every Reference
This commit is contained in:
parent
1e6dccd1c7
commit
90f13520dd
|
@ -31,6 +31,7 @@
|
|||
#include "undo_redo.h"
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "core/resource.h"
|
||||
|
||||
void UndoRedo::_discard_redo() {
|
||||
if (current_action == actions.size() - 1) {
|
||||
|
@ -104,8 +105,8 @@ void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_A
|
|||
ERR_FAIL_COND((current_action + 1) >= actions.size());
|
||||
Operation do_op;
|
||||
do_op.object = p_object->get_instance_id();
|
||||
if (Object::cast_to<Resource>(p_object)) {
|
||||
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
|
||||
if (Object::cast_to<Reference>(p_object)) {
|
||||
do_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
|
||||
}
|
||||
|
||||
do_op.type = Operation::TYPE_METHOD;
|
||||
|
@ -130,8 +131,8 @@ void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT
|
|||
|
||||
Operation undo_op;
|
||||
undo_op.object = p_object->get_instance_id();
|
||||
if (Object::cast_to<Resource>(p_object)) {
|
||||
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
|
||||
if (Object::cast_to<Reference>(p_object)) {
|
||||
undo_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
|
||||
}
|
||||
|
||||
undo_op.type = Operation::TYPE_METHOD;
|
||||
|
@ -148,8 +149,8 @@ void UndoRedo::add_do_property(Object *p_object, const String &p_property, const
|
|||
ERR_FAIL_COND((current_action + 1) >= actions.size());
|
||||
Operation do_op;
|
||||
do_op.object = p_object->get_instance_id();
|
||||
if (Object::cast_to<Resource>(p_object)) {
|
||||
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
|
||||
if (Object::cast_to<Reference>(p_object)) {
|
||||
do_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
|
||||
}
|
||||
|
||||
do_op.type = Operation::TYPE_PROPERTY;
|
||||
|
@ -169,8 +170,8 @@ void UndoRedo::add_undo_property(Object *p_object, const String &p_property, con
|
|||
|
||||
Operation undo_op;
|
||||
undo_op.object = p_object->get_instance_id();
|
||||
if (Object::cast_to<Resource>(p_object)) {
|
||||
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
|
||||
if (Object::cast_to<Reference>(p_object)) {
|
||||
undo_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
|
||||
}
|
||||
|
||||
undo_op.type = Operation::TYPE_PROPERTY;
|
||||
|
@ -184,8 +185,8 @@ void UndoRedo::add_do_reference(Object *p_object) {
|
|||
ERR_FAIL_COND((current_action + 1) >= actions.size());
|
||||
Operation do_op;
|
||||
do_op.object = p_object->get_instance_id();
|
||||
if (Object::cast_to<Resource>(p_object)) {
|
||||
do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
|
||||
if (Object::cast_to<Reference>(p_object)) {
|
||||
do_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
|
||||
}
|
||||
|
||||
do_op.type = Operation::TYPE_REFERENCE;
|
||||
|
@ -203,8 +204,8 @@ void UndoRedo::add_undo_reference(Object *p_object) {
|
|||
|
||||
Operation undo_op;
|
||||
undo_op.object = p_object->get_instance_id();
|
||||
if (Object::cast_to<Resource>(p_object)) {
|
||||
undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object));
|
||||
if (Object::cast_to<Reference>(p_object)) {
|
||||
undo_op.ref = Ref<Reference>(Object::cast_to<Reference>(p_object));
|
||||
}
|
||||
|
||||
undo_op.type = Operation::TYPE_REFERENCE;
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
#ifndef UNDO_REDO_H
|
||||
#define UNDO_REDO_H
|
||||
|
||||
#include "core/object.h"
|
||||
#include "core/resource.h"
|
||||
#include "core/reference.h"
|
||||
|
||||
class UndoRedo : public Object {
|
||||
GDCLASS(UndoRedo, Object);
|
||||
|
@ -61,7 +60,7 @@ private:
|
|||
};
|
||||
|
||||
Type type;
|
||||
Ref<Resource> resref;
|
||||
Ref<Reference> ref;
|
||||
ObjectID object;
|
||||
String name;
|
||||
Variant args[VARIANT_ARG_MAX];
|
||||
|
|
Loading…
Reference in New Issue