Undo / Redo

BlitzPlus Forums/BlitzPlus Programming/Undo / Redo

thalamus(Posted 2005) [#1]
Anyone had any experience coding an Undo/Redo routine?


CS_TBL(Posted 2005) [#2]
It's not like a single function orso.. You must know at forehand that you need undo/redo. Just create a copy of all your relevant variables/data and switch between that copy and your current crop o' vars/data.

with types (I think):

MyApp.vars=new vars
Undo.vars=new vars

with banks:

MyApp=CreateBank(size)
Undo=Createbank(banksize(MyApp))

Those are adviced..

with just variables it's less handy

var1=1
var2=4
var3=7

would lead to:

var1undo=var1
var2undo=var2
var3undo=var3

Another way is to create small arrays of your variables

normal=0
undo=1

dim var1(1)
dim var2(1)
dim var3(1)

var1(normal)=var
var1(undo)=var1(normal)

etc.

Naturally, if you'll go like this, know that vars and arrays suck if you'll use them like this. :)

My personal fav. would be the bank-method.


Regular K(Posted 2005) [#3]
An idea would be to, every 100ms or so, take all the variables, and add them to a new bank. And then you could have a few undos.

To undo, go through all the strings or whatever in that bank and put them back. It would work.


JoshK(Posted 2005) [#4]
No, you create a new undo state every time something changes, not every 100 msecs.