/* Random object descriptions. */
/****************************************************************/
-char *
+static char *
description (void)
{
int r;
/* Placing objects. */
/****************************************************************/
-void
+static void
place_in_arena_at_xy (GtkWidget *item, int x, int y)
{
arena[x][y] = item;
}
}
-void
+static void
place_in_arena_randomly (GtkWidget *item)
{
int x, y;
/* Labels representing things the robot might find. */
/****************************************************************/
-GtkWidget *
+static GtkWidget *
random_character (gchar *description)
{
gchar character[2] = { random() % ('~'-'!') + '!', 0 };
/* Talking back to the user. */
/****************************************************************/
-void
+static void
show_message (const char *message)
{
HildonNote* note = HILDON_NOTE
/****************************************************************/
/* Loading the non-kitten objects. */
/****************************************************************/
-void
+
+static void
ensure_messages_loaded (void)
{
FILE *nki_file = NULL;
fclose (nki_file);
}
-void
+static void
load_images (void)
{
robot_pic = gdk_pixbuf_new_from_file ("/usr/share/rfk/rfk-robot.png", NULL);
/****************************************************************/
/* Stop doing that, and do something else. */
/****************************************************************/
+
static void
switch_state (StateOfPlay new_state)
{
/****************************************************************/
/* Things we need DBus for: online help, and vibration. */
/****************************************************************/
+
static void
call_dbus (DBusBusType type,
char *name,
gdk_draw_pixbuf (GDK_DRAWABLE(widget->window),
gc,
scaled_love_pic, 0, 0,
- robot_x + gdk_pixbuf_get_width (robot_pic), all_y,
+ robot_x + gdk_pixbuf_get_width (robot_pic) +
+ (gdk_pixbuf_get_width (love_pic)-love_size)/2,
+ all_y + (gdk_pixbuf_get_height (love_pic)-love_size)/2,
-1, -1,
GDK_RGB_DITHER_NONE, 0, 0);
- love_size ++;
+ love_size += 10;
if (love_size >= gdk_pixbuf_get_width (love_pic))
{
{ GDK_Up, 'k', 0, -1 }
};
-gboolean
+static gboolean
move_robot (guint8 whichway)
{
GtkWidget *new_space;
/* Event handlers. */
/****************************************************************/
-gboolean
+static gboolean
on_window_clicked (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
return TRUE;
}
-gboolean
+static gboolean
on_key_pressed (GtkWidget *widget,
GdkEventKey *event,
gpointer user_data)
return FALSE;
}
-void
+static void
play_game (gpointer button, gpointer data)
{
switch_state (STATE_PLAYING);
}
static void
+restart (gpointer button, gpointer data)
+{
+ if (current_state == STATE_EPILOGUE)
+ {
+ show_message ("Have patience while robotfindskitten.");
+ }
+ else
+ {
+ switch_state (STATE_PROLOGUE);
+ }
+}
+
+static void
set_up_board (void)
{
guint x, y;
{
GtkWidget *middle = gtk_hbox_new (FALSE, 0);
GtkWidget *buttons = gtk_hbox_new (TRUE, 0);
- GtkWidget *explain = NULL, *help_button, *play_button, *intro;
+ GtkWidget *explain = NULL, *button, *intro;
const char *explanation =
"In this game, you are robot (#). "
"Your job is to find kitten. This task is complicated "
GKeyFile *desktop = g_key_file_new ();
gchar *version;
guint x, y;
+ HildonAppMenu *menu = HILDON_APP_MENU (hildon_app_menu_new ());
/* The window */
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ window = hildon_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "robotfindskitten");
gtk_widget_modify_bg (window, GTK_STATE_NORMAL, &black);
g_signal_connect (G_OBJECT (window), "button-press-event", G_CALLBACK (on_window_clicked), NULL);
version = g_strdup("");
}
- help_button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_THUMB_HEIGHT,
+ button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_THUMB_HEIGHT,
HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
- "Help", NULL);
- g_signal_connect (help_button, "clicked", G_CALLBACK (get_help), NULL);
+ "Play", NULL);
+ g_signal_connect (button, "clicked", G_CALLBACK (play_game), NULL);
- play_button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_THUMB_HEIGHT,
+ gtk_box_pack_end (GTK_BOX (buttons), button, TRUE, TRUE, 0);
+
+ button = hildon_button_new_with_text (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_THUMB_HEIGHT,
HILDON_BUTTON_ARRANGEMENT_HORIZONTAL,
- "Play", NULL);
- g_signal_connect (play_button, "clicked", G_CALLBACK (play_game), NULL);
+ "Help", NULL);
+ g_signal_connect (button, "clicked", G_CALLBACK (get_help), NULL);
+ gtk_box_pack_end (GTK_BOX (buttons), button, TRUE, TRUE, 0);
+
+ /* and another help button, this time for the menu */
+ button = gtk_button_new_with_label ("Help");
+ g_signal_connect (button, "clicked", G_CALLBACK (get_help), NULL);
+ hildon_app_menu_append (menu, GTK_BUTTON (button));
+
+ button = gtk_button_new_with_label ("Restart");
+ g_signal_connect (button, "clicked", G_CALLBACK (restart), NULL);
+ hildon_app_menu_append (menu, GTK_BUTTON (button));
- gtk_box_pack_end (GTK_BOX (buttons), play_button, TRUE, TRUE, 0);
- gtk_box_pack_end (GTK_BOX (buttons), help_button, TRUE, TRUE, 0);
+ gtk_widget_show_all (GTK_WIDGET (menu));
+ hildon_window_set_app_menu (HILDON_WINDOW (window), menu);
explain = gtk_label_new (explanation);
gtk_label_set_line_wrap (GTK_LABEL (explain), TRUE);