Do not directly pause/unpause the chess clock
https://bugzilla.gnome.org/show_bug.cgi?id=728202
This commit is contained in:
parent
434687157d
commit
a4148ca589
3 changed files with 10 additions and 14 deletions
|
@ -51,6 +51,7 @@ public class ChessGame : Object
|
|||
public signal void ended ();
|
||||
|
||||
public bool is_paused { get; private set; default = false; }
|
||||
public bool should_show_paused_overlay { get; private set; default = false; }
|
||||
|
||||
public ChessState current_state
|
||||
{
|
||||
|
@ -298,12 +299,13 @@ public class ChessGame : Object
|
|||
get { return move_stack.length() - 1; }
|
||||
}
|
||||
|
||||
public void pause ()
|
||||
public void pause (bool show_overlay = true)
|
||||
{
|
||||
if (clock != null && result == ChessResult.IN_PROGRESS && !is_paused)
|
||||
{
|
||||
clock.pause ();
|
||||
is_paused = true;
|
||||
should_show_paused_overlay = show_overlay;
|
||||
paused ();
|
||||
}
|
||||
}
|
||||
|
@ -314,6 +316,7 @@ public class ChessGame : Object
|
|||
{
|
||||
clock.unpause ();
|
||||
is_paused = false;
|
||||
should_show_paused_overlay = false;
|
||||
unpaused ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public class ChessView : Gtk.DrawingArea
|
|||
}
|
||||
|
||||
/* Draw pause overlay */
|
||||
if (scene.game.is_paused)
|
||||
if (scene.game.should_show_paused_overlay)
|
||||
{
|
||||
c.rotate (Math.PI * scene.board_angle / 180.0);
|
||||
draw_paused_overlay (c);
|
||||
|
@ -273,7 +273,7 @@ public class ChessView : Gtk.DrawingArea
|
|||
|
||||
public override bool button_press_event (Gdk.EventButton event)
|
||||
{
|
||||
if (scene.game == null || event.button != 1 || scene.game.is_paused)
|
||||
if (scene.game == null || event.button != 1 || scene.game.should_show_paused_overlay)
|
||||
return false;
|
||||
|
||||
int file = (int) Math.floor((event.x - 0.5 * get_allocated_width () + square_size * 4) / square_size);
|
||||
|
|
|
@ -1381,9 +1381,7 @@ public class ChessApplication : Gtk.Application
|
|||
private void present_claim_draw_dialog ()
|
||||
requires (game.can_claim_draw ())
|
||||
{
|
||||
/* Manually since we don't want to show the pause overlay */
|
||||
if (game.clock != null)
|
||||
game.clock.pause ();
|
||||
game.pause (false);
|
||||
|
||||
var dialog = new Gtk.MessageDialog (window,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
|
@ -1426,9 +1424,7 @@ public class ChessApplication : Gtk.Application
|
|||
{
|
||||
/* Display this dialog only once per game */
|
||||
allow_claim_draw_dialog = false;
|
||||
|
||||
if (game.clock != null)
|
||||
game.clock.unpause ();
|
||||
game.unpause ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1440,9 +1436,7 @@ public class ChessApplication : Gtk.Application
|
|||
|
||||
public void resign_cb ()
|
||||
{
|
||||
/* Manually since we don't want to show the pause overlay */
|
||||
if (game.clock != null)
|
||||
game.clock.pause ();
|
||||
game.pause (false);
|
||||
|
||||
var dialog = new Gtk.MessageDialog (window,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
|
@ -1471,8 +1465,7 @@ public class ChessApplication : Gtk.Application
|
|||
}
|
||||
else
|
||||
{
|
||||
if (game.clock != null)
|
||||
game.clock.unpause ();
|
||||
game.unpause ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue