summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliot Fairweather <elliot.fairweather@collabora.co.uk>2008-07-31 23:53:20 (GMT)
committerElliot Fairweather <elliot.fairweather@collabora.co.uk>2008-07-31 23:53:20 (GMT)
commit23cbfbba4de3b6129656c98d7fc44cae85ebd925 (patch)
treee6782e77d864be930c7289649371c4f5183d0b19
parent90c1bdd36ad14fa9c187aa024be8eb6db4b451e2 (diff)
downloadtictactube-23cbfbba4de3b6129656c98d7fc44cae85ebd925.tar.gz
tictactube-23cbfbba4de3b6129656c98d7fc44cae85ebd925.tar.xz
add player number parameter to game current player changed signal
20080731235320-82d1e-62ba927cd4b6a90a59800624305b317393b4a44c.gz
-rw-r--r--src/ttt-game.c10
-rw-r--r--src/ttt-ui.c20
2 files changed, 17 insertions, 13 deletions
diff --git a/src/ttt-game.c b/src/ttt-game.c
index 665a863..1f8f7a8 100644
--- a/src/ttt-game.c
+++ b/src/ttt-game.c
@@ -123,8 +123,8 @@ ttt_game_class_init (TttGameClass *klass)
G_TYPE_NONE, 0);
signals[CURRENT_PLAYER_CHANGED] =
g_signal_new ("current-player-changed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1, G_TYPE_UINT);
signals[WARNING] =
g_signal_new ("warning", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__UINT,
@@ -399,7 +399,8 @@ ttt_game_model_iface_undecided_cb (TttModelIface *iface,
if (priv->current_player->local)
priv->local_player = priv->current_player;
- g_signal_emit (game, signals[CURRENT_PLAYER_CHANGED], 0);
+ g_signal_emit (game, signals[CURRENT_PLAYER_CHANGED], 0,
+ priv->current_player->number);
ttt_model_iface_print (priv->model);
g_signal_emit (game, signals[MODEL_UPDATED], 0);
@@ -527,7 +528,8 @@ ttt_game_ready_check (TttGame *game)
priv->local_player = priv->current_player;
//
- g_signal_emit (game, signals[CURRENT_PLAYER_CHANGED], 0);
+ g_signal_emit (game, signals[CURRENT_PLAYER_CHANGED], 0,
+ priv->current_player->number);
g_signal_emit (game, signals[READY], 0);
}
diff --git a/src/ttt-ui.c b/src/ttt-ui.c
index 84201a0..9d239be 100644
--- a/src/ttt-ui.c
+++ b/src/ttt-ui.c
@@ -86,7 +86,7 @@ static void ttt_ui_game_ended_cb (TttGame *game,
guint player_number, gpointer data);
static void ttt_ui_game_model_updated_cb (TttGame *game, gpointer data);
static void ttt_ui_game_current_player_changed_cb (TttGame *game,
- gpointer data);
+ guint player_number, gpointer data);
static void ttt_ui_game_warning_cb (TttGame *game, guint warning,
gpointer data);
static void ttt_ui_game_closed_cb (TttGame *game, gpointer data);
@@ -588,18 +588,16 @@ ttt_ui_set_up_new_game (TttUi *ui,
static void
ttt_ui_game_current_player_changed_cb (TttGame *game,
+ guint player_number,
gpointer data)
{
TttUi *ui = TTT_UI (data);
TttUiPriv *priv = GET_PRIV (ui);
- TttGamePlayer *current_player;
+ TttGamePlayer *player;
gchar *label;
gchar *markup;
- g_object_get (G_OBJECT (priv->game), "current-player",
- &current_player, NULL);
-
- if (current_player->number == 1)
+ if (player_number == 1)
{
gtk_label_set_text (GTK_LABEL (priv->player2_label),
"Player 2");
@@ -620,9 +618,13 @@ ttt_ui_game_current_player_changed_cb (TttGame *game,
g_free (markup);
- if (current_player->local)
- label = g_strdup_printf ("%s, it's your turn",
- current_player->name);
+ if (player_number == 1)
+ g_object_get (G_OBJECT (priv->game), "player1", &player, NULL);
+ else
+ g_object_get (G_OBJECT (priv->game), "player2", &player, NULL);
+
+ if (player->local)
+ label = g_strdup_printf ("%s, it's your turn", player->name);
else
label = g_strdup ("Waiting for other player to move");