FreeOrion

Forums for the FreeOrion project
It is currently Sat Dec 16, 2017 5:18 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Undo button
PostPosted: Thu Aug 17, 2017 1:53 am 
Offline
AI Lead, Programmer
User avatar

Joined: Sat Sep 22, 2012 6:25 pm
Posts: 4390
some discussion about the Continue feature has led to discussion about an undo button, which I think should be in it's own thread, so...

Morlic wrote:
A player wants to move fleet A to system Alpha but mistakenly had fleet B selected which was on its way to system Beta.
The easiest way for him to correct this mistake is to press an undo button especially if he forgot what the previous order for fleet B was (e.g. fleet B is one of many colonization ships sent to a lot of different systems).
biza wrote:
Thank you Morlic, that was exactly my thoughts.


OK, well, that's a rather different kind of thing, which I think could be supported but in a different kind of way. I was talking about recording orders as you go, during a turn, so that if the computer rebooted or the game crashed those orders could still be read back and repeated without the player having to make all those determinations again (a fairly rare need and not a big deal, but could be nice to have). That wouldn't really do much to support this kind of 'undo' button that you are talking about though, not particularly well anyways-- yes you could keep the full sequence of all orders (or at least all fleet movement orders) and then search for the second-most-recent move order for that particular fleet, and then perhaps just try reapplying that same original order, or better yet try to determine where in that move path you might now be and just reapply the remaining portion of it, but that seems to get a bit messy and uncertain.

I think that really if you were wanting to support an undo button then by far the best approach would be more focused on specifically saving state information which could be referenced for an undo. You could have the MapWnd keep a record related to the most recent order (or perhaps even the most recent N orders), wherein it would store all the necessary information to properly undo that order. For fleet path orders it would be the specifics of the fleet ID and preexisting path, for ship-transfer / fleet-merge orders it would be info on the fleets and ship lists, etc. I think it could even could be made to work for undoing the deletion of a production queue item, though that would probably be one of the trickier ones. Maintaining this info purely in the MapWnd would mean that the undo records would be erased at the start of each new turn and upon any savegame file load, but that seems pretty consistent with typical undo abilities to me.

_________________
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0


Top
 Profile  
 
 Post subject: Re: Undo button
PostPosted: Thu Aug 17, 2017 7:14 am 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12042
Location: Munich
Dilvish wrote:
...saving state information which could be referenced for an undo. You could have the MapWnd keep a record related to the most recent order (or perhaps even the most recent N orders), wherein it would store all the necessary information to properly undo that order.
Orders are stored in the OrderSet indexed by numbers that increment in the order (NPI) they are issued, so there doesn't need to be any storage of orders or the order in which they were issued. This info is necessarily saved when saving a game and restored when loading.
Quote:
For fleet path orders it would be the specifics of the fleet ID and preexisting path
It shouldn't be difficult to add a record to a FleetMoveOrder to keep track of what the destination was before the order was executed.
Quote:
...for ship-transfer / fleet-merge orders it would be info on the fleets and ship lists, etc.
It already stores the ship ids as part of the order, so would just need to keep track of the fleet they were in before the order was executed.
Quote:
I think it could even could be made to work for undoing the deletion of a production queue item, though that would probably be one of the trickier ones.
ProductionQueueOrder is already a bit of a mess, and would probably be best split into ~8 distinct order types which can attempt to store the relevant queue indices and/or production queue element info necessary to undo all the variations of that order.

A bit more tricky is the reworking of the OrderSet to allow redoing orders that have been undone.


Top
 Profile  
 
 Post subject: Re: Undo button
PostPosted: Thu Aug 17, 2017 5:59 pm 
Offline
AI Lead, Programmer
User avatar

Joined: Sat Sep 22, 2012 6:25 pm
Posts: 4390
Hmm, I had been thinking that for an undo button it would be simpler to simply store with the UI the info needed specifically for the undo, rather than increasing the information that gets sent back and forth to server and saved with games, but on thinking about it more I agree it does sound better to primarily rely on expanding the existing support for cancel/undo within the Order classes.

_________________
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group