class_editorundoredomanager.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/EditorUndoRedoManager.xml.
  6. .. _class_EditorUndoRedoManager:
  7. EditorUndoRedoManager
  8. =====================
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Manages undo history of scenes opened in the editor.
  11. Description
  12. -----------
  13. ``EditorUndoRedoManager`` is a manager for :ref:`UndoRedo<class_UndoRedo>` objects associated with edited scenes. Each scene has its own undo history and ``EditorUndoRedoManager`` ensures that each action performed in the editor gets associated with a proper scene. For actions not related to scenes (:ref:`ProjectSettings<class_ProjectSettings>` edits, external resources, etc.), a separate global history is used.
  14. The usage is mostly the same as :ref:`UndoRedo<class_UndoRedo>`. You create and commit actions and the manager automatically decides under-the-hood what scenes it belongs to. The scene is deduced based on the first operation in an action, using the object from the operation. The rules are as follows:
  15. - If the object is a :ref:`Node<class_Node>`, use the currently edited scene;
  16. - If the object is a built-in resource, use the scene from its path;
  17. - If the object is external resource or anything else, use global history.
  18. This guessing can sometimes yield false results, so you can provide a custom context object when creating an action.
  19. Methods
  20. -------
  21. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`add_do_method<class_EditorUndoRedoManager_method_add_do_method>` **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` method, ... **)** |vararg| |
  23. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`add_do_property<class_EditorUndoRedoManager_method_add_do_property>` **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` property, :ref:`Variant<class_Variant>` value **)** |
  25. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`add_do_reference<class_EditorUndoRedoManager_method_add_do_reference>` **(** :ref:`Object<class_Object>` object **)** |
  27. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`add_undo_method<class_EditorUndoRedoManager_method_add_undo_method>` **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` method, ... **)** |vararg| |
  29. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`add_undo_property<class_EditorUndoRedoManager_method_add_undo_property>` **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` property, :ref:`Variant<class_Variant>` value **)** |
  31. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`add_undo_reference<class_EditorUndoRedoManager_method_add_undo_reference>` **(** :ref:`Object<class_Object>` object **)** |
  33. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`commit_action<class_EditorUndoRedoManager_method_commit_action>` **(** :ref:`bool<class_bool>` execute=true **)** |
  35. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`create_action<class_EditorUndoRedoManager_method_create_action>` **(** :ref:`String<class_String>` name, :ref:`MergeMode<enum_UndoRedo_MergeMode>` merge_mode=0, :ref:`Object<class_Object>` custom_context=null **)** |
  37. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`UndoRedo<class_UndoRedo>` | :ref:`get_history_undo_redo<class_EditorUndoRedoManager_method_get_history_undo_redo>` **(** :ref:`int<class_int>` id **)** |const| |
  39. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`int<class_int>` | :ref:`get_object_history_id<class_EditorUndoRedoManager_method_get_object_history_id>` **(** :ref:`Object<class_Object>` object **)** |const| |
  41. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`is_committing_action<class_EditorUndoRedoManager_method_is_committing_action>` **(** **)** |const| |
  43. +---------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. Signals
  45. -------
  46. .. _class_EditorUndoRedoManager_signal_history_changed:
  47. - **history_changed** **(** **)**
  48. Emitted when the list of actions in any history has changed, either when an action is commited or a history is cleared.
  49. ----
  50. .. _class_EditorUndoRedoManager_signal_version_changed:
  51. - **version_changed** **(** **)**
  52. Emitted when the version of any history has changed as a result of undo or redo call.
  53. Enumerations
  54. ------------
  55. .. _enum_EditorUndoRedoManager_SpecialHistory:
  56. .. _class_EditorUndoRedoManager_constant_GLOBAL_HISTORY:
  57. .. _class_EditorUndoRedoManager_constant_INVALID_HISTORY:
  58. enum **SpecialHistory**:
  59. - **GLOBAL_HISTORY** = **0** --- Global history not associated with any scene, but with external resources etc.
  60. - **INVALID_HISTORY** = **-99** --- Invalid "null" history. It's a special value, not associated with any object.
  61. Method Descriptions
  62. -------------------
  63. .. _class_EditorUndoRedoManager_method_add_do_method:
  64. - void **add_do_method** **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` method, ... **)** |vararg|
  65. Register a method that will be called when the action is committed (i.e. the "do" action).
  66. If this is the first operation, the ``object`` will be used to deduce target undo history.
  67. ----
  68. .. _class_EditorUndoRedoManager_method_add_do_property:
  69. - void **add_do_property** **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` property, :ref:`Variant<class_Variant>` value **)**
  70. Register a property value change for "do".
  71. If this is the first operation, the ``object`` will be used to deduce target undo history.
  72. ----
  73. .. _class_EditorUndoRedoManager_method_add_do_reference:
  74. - void **add_do_reference** **(** :ref:`Object<class_Object>` object **)**
  75. Register a reference for "do" that will be erased if the "do" history is lost. This is useful mostly for new nodes created for the "do" call. Do not use for resources.
  76. ----
  77. .. _class_EditorUndoRedoManager_method_add_undo_method:
  78. - void **add_undo_method** **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` method, ... **)** |vararg|
  79. Register a method that will be called when the action is undone (i.e. the "undo" action).
  80. If this is the first operation, the ``object`` will be used to deduce target undo history.
  81. ----
  82. .. _class_EditorUndoRedoManager_method_add_undo_property:
  83. - void **add_undo_property** **(** :ref:`Object<class_Object>` object, :ref:`StringName<class_StringName>` property, :ref:`Variant<class_Variant>` value **)**
  84. Register a property value change for "undo".
  85. If this is the first operation, the ``object`` will be used to deduce target undo history.
  86. ----
  87. .. _class_EditorUndoRedoManager_method_add_undo_reference:
  88. - void **add_undo_reference** **(** :ref:`Object<class_Object>` object **)**
  89. Register a reference for "undo" that will be erased if the "undo" history is lost. This is useful mostly for nodes removed with the "do" call (not the "undo" call!).
  90. ----
  91. .. _class_EditorUndoRedoManager_method_commit_action:
  92. - void **commit_action** **(** :ref:`bool<class_bool>` execute=true **)**
  93. Commit the action. If ``execute`` is true (default), all "do" methods/properties are called/set when this function is called.
  94. ----
  95. .. _class_EditorUndoRedoManager_method_create_action:
  96. - void **create_action** **(** :ref:`String<class_String>` name, :ref:`MergeMode<enum_UndoRedo_MergeMode>` merge_mode=0, :ref:`Object<class_Object>` custom_context=null **)**
  97. Create a new action. After this is called, do all your calls to :ref:`add_do_method<class_EditorUndoRedoManager_method_add_do_method>`, :ref:`add_undo_method<class_EditorUndoRedoManager_method_add_undo_method>`, :ref:`add_do_property<class_EditorUndoRedoManager_method_add_do_property>`, and :ref:`add_undo_property<class_EditorUndoRedoManager_method_add_undo_property>`, then commit the action with :ref:`commit_action<class_EditorUndoRedoManager_method_commit_action>`.
  98. The way actions are merged is dictated by the ``merge_mode`` argument. See :ref:`MergeMode<enum_UndoRedo_MergeMode>` for details.
  99. If ``custom_context`` object is provided, it will be used for deducing target history (instead of using the first operation).
  100. ----
  101. .. _class_EditorUndoRedoManager_method_get_history_undo_redo:
  102. - :ref:`UndoRedo<class_UndoRedo>` **get_history_undo_redo** **(** :ref:`int<class_int>` id **)** |const|
  103. Returns the :ref:`UndoRedo<class_UndoRedo>` object associated with the given history ``id``.
  104. \ ``id`` above ``0`` are mapped to the opened scene tabs (but it doesn't match their order). ``id`` of ``0`` or lower have special meaning (see :ref:`SpecialHistory<enum_EditorUndoRedoManager_SpecialHistory>`).
  105. Best used with :ref:`get_object_history_id<class_EditorUndoRedoManager_method_get_object_history_id>`. This method is only provided in case you need some more advanced methods of :ref:`UndoRedo<class_UndoRedo>` (but keep in mind that directly operating on the :ref:`UndoRedo<class_UndoRedo>` object might affect editor's stability).
  106. ----
  107. .. _class_EditorUndoRedoManager_method_get_object_history_id:
  108. - :ref:`int<class_int>` **get_object_history_id** **(** :ref:`Object<class_Object>` object **)** |const|
  109. Returns the history ID deduced from the given ``object``. It can be used with :ref:`get_history_undo_redo<class_EditorUndoRedoManager_method_get_history_undo_redo>`.
  110. ----
  111. .. _class_EditorUndoRedoManager_method_is_committing_action:
  112. - :ref:`bool<class_bool>` **is_committing_action** **(** **)** |const|
  113. Returns ``true`` if the ``EditorUndoRedoManager`` is currently committing the action, i.e. running its "do" method or property change (see :ref:`commit_action<class_EditorUndoRedoManager_method_commit_action>`).
  114. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  115. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  116. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  117. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  118. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  119. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`