[gnome-chess/gnome-3-8] Chess history doesn't work very well
- From: Jason Clinton <jclinton src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/gnome-3-8] Chess history doesn't work very well
- Date: Mon, 15 Apr 2013 04:54:09 +0000 (UTC)
commit 709de641ea3d098b6f17b7a1aa2f5b152601a889
Author: Michael Catanzaro <mike catanzaro gmail com>
Date: Sun Mar 3 16:56:47 2013 -0600
Chess history doesn't work very well
* Autoload the most recent autosaved game instead of the least recent
* Update history upon completing a game, so it's not autoloaded forever
* Autosave even if game was manually loaded from a PGN
https://bugzilla.gnome.org/show_bug.cgi?id=695092
(cherry picked from commit 55f896d1d29c18e491ca774191aa83d64558dcb8)
src/gnome-chess.vala | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index d2062ee..c566a6d 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -135,12 +135,14 @@ public class Application : Gtk.Application
foreach (var profile in ai_profiles)
message ("Detected AI profile %s in %s", profile.name, profile.path);
+ bool from_history = game_file == null ? true : false;
+
/* Load from history if no game requested */
if (game_file == null)
{
var unfinished = history.get_unfinished ();
if (unfinished != null)
- game_file = unfinished.data;
+ game_file = unfinished.last().data;
else
start_new_game ();
}
@@ -149,7 +151,7 @@ public class Application : Gtk.Application
{
try
{
- load_game (game_file, false);
+ load_game (game_file, from_history);
}
catch (Error e)
{
@@ -272,10 +274,6 @@ public class Application : Gtk.Application
private void autosave ()
{
- /* FIXME: Prompt user to save somewhere */
- if (!in_history)
- return;
-
/* Don't autosave if no moves (e.g. they have been undone) or only the computer has moved */
if (!game_needs_saving)
{
@@ -286,10 +284,10 @@ public class Application : Gtk.Application
try
{
- if (game_file != null)
- history.update (game_file, "", pgn_game.result);
- else
+ if (!in_history || game_file == null)
game_file = history.add (pgn_game.date, pgn_game.result);
+ else
+ history.update (game_file, "", pgn_game.result);
debug ("Writing current game to %s", game_file.get_path ());
pgn_game.write (game_file);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]