-
Notifications
You must be signed in to change notification settings - Fork 373
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
Adds Undo/Redo to ReClass.NET #263
Open
FransBouma
wants to merge
17
commits into
ReClassNET:master
Choose a base branch
from
FransBouma:UndoRedo
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…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
…table pointer automatically.
…ks without opening the menu. Made the window a bit wider (was too small already) so all toolbar buttons are visible
… it gets removed when the window is too narrow
… 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
…ost elements are now undo/redo aware
Status on this? |
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've implemented this in a separate branch (with the changes from my previous PR #262 already merged).
What's changed?
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.