Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request]: Undo/Redo Support #245

Open
1 task done
arjo129 opened this issue Dec 20, 2024 · 2 comments · May be fixed by #257
Open
1 task done

[Feature request]: Undo/Redo Support #245

arjo129 opened this issue Dec 20, 2024 · 2 comments · May be fixed by #257
Labels
enhancement New feature or request

Comments

@arjo129
Copy link
Member

arjo129 commented Dec 20, 2024

Before proceeding, is there an existing issue or discussion for this?

Description

As mentioned in the title. This will likely need a major refactor ☠️ , in traffic editor we were fortunate to have Qt's built in QAction based undo/redo workflow. For Site Editor, we should support some way of undoing a change.

Implementation Considerations

There are several ways to support undo/redo. The naivest way is to snapshot the current world state and keep it in a buffer. This will not scale well as worlds get more complex.

A less naive way would be to require that every forward edit has an equivalent inverse edit. For instance in Qt, this is exactly what the QAction class does. TBF, I'm not sure of the best way we would implement this particularly, with the context of bevy_impulse in mind.

Special care will have to be taken when we handle moving and deletion of objects as well.

Alternatives

Saving intermediate .ron files ☠️ .

Additional information

No response

Mildly related issue:
#216

@arjo129 arjo129 added the enhancement New feature or request label Dec 20, 2024
@luca-della-vedova
Copy link
Member

If I remember correctly, one of the intentions behind using the ChangePlugin for submitting changes to components rather than writing directly to their value was exactly for this reason, to be able to intercept them and save an undo redo buffer (there is a comment about it).

Note however that the Change plugin does not cover everything. Specifically entity creation and deletion does not go through a Change plugin. However I can imagine intercepting the Delete events to undo / redo deletion and keeping track of what was created to undo creation.
There might also be other component changes that don't go through a Change plugin but I'm not 100% sure

@arjo129
Copy link
Member Author

arjo129 commented Dec 20, 2024

Yeah I do believe that was one of the reasons to use the change plugin, IIRC that it does not cover movement (which is often the thing I want to undo most often).

@arjo129 arjo129 linked a pull request Dec 27, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants