| addons | ||
| examples/creverter | ||
| images | ||
| tests | ||
| .gitattributes | ||
| .gitignore | ||
| CHANGELOG.md | ||
| icon.png | ||
| icon.png.import | ||
| LICENSE.txt | ||
| project.godot | ||
| README.md | ||
Composite Reverter
The Composite Reverter (CReverter) is a memento-based undo/redo utility for Godot. It provides a clean interface to track the history of multiple objects and then to traverse that history via functions like undo and redo.
A unique feature is its support of composition, allowing objects to handle their own saving and loading independently of each other while still operating in unison. This enhances decoupling and encapsulation in your code.
How to Use
Requirements
Godot must be version 4.0 or later.
Install
- Option 1: Get it from the Godot Asset Library through the Godot editor.
- Option 2: Download it from the Releases page and put the
creverter/folder into theres://addons/folder in your project.
Quickstart
# Initialize reverter in main script
func _ready() -> void:
# These connections can also be set in the PackedScene
%Reverter.saving.connect(%MyNode.on_reverter_saving)
%Reverter.loading.connect(%MyNode.on_reverter_loading)
%UndoButton.pressed.connect(%Reverter.undo)
%RedoButton.pressed.connect(%Reverter.redo)
# Initial commit
%Reverter.commit()
# Make changes and commit again to make buttons usable
%MyNode.my_var -= 1
%Reverter.commit()
%Reverter.loaded.connect(_on_reverter_loaded)
func _on_reverter_loaded() -> void:
print(%MyNode.my_var)
# Connect saving and loading functions in %MyNode script
var my_var = 100
func on_reverter_saving(memento: CRMemento) -> void:
memento.add_submemento(name, {"my_var": my_var})
func on_reverter_loading(memento: CRMemento) -> void:
my_var = memento.get_submemento(name).my_var
API Reference
To view the API reference from inside the Godot editor: Either press F1 or go to Script > Search Help, and then search for "CReverter".
Contributing
Contributions, bug reports, requests, and general feedback are welcome. Make a new issue to get started.
Origin
This is developed for use in Super Practica. You can see an example of its usage there.