}
void draw_polygon(frontend *fe, int *coords, int npoints,
- int fill, int colour)
+ int fillcolour, int outlinecolour)
{
GdkPoint *points = snewn(npoints, GdkPoint);
int i;
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 {
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;
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);
*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;
}