[gnome-chess] Remove superpaused state
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Remove superpaused state
- Date: Mon, 6 Jan 2014 23:58:54 +0000 (UTC)
commit 3b02d6206bbbb3f42fb1b328e24926d7a9fa481c
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Jan 6 12:12:19 2014 -0600
Remove superpaused state
This wasn't a very great idea. It also lets you cheat by pausing the
timer without running down the clock. People can simply take the time to
press pause if they want to pause the game.
src/chess-game.vala | 14 ++------------
src/chess-scene.vala | 2 +-
src/chess-view-2d.vala | 2 +-
src/chess-view-3d.vala | 2 +-
src/gnome-chess.vala | 31 ++++++++++---------------------
5 files changed, 15 insertions(+), 36 deletions(-)
---
diff --git a/src/chess-game.vala b/src/chess-game.vala
index 21c41af..2b6abbd 100644
--- a/src/chess-game.vala
+++ b/src/chess-game.vala
@@ -1278,14 +1278,12 @@ public class ChessGame
public signal void started ();
public signal void turn_started (ChessPlayer player);
public signal void moved (ChessMove move);
- public signal void superpaused ();
+ public signal void paused ();
public signal void unpaused ();
public signal void undo ();
public signal void ended ();
public bool is_paused { get; private set; default = false; }
- /* Like normal pause, but also draw pause game overlay */
- public bool is_superpaused { get; private set; default = false; }
public ChessState current_state
{
@@ -1518,24 +1516,16 @@ public class ChessGame
{
clock.pause ();
is_paused = true;
+ paused ();
}
}
- public void superpause ()
- {
- is_superpaused = true;
- pause ();
- /* Draw the pause game overlay */
- superpaused ();
- }
-
public void unpause ()
{
if (clock != null && result == ChessResult.IN_PROGRESS && is_paused)
{
clock.unpause ();
is_paused = false;
- is_superpaused = false;
unpaused ();
}
}
diff --git a/src/chess-scene.vala b/src/chess-scene.vala
index 882b009..4e3a565 100644
--- a/src/chess-scene.vala
+++ b/src/chess-scene.vala
@@ -101,7 +101,7 @@ public class ChessScene : Object
selected_rank = -1;
selected_file = -1;
_game.moved.connect (moved_cb);
- _game.superpaused.connect (paused_cb);
+ _game.paused.connect (paused_cb);
_game.unpaused.connect (unpaused_cb);
_game.undo.connect (undo_cb);
update_board ();
diff --git a/src/chess-view-2d.vala b/src/chess-view-2d.vala
index 3d2eddc..ddeae6a 100644
--- a/src/chess-view-2d.vala
+++ b/src/chess-view-2d.vala
@@ -200,7 +200,7 @@ private class ChessView2D : ChessView
}
/* Draw pause overlay */
- if (scene.game.is_superpaused)
+ if (scene.game.is_paused)
{
c.rotate (Math.PI * scene.board_angle / 180.0);
draw_paused_overlay (c);
diff --git a/src/chess-view-3d.vala b/src/chess-view-3d.vala
index 384d1c2..fe1a13e 100644
--- a/src/chess-view-3d.vala
+++ b/src/chess-view-3d.vala
@@ -240,7 +240,7 @@ private class ChessView3D : ChessView
public override bool draw (Cairo.Context c)
{
- if (scene.game.is_superpaused)
+ if (scene.game.is_paused)
{
glXMakeCurrent (display, X.None, (GLX.Context) null);
c.translate (get_allocated_width () / 2, get_allocated_height () / 2);
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 77da2b7..e9954a2 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -62,6 +62,7 @@ public class Application : Gtk.Application
private ChessPlayer? human_player = null;
private ChessEngine? opponent_engine = null;
private bool widget_sensitivity[8];
+ private bool pause_requested = false;
private enum SensitivityIndex
{
@@ -110,22 +111,6 @@ public class Application : Gtk.Application
this.game_file = game_file;
}
- public bool on_window_focus_out (Gdk.EventFocus focus)
- {
- if (!game.is_paused || !game.is_superpaused)
- game.pause ();
-
- return false;
- }
-
- public bool on_window_focus_in (Gdk.EventFocus focus)
- {
- if (game.is_paused && !game.is_superpaused)
- game.unpause ();
-
- return false;
- }
-
public override void startup ()
{
base.startup ();
@@ -179,8 +164,6 @@ public class Application : Gtk.Application
menu_button.set_menu_model (window_menu);
add_window (window);
- window.focus_out_event.connect (on_window_focus_out);
- window.focus_in_event.connect (on_window_focus_in);
window.icon_name = "gnome-chess";
info_bar = new Gtk.InfoBar ();
@@ -1353,12 +1336,18 @@ public class Application : Gtk.Application
public void pause_resume_cb ()
{
- if (game.is_superpaused)
+ if (pause_requested)
+ {
game.unpause ();
+ pause_requested = false;
+ }
else
- game.superpause ();
+ {
+ game.pause ();
+ pause_requested = true;
+ }
- if (game.is_paused)
+ if (pause_requested)
{
stash_action_sensitivity ();
disable_window_action (RESIGN_ACTION_NAME);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]