From: Lane S. <dow...@gm...> - 2007-12-21 15:21:50
|
Thank you. That's exactly what I needed to know. Lane On Dec 20, 2007 10:45 PM, Sean Bridges <sbr...@ya...> wrote: > You need to mark the changes in the history so you can > tell which are moves, and which are undos. > > You can mark each move/undo in a history event, using > delegateBridge.getHistoryWriter().startEvent(someName). > > When you do a normal move, add the change in a history > event marked "move n" . When you undo a move, add it > in an event called "undo n". When you want to undo a > move, walk back in the tree until you find the last > move that hasn't been undone, find the change for the > move, invert it, apply the change, and your done. > > Sean > > > --- Lane Schwartz <dow...@gm...> wrote: > > > On Dec 20, 2007 8:46 AM, Tony Clayton > > <to...@cl...> wrote: > > > Quoting Lane Schwartz <dow...@gm...>: > > > > > > > Hi all, > > > > > > > > I was wondering about undo functionality. > > > > > > > > I've been tinkering around with a new simple > > single-player game, and > > > > I'd like to add undo functionality. > > > > > > > > I see that I can get a History from the > > GameData, and I know that any > > > > change can has an invert method that gives the > > inverse of the Change. > > > > But I'm not sure how to incorporate the two. > > > > > > > > Here's what I'd like: > > > > > > > > User makes some plays. > > > > User selects Edit->Undo. The most recent play is > > undone and the board > > > > now reflects this. > > > > User could continue playing, or could again > > select undo. User could > > > > keep undoing as far as desired. > > > > > > > > Any tips would be appreciated. I looked through > > the existing codebase, > > > > but I couldn't find any examples that seemed to > > work like this. > > > > > > > > Thanks, > > > > Lane > > > > > > Hi Lane, > > > This sounds interesting, but difficult. The > > History panel reflects the UI at > > > each stage of the game, but does not currently > > have the ability to roll back > > > delegate state or move backwards through > > delegates. > > > This might not even be possible until we finish > > moving all game state out of > > > delegates themselves and into the GameData, I'm > > not sure. > > > > > > The Undo Move panel basically already has this > > same functionality for the > > > undoable move case, which is within the lifecycle > > of a single delegate. > > > In order to move backwards through contiguous > > delegates, you are going to need > > > game engine modifications. I'm not actually sure > > how feasible this is. > > > > > > To implement this generically, you would add this > > as a feature of the > > > EditDelegate. > > > I can see the interface working in a couple ways: > > > 1. On the Edit panel, an Undo button to undo the > > last move. > > > 2. In the History panel, right-click on a node > > and get an "Undo to this point" > > > option (but you can't undo into another player's > > turn, unless you load the game > > > in single-player mode). > > > > > > The history log should show a full history of the > > original turn, and an entry > > > for the Undo operation later on. > > > > > > This sounds like a significant undertaking. Good > > luck if you decide to tackle > > > it. > > > > > > Tony > > > > Tony, > > > > Thanks for the feedback. I guess I wasn't thinking > > of anything as > > ambitious as what you describe. I guess I wasn't > > clear that when I > > said a one-player game, I meant a non-A&A game. > > > > I've actually been implementing the n-puzzle game, > > which is single > > player, and has very simple delegates (no state is > > maintained in the > > delegates). > > > > For n-puzzle, I currently don't have any sort of > > history panel. > > > > My main question is, once you get the most recent > > change, and then > > call the inverse method to get the inverse change, > > how does that get > > applied to the history? If you simply apply the > > inverse change, then > > that will be the new most recent change, and the one > > next back in the > > history won't be accessible if you want to keep > > undoing. > > > > Lane > > > > -- > > When a place gets crowded enough to require ID's, > > social collapse is not > > far away. It is time to go elsewhere. The best > > thing about space travel > > is that it made it possible to go elsewhere. > > -- R.A. Heinlein, "Time Enough For > > Love" > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Microsoft > > Defy all challenges. Microsoft(R) Visual Studio > > 2005. > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > _______________________________________________ > > Triplea-developers mailing list > > Tri...@li... > > > https://lists.sourceforge.net/lists/listinfo/triplea-developers > > > > > > ____________________________________________________________________________________ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ > > -- When a place gets crowded enough to require ID's, social collapse is not far away. It is time to go elsewhere. The best thing about space travel is that it made it possible to go elsewhere. -- R.A. Heinlein, "Time Enough For Love" |