Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (723)
Games in Android Showcase (216)
games submitted by our members
Games in WIP (790)
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 26115 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  
You cannot reply to this message, because it is very, very old.

buddyBro (183 views)
2017-04-05 03:38:00

CopyableCougar4 (614 views)
2017-03-24 15:39:42

theagentd (607 views)
2017-03-24 15:32:08

Rule (659 views)
2017-03-19 12:43:22

Rule (632 views)
2017-03-19 12:42:17

Rule (637 views)
2017-03-19 12:36:21

theagentd (649 views)
2017-03-16 05:07:07

theagentd (583 views)
2017-03-15 22:37:06

theagentd (423 views)
2017-03-15 22:32:18

theagentd (352 views)
2017-03-15 22:31:11
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51 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!