[gnome-mines] Add --small, --medium & --big command-line options.
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mines] Add --small, --medium & --big command-line options.
- Date: Tue, 23 Sep 2014 18:43:57 +0000 (UTC)
commit 78ed305f200bd110d445bc8716f09c48847f5816
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Mon Jul 14 15:37:49 2014 +0200
Add --small, --medium & --big command-line options.
https://bugzilla.gnome.org/show_bug.cgi?id=733162
data/gnome-mines.6 | 10 ++++++++++
src/gnome-mines.vala | 19 +++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/data/gnome-mines.6 b/data/gnome-mines.6
index d3c8a65..cb8e5c6 100644
--- a/data/gnome-mines.6
+++ b/data/gnome-mines.6
@@ -27,6 +27,16 @@ only your brain and a little bit of luck.
.TP
.B \-v, \-\-version
Print release version and exit
+.PP
+.B \-\-small
+.br
+.B \-\-medium
+.br
+.B \-\-big
+.RS 7
+Start the game with a small (8 by 8), medium (16 by 16) or big (30 by 16) board.
+If more than one of these options is given, the biggest size is selected.
+.RE
.P
This program also accepts the standard GNOME and GTK options.
.SH AUTHORS
diff --git a/src/gnome-mines.vala b/src/gnome-mines.vala
index d46c105..b171898 100644
--- a/src/gnome-mines.vala
+++ b/src/gnome-mines.vala
@@ -21,6 +21,9 @@ public class Mines : Gtk.Application
private const string KEY_NMINES = "nmines";
private const string KEY_MODE = "mode";
+ /* For command-line options */
+ private static int game_mode = -1;
+
/* Keys shared with MinefieldView */
public static const string KEY_USE_QUESTION_MARKS = "use-question-marks";
public static const string KEY_USE_OVERMINE_WARNING = "use-overmine-warning";
@@ -76,6 +79,9 @@ public class Mines : Gtk.Application
private const OptionEntry[] option_entries =
{
{ "version", 'v', 0, OptionArg.NONE, null, N_("Print release version and exit"), null },
+ { "small", 0, 0, OptionArg.NONE, null, N_("Small game"), null },
+ { "medium", 0, 0, OptionArg.NONE, null, N_("Medium game"), null },
+ { "big", 0, 0, OptionArg.NONE, null, N_("Big game"), null },
{ null }
};
@@ -106,6 +112,9 @@ public class Mines : Gtk.Application
settings = new Settings ("org.gnome.mines");
settings.delay ();
+ if (game_mode != -1)
+ settings.set_int (KEY_MODE, game_mode);
+
Gtk.Window.set_default_icon_name ("gnome-mines");
var css_provider = new Gtk.CssProvider ();
@@ -240,6 +249,9 @@ public class Mines : Gtk.Application
high_scores_button = (Gtk.Button) ui_builder.get_object ("high_scores_button");
replay_button = (Gtk.Button) ui_builder.get_object ("replay_button");
new_game_button = (Gtk.Button) ui_builder.get_object ("new_game_button");
+
+ if (game_mode != -1)
+ start_game ();
}
private void startup_new_game_screen (Gtk.Builder builder)
@@ -379,6 +391,13 @@ public class Mines : Gtk.Application
return Posix.EXIT_SUCCESS;
}
+ if (options.contains ("small"))
+ game_mode = 0;
+ if (options.contains ("medium"))
+ game_mode = 1;
+ if (options.contains ("big"))
+ game_mode = 2;
+
/* Activate */
return -1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]