gnome-chess currently disables undo functionality when a game has ended.

This commit keeps the undo button enabled even after end of a game.
User can now undo a move even after a checkmate or a draw.

Closes #44
This commit is contained in:
Amandeep Singh 2020-10-14 13:20:34 +05:30 committed by Michael Catanzaro
parent 7e3368f278
commit 0ab9614e13
3 changed files with 14 additions and 18 deletions

View file

@ -216,8 +216,17 @@ public class ChessGame : Object
if (move_stack.next == null)
return;
/* Pop off the move state and notify */
/* Pop off the move state */
move_stack.remove_link (move_stack);
/* Restart the game if undo was done after end of the game */
if (result != ChessResult.IN_PROGRESS)
{
result = ChessResult.IN_PROGRESS;
start ();
}
/* Notify */
undo ();
}

View file

@ -78,11 +78,6 @@ public class ChessEngineCECP : ChessEngine
stop ();
error ();
}
else if (line.has_prefix ("1-0") || line.has_prefix ("0-1"))
{
/* The engine thinks the game is over and will not play on. */
stop ();
}
else if (line == "game is a draw" ||
line == "draw" ||
line == "Draw" ||

View file

@ -1163,6 +1163,7 @@ Copyright © 20152016 Sahil Sareen""";
/* Remove from the PGN game */
pgn_game.moves.remove_link (pgn_game.moves.last ());
pgn_game.result = PGNGame.RESULT_IN_PROGRESS;
/* Remove from the history */
var model = (Gtk.ListStore) history_combo.model;
@ -1255,6 +1256,7 @@ Copyright © 20152016 Sahil Sareen""";
/* Window title on Black's turn if Black is a computer */
headerbar.set_title (_("Black is Thinking…"));
}
headerbar.set_subtitle (null);
}
private void update_pause_resume_button ()
@ -1281,7 +1283,6 @@ Copyright © 20152016 Sahil Sareen""";
private void game_end_cb ()
{
disable_window_action (RESIGN_ACTION_NAME);
disable_window_action (UNDO_MOVE_ACTION_NAME);
disable_window_action (PAUSE_RESUME_ACTION_NAME);
/* In case of engine desync before the first move, or after undo */
@ -1289,9 +1290,6 @@ Copyright © 20152016 Sahil Sareen""";
game_needs_saving = false;
if (opponent_engine != null)
opponent_engine.stop ();
string title = "";
switch (game.result)
{
@ -1502,15 +1500,12 @@ Copyright © 20152016 Sahil Sareen""";
var response = dialog.run ();
dialog.destroy ();
game.unpause ();
if (response == ResponseType.ACCEPT)
{
game.current_player.claim_draw ();
}
else
{
game.unpause ();
}
}
public void new_game_cb ()
@ -1540,6 +1535,7 @@ Copyright © 20152016 Sahil Sareen""";
var response = dialog.run ();
dialog.destroy ();
game.unpause ();
if (response == ResponseType.ACCEPT)
{
@ -1548,10 +1544,6 @@ Copyright © 20152016 Sahil Sareen""";
else
game.current_player.resign ();
}
else
{
game.unpause ();
}
}
public void undo_move_cb ()