class_undoredo.rst 10 KB

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