Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (788)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (860)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Software "history" storing methods.  (Read 35469 times)
0 Members and 1 Guest are viewing this topic.
Offline trollwarrior1
« Posted 2013-12-13 21:02:47 »

So I'm making this 2d bone modeler.

The question I would like to ask is what is the "way" to do "history". The thingy with CTRL+Z, Y. Do I store copies of my data every time I change something? But that seems to me that doing that would destroy the memory.

Do I just record what actions were done and reverse them? I tried this, and it seems not to work very properly.
Offline Drenius
« Reply #1 - Posted 2013-12-13 21:42:44 »

It should, if you really store EVERY kind of change...
Offline Opiop
« Reply #2 - Posted 2013-12-13 22:32:44 »

Look at every text editor, for example. They save every single letter you changed (or they should), but generally they group the saved letters by words. I would do this for your program. Instead of saving every tiny change, group together a few small changes. But you have to be careful because you need to only group small changes, as larger changes are far more significant in some cases.

However, my way is still flawed because some smaller changes might also be important. Maybe instead of saving them to memory, you should save them to file. Open a file when the program is started, assign every joint an id and then use that id and save the new modified joint angles/positions/whatever else to the file. When the user presses the back button, simply loop backwards through the text file, getting every id and then assigning the old attributes to that specific joint. When the user exits the program, close the file.

Optional: Save the file to disk when the program exits, or at regular intervals so that if the user experiences a power outage most of their data will still be there.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Troubleshoots

JGO Knight

Medals: 36
Exp: 7-9 months

Damn maths.

« Reply #3 - Posted 2013-12-13 22:37:12 »

Similarly to what Opiop said, though I'm not an expert, I'd store every state of the program on a stack and pop the stack when the user presses ctrl-Z.

Why are all OpenGL tutorials written in Brainf**k?
Offline Drenius
« Reply #4 - Posted 2013-12-14 01:23:35 »

And maybe it is the best to add every undone step to a redo stack that is cleared as soon as a new action is performed...
Offline UtilityFrog

Senior Newbie

Medals: 1

« Reply #5 - Posted 2013-12-14 07:44:13 »

I came across this article recently on the Command Pattern. I haven't used it yet, but one of the things the pattern apparently enables is a method of undo/redo. The site that article comes from, Game Programming Patterns, has a number of great articles on general game programming and architecture.
Pages: [1]
  ignore  |  Print  

hadezbladez (2080 views)
2018-11-16 13:46:03

hadezbladez (798 views)
2018-11-16 13:41:33

hadezbladez (2049 views)
2018-11-16 13:35:35

hadezbladez (412 views)
2018-11-16 13:32:03

EgonOlsen (3443 views)
2018-06-10 19:43:48

EgonOlsen (3665 views)
2018-06-10 19:43:44

EgonOlsen (2270 views)
2018-06-10 19:43:20

DesertCoockie (2991 views)
2018-05-13 18:23:11

nelsongames (3068 views)
2018-04-24 18:15:36

nelsongames (3752 views)
2018-04-24 18:14:32
Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!