Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adds Undo/Redo to ReClass.NET #263

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

Open
FransBouma wants to merge 17 commits into ReClassNET:master
base: master
Choose a base branch
Loading
from FransBouma:UndoRedo

Conversation

@FransBouma
Copy link

@FransBouma FransBouma commented Jul 4, 2023
edited
Loading

I've implemented this in a separate branch (with the changes from my previous PR #262 already merged).

What's changed?

  • Undo/Redo support for class creation/deletion/modification
  • Undo/Redo support for changing nodes / node types / address etc.
  • Added an undo/redo button pair to the toolbar using the existing icons already in the resources
  • Defined some toolbar buttons for some node types to be able to overflow the toolbar if the window is narrow

I didn't implement undo/redo for enums as the enum functionality is a bit broken I think (there's an add event but not a remove event for instance. I had it working more or less but didn't want to add it just yet) so I left it as-is.

I added this using Algorithmia's command system. This is a library I wrote a long time ago and maintain since, and it's very stable. It comes with 2 nuget packages (algorithmia and bcl extensions).

The system basically tracks commands executed through the command queue manager and records every command in the 'active' queue on top of the stack. So when a command A changes something that executes a command B, B will end up in A's command queue and B's command queue is then put on top of the stack. This way you can track multiple commands within the scope of a single command and undo/redo them in 1 go. A command is an object with a lambda that makes a change and it has optional lambda's to obtain the pre-change state and the post-change state. Algorithmia has several datastructures that mimic BCL classes (like list) and wrappers (to wrap members to make them undo/redo aware) and they take care of change checking and event raising as well.

I have tested it with several class hierarchies and I think it works ok, but I know from experience that Undo/Redo code can get hairy at times especially in edge cases, e.g. multiple undo/redo sequences work ok but perhaps I missed an edge case and an event handler creates duplicate elements when redoing the whole tree of commands.

Let me know if you need additional info, or if I have to make additional changes :)

NOTE the commits in this PR are apparently also the ones in #262 :( Which sucks, and might be complicate file reviewing. If you want to wait reviewing this because of that, that's fine. I'm sorry this happened, I honestly don't know how to avoid that.

Zyano0x and bukowa reacted with hooray emoji GH-Rake, Sightem, jdpatdiscord, vinoross0, and bukowa reacted with heart emoji
FransBouma added 17 commits July 3, 2023 12:23
...olbar button to toolbar menu item so it can have a shortcut too.
...sable from different nodes. Changed VTable node so it always displays the RTTI information if available.
...e class. This required some hairy work in a lot of places as the context menu wasn't usable on nested classes. It now is
...ks without opening the menu. Made the window a bit wider (was too small already) so all toolbar buttons are visible
... the window is too narrow to make room for undo/redo buttons
...romBuffer to MemoryBuffer, have refactored Hex32Node to use this method instead, have removed unnecessary braces and brackets.
...dlers to the ShowException method in Program so it always catches all exceptions thrown
Copy link

Sightem commented Oct 16, 2023

Status on this?

Copy link
Author

I think @KN4CK3R has to find some time to handle this, and perhaps is currently busy with other things. If you want to use it, you can pull this PR's code and build it yourself.

Sightem reacted with rocket emoji

Copy link

bukowa commented Oct 4, 2025

It would be great if it were possible to view and go back to any point in the history, and if that history was saved directly in the structure (project) file itself.

Copy link

bukowa commented Oct 4, 2025

I am just testing and it's pretty buggy overall.

Copy link
Author

I am just testing and it's pretty buggy overall.

What does 'buggy' mean in this case?

Copy link

bukowa commented Oct 4, 2025

When you play around adding removing stuff undo / redo does not properly bring back previous state of the offset.

Copy link
Author

Hmm, strange, it worked fine when I wrote it. It's been a very long time I looked at it tho

Copy link

bukowa commented Oct 4, 2025

It mostly is :) Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /