class_undoredo.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_UndoRedo:
  4. UndoRedo
  5. ========
  6. **Inherits:** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Helper to manage UndoRedo in the editor or custom tools.
  11. Member Functions
  12. ----------------
  13. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | void | :ref:`add_do_method<class_UndoRedo_add_do_method>` **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` method, :ref:`Variant<class_variant>` arg0=NULL, :ref:`Variant<class_variant>` arg1=NULL, :ref:`Variant<class_variant>` arg2=NULL, :ref:`Variant<class_variant>` arg3=NULL, :ref:`Variant<class_variant>` arg4=NULL **)** |
  15. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`add_do_property<class_UndoRedo_add_do_property>` **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` property, :ref:`Variant<class_variant>` value **)** |
  17. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`add_do_reference<class_UndoRedo_add_do_reference>` **(** :ref:`Object<class_object>` object **)** |
  19. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`add_undo_method<class_UndoRedo_add_undo_method>` **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` method, :ref:`Variant<class_variant>` arg0=NULL, :ref:`Variant<class_variant>` arg1=NULL, :ref:`Variant<class_variant>` arg2=NULL, :ref:`Variant<class_variant>` arg3=NULL, :ref:`Variant<class_variant>` arg4=NULL **)** |
  21. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`add_undo_property<class_UndoRedo_add_undo_property>` **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` property, :ref:`Variant<class_variant>` value **)** |
  23. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`add_undo_reference<class_UndoRedo_add_undo_reference>` **(** :ref:`Object<class_object>` object **)** |
  25. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`clear_history<class_UndoRedo_clear_history>` **(** **)** |
  27. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`commit_action<class_UndoRedo_commit_action>` **(** **)** |
  29. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`create_action<class_UndoRedo_create_action>` **(** :ref:`String<class_string>` name, :ref:`int<class_int>` merge_mode=0 **)** |
  31. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`String<class_string>` | :ref:`get_current_action_name<class_UndoRedo_get_current_action_name>` **(** **)** const |
  33. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`get_version<class_UndoRedo_get_version>` **(** **)** const |
  35. +------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. Numeric Constants
  37. -----------------
  38. - **MERGE_DISABLE** = **0**
  39. - **MERGE_ENDS** = **1**
  40. - **MERGE_ALL** = **2**
  41. Description
  42. -----------
  43. Helper to maange UndoRedo in the editor or custom tools. It works by storing calls to functions in both 'do' an 'undo' lists.
  44. Common behavior is to create an action, then add do/undo calls to functions or property changes, then commiting the action.
  45. Member Function Description
  46. ---------------------------
  47. .. _class_UndoRedo_add_do_method:
  48. - void **add_do_method** **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` method, :ref:`Variant<class_variant>` arg0=NULL, :ref:`Variant<class_variant>` arg1=NULL, :ref:`Variant<class_variant>` arg2=NULL, :ref:`Variant<class_variant>` arg3=NULL, :ref:`Variant<class_variant>` arg4=NULL **)**
  49. Add a call to a method in a given object with custom
  50. arguments.
  51. .. _class_UndoRedo_add_do_property:
  52. - void **add_do_property** **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` property, :ref:`Variant<class_variant>` value **)**
  53. Set a property with a custom value.
  54. .. _class_UndoRedo_add_do_reference:
  55. - void **add_do_reference** **(** :ref:`Object<class_object>` object **)**
  56. Add a 'do' reference 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.
  57. .. _class_UndoRedo_add_undo_method:
  58. - void **add_undo_method** **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` method, :ref:`Variant<class_variant>` arg0=NULL, :ref:`Variant<class_variant>` arg1=NULL, :ref:`Variant<class_variant>` arg2=NULL, :ref:`Variant<class_variant>` arg3=NULL, :ref:`Variant<class_variant>` arg4=NULL **)**
  59. Add a call to an undo method in a given object with custom arguments. Undo calls are used to revert 'do' calls.
  60. .. _class_UndoRedo_add_undo_property:
  61. - void **add_undo_property** **(** :ref:`Object<class_object>` object, :ref:`String<class_string>` property, :ref:`Variant<class_variant>` value **)**
  62. Undo setting of a property with a custom value.
  63. .. _class_UndoRedo_add_undo_reference:
  64. - void **add_undo_reference** **(** :ref:`Object<class_object>` object **)**
  65. Add an 'undo' reference that will be erased if the 'undo' history is lost. This is useful mostly for nodes rmoved with the 'do' call (not the 'undo' call!).
  66. .. _class_UndoRedo_clear_history:
  67. - void **clear_history** **(** **)**
  68. Clear the undo/redo history and associated
  69. references.
  70. .. _class_UndoRedo_commit_action:
  71. - void **commit_action** **(** **)**
  72. Commit the action. All 'do' methods/properties are called/set when this function is called.
  73. .. _class_UndoRedo_create_action:
  74. - void **create_action** **(** :ref:`String<class_string>` name, :ref:`int<class_int>` merge_mode=0 **)**
  75. Create a new action. After this is called, do all your calls to :ref:`add_do_method<class_UndoRedo_add_do_method>`, :ref:`add_undo_method<class_UndoRedo_add_undo_method>`, :ref:`add_do_property<class_UndoRedo_add_do_property>` and :ref:`add_undo_property<class_UndoRedo_add_undo_property>`.
  76. .. _class_UndoRedo_get_current_action_name:
  77. - :ref:`String<class_string>` **get_current_action_name** **(** **)** const
  78. Get the name of the current action.
  79. .. _class_UndoRedo_get_version:
  80. - :ref:`int<class_int>` **get_version** **(** **)** const
  81. Get the version, each time a new action is commited, the version number of the UndoRedo is increased automatically.
  82. This is useful mostly to check if something changed from a saved version.