Sign in to follow this  
  • entries
    29
  • comments
    35
  • views
    17820

Undo/Redo

Sign in to follow this  
walle

376 views

Hello. Got some progress to show today. Woho. First of all, a thanks to Reiner for making free tile sets to use, I'm currently using one to see what I'm doing.

Here are three screenshots of my progress(click them to see full size):
Screen 1
Here you see the grid, the snap to grid works too. Really easy to make maps fast, will go even faster when I get Undo/Redo up and running, but more about that later.


Screen 2
Here you can see the info box in action, called Navigator in photoshop. Took a while to get it right, but now it works perfectly. The red box follows the what is shown in the form, zoom doesn't work yet but when it does the info box will show that too.


Screen 3
Not much new here, a saved map. We can give the history and layers forms a little attention to then. The names are kind of self-explanatory but well the history form is what is getting the most attention now, it will work so that every action you do can be undone, and also reverted back to in one jump. The layer form will basically show all the layers on the map and enable editing in form of layer order manipulation and such.


Undo and Redo
Now this is my mission, I think I will try the memento pattern.
I will make a interface of an action that all action that you can do in the editor will inherit from, and a history class that keeps a undo and a redo stack of actions. When I pop a state from the undo stack I push it onto the redo stack and the other way around if I redo.
The tricky part I think will be representing actions. I could represent a addTile action with a copy of the tile added, but this will skyrocket my memory usage I guess. I will have to think about this for a while before I begin to code. Suggestions are always welcome [smile].

Well that was this for this day, I hope to be able to do these kind of updates a couple of times a week. Bye to then!
Sign in to follow this  


2 Comments


Recommended Comments

Your approach to the list of actions sounds pretty good to me. I've been thinking of doing it this way for a while in my own editors, but have yet to implement it [smile]. I had planned that the interface would define methods for do/undo/redo, and each operation (addtile, etc.) would just contain the instructions for executing the methods (e.g. add tile index 14 to grid pos 3,4). I would have a fixed length for the history of actions (probably around 100 or so), given that you're unlikely to go back too far in the history to make changes. Just my $0.02.

Share this comment


Link to comment
My thoughts was not to have a fixed lenght of the history, or perhaps just use a circular history, so if you edit to much you can't go back, unless to the initial state oufcource. But not shure yet.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now