[gnome-nibbles] Allow setting GAMEDELAY from the command line
- From: Bryan Quigley <bryanquigs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles] Allow setting GAMEDELAY from the command line
- Date: Sun, 14 Sep 2014 03:09:01 +0000 (UTC)
commit b654dbb61876e540733e9c1bbf2f973063d76512
Author: Bryan Quigley <bryanquigs src gnome org>
Date: Sat Sep 13 23:08:23 2014 -0400
Allow setting GAMEDELAY from the command line
src/gnibbles.h | 3 ++-
src/main.c | 21 +++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/src/gnibbles.h b/src/gnibbles.h
index 32bc863..99079d4 100644
--- a/src/gnibbles.h
+++ b/src/gnibbles.h
@@ -48,7 +48,8 @@
#define GAMEOVER 2
#define VICTORY 3
-#define GAMEDELAY 35
+#define DEFAULTGAMEDELAY 35
+int GAMEDELAY;
#define NETDELAY 2
#define BONUSDELAY 100
diff --git a/src/main.c b/src/main.c
index bd0ee95..9d39520 100644
--- a/src/main.c
+++ b/src/main.c
@@ -666,6 +666,11 @@ activate (GtkApplication* app,
G_CALLBACK (configure_event_cb), NULL);
}
+static GOptionEntry entries[] =
+{
+ { "DEBUG_GAMEDELAY", 0, 0, G_OPTION_ARG_INT, &GAMEDELAY, "Built-in speed multiplier, lower is faster,
default is 35", "D" },
+ { NULL }
+};
int
@@ -675,6 +680,22 @@ main (int argc, char **argv)
GtkApplication *app;
int status;
+ //Handle Command Line options
+ GAMEDELAY = DEFAULTGAMEDELAY;
+ GError *error = NULL;
+ GOptionContext *context;
+
+ context = g_option_context_new ("");
+ g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, gtk_get_option_group (TRUE));
+
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ {
+ g_print ("option parsing failed: %s\n", error->message);
+ exit (1);
+ }
+ //Done handling Command Line options
+
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]