Undo/Redo addon for Godot.
Find a file
2024-06-19 22:03:45 -07:00
addons Put copies of readme and changelog into addons folder 2024-06-19 22:03:45 -07:00
examples/creverter/basic_example Simplify example and explain it with comments 2024-06-17 15:15:24 -07:00
images Add screenshots 2024-06-17 15:20:04 -07:00
tests Add project 2024-06-16 16:50:55 -07:00
.gitattributes Prepare gitattributes file for the asset library 2024-06-16 17:28:22 -07:00
.gitignore Initial commit 2024-06-16 23:38:16 +00:00
CHANGELOG.md Add a changelog 2024-06-19 22:02:55 -07:00
icon.png Center icon 2024-06-17 14:01:20 -07:00
icon.png.import Center icon 2024-06-17 14:01:20 -07:00
LICENSE Initial commit 2024-06-16 23:38:16 +00:00
project.godot Add project metadata 2024-06-17 14:04:48 -07:00
README.md Write readme 2024-06-17 21:04:22 -07:00

Composite Reverter

Overview

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 subsystems 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

This is an addon for Godot. 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 the /addons/ folder in your project.

Quickstart

var reverter
var health = 100

func _ready():
    reverter = CReverter.new()
    reverter.connect_save_load(get_instance_id(), _save_func, _load_func)
    reverter.commit()
    %UndoButton.pressed.connect(reverter.undo)
    %RedoButton.pressed.connect(reverter.redo)
    
func _save_func():
    return {
        "position": position,
        "health": health,
    }
    
func _load_func(memento):
    position = memento.position
    health = memento.health

From here, modify the position or health and commit the change. Then you can undo it with the connected buttons.

API Reference

Detailed usage information can be found in the API reference, which you can read from inside the Godot editor. To do this, install the CReverter addon, click on Script > Search Help, and search for "creverter".

Contributing

Contributions, bug reports, requests, and general feedback are welcome. To contribute, first make an issue discussing what you what you want to do.

Any feedback about real use-cases is appreciated. How did using the CReverter go for your project? Did everything work nicely or were there unexpected problems? You can make an issue about this to tell me. This kind of feedback helps me to develop this better and improve the documentation.

Shameless Plug

If you found value in the CReverter then please visit/bookmark/contribute-to/fund/talk-up/otherwise-relate-to-in-a-favoring-way the FOSS game I'm developing, Super Practica. Thanks.

The Composite Reverter works well together with the Contextual Service Locator! It's exactly the kind of "service" that it's good for locating!