aboutsummaryrefslogtreecommitdiff
path: root/gtk.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-05-20 08:22:49 +0000
committerSimon Tatham <anakin@pobox.com>2004-05-20 08:22:49 +0000
commit61f08e7634e0e39148a784c0ce6efcc112ed5a7a (patch)
tree55b06d0ae5f94f331146b15e9437bcef5ce4e895 /gtk.c
parent350683b25371ec6a7548b2e83b2be15eb629815f (diff)
downloadpuzzles-61f08e7634e0e39148a784c0ce6efcc112ed5a7a.zip
puzzles-61f08e7634e0e39148a784c0ce6efcc112ed5a7a.tar.gz
puzzles-61f08e7634e0e39148a784c0ce6efcc112ed5a7a.tar.bz2
puzzles-61f08e7634e0e39148a784c0ce6efcc112ed5a7a.tar.xz
Now that we have string-encodable game parameters, let's support a
command-line argument which is either a set of parameters or a params+seed game ID. [originally from svn r4234]
Diffstat (limited to 'gtk.c')
-rw-r--r--gtk.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/gtk.c b/gtk.c
index 6a98726..3501f83 100644
--- a/gtk.c
+++ b/gtk.c
@@ -762,7 +762,7 @@ static void add_menu_separator(GtkContainer *cont)
gtk_widget_show(menuitem);
}
-static frontend *new_window(void)
+static frontend *new_window(char *game_id, char **error)
{
frontend *fe;
GtkBox *vbox;
@@ -774,6 +774,14 @@ static frontend *new_window(void)
time(&t);
fe->me = midend_new(fe, &t, sizeof(t));
+ if (game_id) {
+ *error = midend_game_id(fe->me, game_id, FALSE);
+ if (*error) {
+ midend_free(fe->me);
+ sfree(fe);
+ return NULL;
+ }
+ }
midend_new_game(fe->me);
fe->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -944,8 +952,16 @@ static frontend *new_window(void)
int main(int argc, char **argv)
{
+ char *pname = argv[0];
+ char *error;
+
gtk_init(&argc, &argv);
- (void) new_window();
+
+ if (!new_window(argc > 1 ? argv[1] : NULL, &error)) {
+ fprintf(stderr, "%s: %s\n", pname, error);
+ return 1;
+ }
+
gtk_main();
return 0;