missing `i' in `\e'
[sgt/puzzles] / gtk.c
diff --git a/gtk.c b/gtk.c
index ef795a4..567ff56 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -348,7 +348,7 @@ void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour)
 }
 
 void draw_polygon(frontend *fe, int *coords, int npoints,
-                  int fill, int colour)
+                  int fillcolour, int outlinecolour)
 {
     GdkPoint *points = snewn(npoints, GdkPoint);
     int i;
@@ -358,19 +358,32 @@ void draw_polygon(frontend *fe, int *coords, int npoints,
         points[i].y = coords[i*2+1];
     }
 
-    gdk_gc_set_foreground(fe->gc, &fe->colours[colour]);
-    gdk_draw_polygon(fe->pixmap, fe->gc, fill, points, npoints);
+    if (fillcolour >= 0) {
+       gdk_gc_set_foreground(fe->gc, &fe->colours[fillcolour]);
+       gdk_draw_polygon(fe->pixmap, fe->gc, TRUE, points, npoints);
+    }
+    assert(outlinecolour >= 0);
+    gdk_gc_set_foreground(fe->gc, &fe->colours[outlinecolour]);
+    gdk_draw_polygon(fe->pixmap, fe->gc, FALSE, points, npoints);
 
     sfree(points);
 }
 
 void draw_circle(frontend *fe, int cx, int cy, int radius,
-                 int fill, int colour)
+                 int fillcolour, int outlinecolour)
 {
-    gdk_gc_set_foreground(fe->gc, &fe->colours[colour]);
-    gdk_draw_arc(fe->pixmap, fe->gc, fill,
-                 cx - radius, cy - radius,
-                 2 * radius, 2 * radius, 0, 360 * 64);
+    if (fillcolour >= 0) {
+       gdk_gc_set_foreground(fe->gc, &fe->colours[fillcolour]);
+       gdk_draw_arc(fe->pixmap, fe->gc, TRUE,
+                    cx - radius, cy - radius,
+                    2 * radius, 2 * radius, 0, 360 * 64);
+    }
+
+    assert(outlinecolour >= 0);
+    gdk_gc_set_foreground(fe->gc, &fe->colours[outlinecolour]);
+    gdk_draw_arc(fe->pixmap, fe->gc, FALSE,
+                cx - radius, cy - radius,
+                2 * radius, 2 * radius, 0, 360 * 64);
 }
 
 struct blitter {
@@ -1360,7 +1373,7 @@ static void add_menu_separator(GtkContainer *cont)
     gtk_widget_show(menuitem);
 }
 
-static frontend *new_window(char *game_id, char **error)
+static frontend *new_window(char *arg, char **error)
 {
     frontend *fe;
     GtkBox *vbox;
@@ -1374,15 +1387,36 @@ static frontend *new_window(char *game_id, char **error)
 
     fe->me = midend_new(fe, &thegame);
 
-    if (game_id) {
-        *error = midend_game_id(fe->me, game_id);
-        if (*error) {
-            midend_free(fe->me);
-            sfree(fe);
-            return NULL;
+    if (arg) {
+       char *err;
+       /*
+        * Try treating the argument as a game ID.
+        */
+        err = midend_game_id(fe->me, arg);
+        if (!err) {
+           /*
+            * It's a valid game ID.
+            */
+           midend_new_game(fe->me);
+       } else {
+           FILE *fp = fopen(arg, "r");
+           if (!fp) {
+               err = "Supplied argument is neither a game ID nor a save file";
+           } else {
+               err = midend_deserialise(fe->me, savefile_read, fp);
+               fclose(fp);
+           }
         }
+       if (err) {
+           *error = err;
+           midend_free(fe->me);
+           sfree(fe);
+           return NULL;
+       }
+
+    } else {
+       midend_new_game(fe->me);
     }
-    midend_new_game(fe->me);
 
     fe->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     gtk_window_set_title(GTK_WINDOW(fe->window), thegame.name);
@@ -1663,7 +1697,7 @@ int main(int argc, char **argv)
                 *seed++ = '\0';
            thegame.decode_params(par, params);
         }
-        if ((error = thegame.validate_params(par)) != NULL) {
+        if ((error = thegame.validate_params(par, TRUE)) != NULL) {
            fprintf(stderr, "%s: %s\n", pname, error);
             return 1;
         }