Documentation ¶
Overview ¶
Package EditorUndoRedoManager provides methods for working with EditorUndoRedoManager object instances.
Index ¶
- type Advanced
- type Any
- type Instance
- func (self Instance) AddDoProperty(obj Object.Instance, property string, value any)
- func (self Instance) AddDoReference(obj Object.Instance)
- func (self Instance) AddUndoProperty(obj Object.Instance, property string, value any)
- func (self Instance) AddUndoReference(obj Object.Instance)
- func (self Instance) AsEditorUndoRedoManager() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) CommitAction()
- func (self Instance) CreateAction(name string)
- func (self Instance) ForceFixedHistory()
- func (self Instance) GetHistoryUndoRedo(id int) [1]gdclass.UndoRedo
- func (self Instance) GetObjectHistoryId(obj Object.Instance) int
- func (self Instance) IsCommittingAction() bool
- func (self Instance) OnHistoryChanged(cb func())
- func (self Instance) OnVersionChanged(cb func())
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Virtual(name string) reflect.Value
- type SpecialHistory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Instance ¶
type Instance [1]gdclass.EditorUndoRedoManager
[EditorUndoRedoManager] is a manager for [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 ([ProjectSettings] edits, external resources, etc.), a separate global history is used. The usage is mostly the same as [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: - If the object is a [Node], use the currently edited scene; - If the object is a built-in resource, use the scene from its path; - If the object is external resource or anything else, use global history. This guessing can sometimes yield false results, so you can provide a custom context object when creating an action. [EditorUndoRedoManager] is intended to be used by Godot editor plugins. You can obtain it using [method EditorPlugin.get_undo_redo]. For non-editor uses or plugins that don't need to integrate with the editor's undo history, use [UndoRedo] instead. The manager's API is mostly the same as in [UndoRedo], so you can refer to its documentation for more examples. The main difference is that [EditorUndoRedoManager] uses object + method name for actions, instead of [Callable].
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AddDoProperty ¶
Register a property value change for "do". If this is the first operation, the [param object] will be used to deduce target undo history.
func (Instance) AddDoReference ¶
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.
func (Instance) AddUndoProperty ¶
Register a property value change for "undo". If this is the first operation, the [param object] will be used to deduce target undo history.
func (Instance) AddUndoReference ¶
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!).
func (Instance) AsEditorUndoRedoManager ¶
func (Instance) CommitAction ¶
func (self Instance) CommitAction()
Commit the action. If [param execute] is true (default), all "do" methods/properties are called/set when this function is called.
func (Instance) CreateAction ¶
Create a new action. After this is called, do all your calls to [method add_do_method], [method add_undo_method], [method add_do_property], and [method add_undo_property], then commit the action with [method commit_action]. The way actions are merged is dictated by the [param merge_mode] argument. See [enum UndoRedo.MergeMode] for details. If [param custom_context] object is provided, it will be used for deducing target history (instead of using the first operation). The way undo operation are ordered in actions is dictated by [param backward_undo_ops]. When [param backward_undo_ops] is [code]false[/code] undo option are ordered in the same order they were added. Which means the first operation to be added will be the first to be undone.
func (Instance) ForceFixedHistory ¶
func (self Instance) ForceFixedHistory()
Forces the next operation (e.g. [method add_do_method]) to use the action's history rather than guessing it from the object. This is sometimes needed when a history can't be correctly determined, like for a nested resource that doesn't have a path yet. This method should only be used when absolutely necessary, otherwise it might cause invalid history state. For most of complex cases, the [code]custom_context[/code] parameter of [method create_action] is sufficient.
func (Instance) GetHistoryUndoRedo ¶
Returns the [UndoRedo] object associated with the given history [param id]. [param id] above [code]0[/code] are mapped to the opened scene tabs (but it doesn't match their order). [param id] of [code]0[/code] or lower have special meaning (see [enum SpecialHistory]). Best used with [method get_object_history_id]. This method is only provided in case you need some more advanced methods of [UndoRedo] (but keep in mind that directly operating on the [UndoRedo] object might affect editor's stability).
func (Instance) GetObjectHistoryId ¶
Returns the history ID deduced from the given [param object]. It can be used with [method get_history_undo_redo].
func (Instance) IsCommittingAction ¶
Returns [code]true[/code] if the [EditorUndoRedoManager] is currently committing the action, i.e. running its "do" method or property change (see [method commit_action]).
func (Instance) OnHistoryChanged ¶
func (self Instance) OnHistoryChanged(cb func())
func (Instance) OnVersionChanged ¶
func (self Instance) OnVersionChanged(cb func())
func (*Instance) UnsafePointer ¶
type SpecialHistory ¶
type SpecialHistory = gdclass.EditorUndoRedoManagerSpecialHistory //gd:EditorUndoRedoManager.SpecialHistory
const ( /*Global history not associated with any scene, but with external resources etc.*/ GlobalHistory SpecialHistory = 0 /*History associated with remote inspector. Used when live editing a running project.*/ RemoteHistory SpecialHistory = -9 /*Invalid "null" history. It's a special value, not associated with any object.*/ InvalidHistory SpecialHistory = -99 )