[gnome-robots] Disable safe teleport when out of safe teleports
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-robots] Disable safe teleport when out of safe teleports
- Date: Sat, 21 Jun 2014 15:24:43 +0000 (UTC)
commit 108c7b0a363d6b25277bee839366a33affbeb61f
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sat Jun 21 10:16:01 2014 -0500
Disable safe teleport when out of safe teleports
It's confusing that safe teleport falls back to random teleport when
you're out of safe teleports. Simply disable this action when no safe
teleports are remaining.
https://bugzilla.gnome.org/show_bug.cgi?id=535006
src/game.c | 13 ++++++++++++-
src/gnobots.c | 3 +++
src/gnobots.h | 1 +
3 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/game.c b/src/game.c
index b568e49..d64599a 100644
--- a/src/game.c
+++ b/src/game.c
@@ -100,6 +100,12 @@ static gboolean safe_teleport (void);
/* Function Definitions */
/**********************************************************************/
+static void
+update_safe_teleport_action (void)
+{
+ g_simple_action_set_enabled (safe_teleport_action, safe_teleports > 0);
+}
+
/**
* message_box
* @msg: message
@@ -307,6 +313,7 @@ add_kill (gint type)
safe_teleports = game_config ()->max_safe_teleports;
}
+ update_safe_teleport_action ();
gnobots_statusbar_set (score, current_level + 1, safe_teleports,
num_robots1, num_robots2);
}
@@ -431,6 +438,8 @@ generate_level (void)
safe_teleports = game_config ()->max_safe_teleports;
}
+ update_safe_teleport_action ();
+
for (i = 0; i < num_robots1; ++i) {
while (1) {
xp = rand () % GAME_WIDTH;
@@ -654,6 +663,7 @@ start_new_game (void)
g_return_if_fail (conf != NULL);
safe_teleports = conf->initial_safe_teleports;
+ update_safe_teleport_action ();
remove_bubble ();
reset_player_animation ();
@@ -1217,7 +1227,7 @@ safe_teleport (void)
}
if (safe_teleports <= 0)
- return random_teleport ();
+ return FALSE;
for (i = 0; i < GAME_WIDTH; ++i) {
for (j = 0; j < GAME_HEIGHT; ++j) {
@@ -1242,6 +1252,7 @@ safe_teleport (void)
reset_player_animation ();
safe_teleports -= 1;
+ update_safe_teleport_action ();
update_arena ();
break;
diff --git a/src/gnobots.c b/src/gnobots.c
index c98d047..72d2a6e 100644
--- a/src/gnobots.c
+++ b/src/gnobots.c
@@ -57,6 +57,7 @@ static gboolean window_is_fullscreen = FALSE, window_is_maximized = FALSE;
GtkWidget *game_area = NULL;
GamesScores *highscores;
GSettings *settings;
+GSimpleAction *safe_teleport_action;
/**********************************************************************/
/**********************************************************************/
@@ -301,6 +302,8 @@ activate (GtkApplication *app, gpointer user_data)
g_action_map_add_action_entries (G_ACTION_MAP (app), app_entries, G_N_ELEMENTS (app_entries), app);
g_action_map_add_action_entries (G_ACTION_MAP (window), win_entries, G_N_ELEMENTS (win_entries), app);
+ safe_teleport_action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (window),
"safe-teleport"));
+
builder = gtk_builder_new_from_file (g_build_filename (DATA_DIRECTORY, "app-menu.ui", NULL));
appmenu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
gtk_application_set_app_menu (app, appmenu);
diff --git a/src/gnobots.h b/src/gnobots.h
index 5afad15..e57073f 100644
--- a/src/gnobots.h
+++ b/src/gnobots.h
@@ -12,6 +12,7 @@ extern GtkWidget *window;
extern GtkWidget *game_area;
extern GamesScores *highscores;
extern GSettings *settings;
+extern GSimpleAction *safe_teleport_action;
/**********************************************************************/
/**********************************************************************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]