[gnome-robots] Remove the status bar
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-robots] Remove the status bar
- Date: Sat, 21 Jun 2014 16:42:23 +0000 (UTC)
commit c6c85eb1147cfd9389f254b36158ad7a698bfadb
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sat Jun 21 11:30:00 2014 -0500
Remove the status bar
Show level and score in the header bar subtitle. Show safe teleports
remaining in the safe teleports button. Don't show enemies remaining
anywhere.
po/POTFILES.in | 1 -
src/Makefile.am | 2 -
src/game.c | 32 +-----
src/gnome-robots.c | 47 ++++++--
src/gnome-robots.h | 2 +-
src/graphics.h | 2 +
src/statusbar.c | 312 ----------------------------------------------------
src/statusbar.h | 22 ----
8 files changed, 45 insertions(+), 375 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 34b773a..c77de0e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -12,4 +12,3 @@ src/games-stock.c
src/gnome-robots.c
src/graphics.c
src/properties.c
-src/statusbar.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 79dc78f..1a32501 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,8 +3,6 @@ bin_PROGRAMS = gnome-robots
gnome_robots_SOURCES = \
gnome-robots.c \
gnome-robots.h \
- statusbar.c \
- statusbar.h \
gameconfig.c \
gameconfig.h \
properties.c \
diff --git a/src/game.c b/src/game.c
index a56a823..4826a2c 100644
--- a/src/game.c
+++ b/src/game.c
@@ -35,7 +35,6 @@
#include "sound.h"
#include "properties.h"
#include "menu.h"
-#include "statusbar.h"
#include "graphics.h"
#include "cursors.h"
#include "games-scores.h"
@@ -100,12 +99,6 @@ 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
@@ -313,9 +306,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);
+ update_game_status (score, current_level + 1, safe_teleports);
}
@@ -438,7 +429,7 @@ generate_level (void)
safe_teleports = game_config ()->max_safe_teleports;
}
- update_safe_teleport_action ();
+ update_game_status (score, current_level, safe_teleports);
for (i = 0; i < num_robots1; ++i) {
while (1) {
@@ -527,9 +518,7 @@ update_arena (void)
}
}
- gnobots_statusbar_set (score, current_level + 1, safe_teleports,
- num_robots1, num_robots2);
-
+ update_game_status (score, current_level + 1, safe_teleports);
}
@@ -570,8 +559,7 @@ timeout_cb (void *data)
generate_level ();
game_state = STATE_PLAYING;
set_move_action_sensitivity (TRUE);
- gnobots_statusbar_set (score, current_level + 1, safe_teleports,
- num_robots1, num_robots2);
+ update_game_status (score, current_level + 1, safe_teleports);
}
} else if (game_state == STATE_DEAD) {
++endlev_counter;
@@ -663,23 +651,15 @@ 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 ();
generate_level ();
clear_game_area ();
- if (game_config ()->maximum_type2 > 0) {
- gnobots_statusbar_show_both (TRUE);
- } else {
- gnobots_statusbar_show_both (FALSE);
- }
-
game_state = STATE_PLAYING;
- gnobots_statusbar_set (score, current_level + 1, safe_teleports,
- num_robots1, num_robots2);
+ update_game_status (score, current_level + 1, safe_teleports);
set_move_action_sensitivity (TRUE);
}
@@ -1252,7 +1232,7 @@ safe_teleport (void)
reset_player_animation ();
safe_teleports -= 1;
- update_safe_teleport_action ();
+ update_game_status (score, current_level, safe_teleports);
update_arena ();
break;
diff --git a/src/gnome-robots.c b/src/gnome-robots.c
index 9c4ae1d..730ff21 100644
--- a/src/gnome-robots.c
+++ b/src/gnome-robots.c
@@ -30,7 +30,6 @@
#include <glib.h>
#include "gbdefs.h"
-#include "statusbar.h"
#include "gameconfig.h"
#include "graphics.h"
#include "sound.h"
@@ -57,7 +56,6 @@ static gboolean window_is_fullscreen = FALSE, window_is_maximized = FALSE;
GtkWidget *game_area = NULL;
GamesScores *highscores;
GSettings *settings;
-GSimpleAction *safe_teleport_action;
/**********************************************************************/
/**********************************************************************/
@@ -112,6 +110,10 @@ static const GamesScoresCategory scorecats[] = {
{"robots_with_safe_teleport-super-safe", N_("Robots with safe teleport with super-safe moves")}
};
+static gint safe_teleports = 0;
+static GtkWidget *safe_teleports_label;
+static GtkWidget *headerbar;
+
/**********************************************************************/
/**********************************************************************/
@@ -127,12 +129,39 @@ set_move_action_sensitivity (gboolean state)
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), state);
action = g_action_map_lookup_action (G_ACTION_MAP (window), "safe-teleport");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), state);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), state && safe_teleports > 0);
action = g_action_map_lookup_action (G_ACTION_MAP (window), "wait");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), state);
}
+void
+update_game_status (gint score, gint current_level, gint safes)
+{
+ GAction *action;
+ gchar *subtitle, *remaining_teleports_text, *button_text;
+
+ /* Window subtitle. The first %d is the level, the second is the score. \t creates a tab. */
+ subtitle = g_strdup_printf (_("Level: %d\tScore: %d"), current_level, score);
+ gtk_header_bar_set_subtitle (GTK_HEADER_BAR (headerbar), subtitle);
+ g_free (subtitle);
+
+ safe_teleports = safes;
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), "safe-teleport");
+ if (g_action_get_enabled (action))
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), safe_teleports > 0);
+
+ /* Second line of safe teleports button label. %d is the number of teleports remaining. */
+ remaining_teleports_text = g_strdup_printf (_("(Remaining: %d)"), safe_teleports);
+ /* First line of safe teleports button label. */
+ button_text = g_strdup_printf ("%s\n<small>%s</small>", _("Teleport _Safely"), remaining_teleports_text);
+ gtk_label_set_markup_with_mnemonic (GTK_LABEL (safe_teleports_label), button_text);
+
+ g_free (remaining_teleports_text);
+ g_free (button_text);
+}
+
static void
preferences_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
@@ -296,7 +325,7 @@ shutdown (GtkApplication *app, gpointer user_data)
static void
activate (GtkApplication *app, gpointer user_data)
{
- GtkWidget *errordialog, *vbox, *hbox, *label, *button, *statusbar, *gridframe, *headerbar;
+ GtkWidget *errordialog, *vbox, *hbox, *label, *button, *gridframe;
GtkSizeGroup *size_group;
GtkBuilder *builder;
GMenuModel *appmenu;
@@ -318,15 +347,11 @@ 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);
g_object_unref (builder);
- statusbar = gnobots_statusbar_new ();
-
make_cursors ();
game_area = gtk_drawing_area_new ();
@@ -356,11 +381,12 @@ activate (GtkApplication *app, gpointer user_data)
gtk_size_group_add_widget (size_group, button);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- label = gtk_label_new_with_mnemonic (_("Teleport _Safely"));
+ safe_teleports_label = gtk_label_new (NULL);
+ gtk_label_set_justify (GTK_LABEL (safe_teleports_label), GTK_JUSTIFY_CENTER);
gtk_widget_set_margin_top (label, 15);
gtk_widget_set_margin_bottom (label, 15);
button = gtk_button_new ();
- gtk_container_add (GTK_CONTAINER (button), label);
+ gtk_container_add (GTK_CONTAINER (button), safe_teleports_label);
gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "win.safe-teleport");
gtk_size_group_add_widget (size_group, button);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
@@ -379,7 +405,6 @@ activate (GtkApplication *app, gpointer user_data)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_box_pack_start (GTK_BOX (vbox), gridframe, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
diff --git a/src/gnome-robots.h b/src/gnome-robots.h
index e57073f..98cfa91 100644
--- a/src/gnome-robots.h
+++ b/src/gnome-robots.h
@@ -12,13 +12,13 @@ extern GtkWidget *window;
extern GtkWidget *game_area;
extern GamesScores *highscores;
extern GSettings *settings;
-extern GSimpleAction *safe_teleport_action;
/**********************************************************************/
/**********************************************************************/
/* Exported functions */
/**********************************************************************/
void set_move_action_sensitivity (gboolean state);
+void update_game_status (gint score, gint level, gint safe_teleports);
void quit_game (void);
/**********************************************************************/
diff --git a/src/graphics.h b/src/graphics.h
index e50aae6..5ed44e2 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -1,6 +1,8 @@
#ifndef GRAPHICS_H
#define GRAPHICS_H
+#include <gtk/gtk.h>
+
/* The size of an individual tile. */
extern gint tile_width;
extern gint tile_height;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]