+
+int midend_wants_statusbar(midend_data *me)
+{
+ return game_wants_statusbar();
+}
+
+config_item *midend_get_config(midend_data *me, int which, char **wintitle)
+{
+ char *titlebuf, *parstr;
+ config_item *ret;
+
+ titlebuf = snewn(40 + strlen(game_name), char);
+
+ switch (which) {
+ case CFG_SETTINGS:
+ sprintf(titlebuf, "%s configuration", game_name);
+ *wintitle = dupstr(titlebuf);
+ return game_configure(me->params);
+ case CFG_SEED:
+ sprintf(titlebuf, "%s game selection", game_name);
+ *wintitle = dupstr(titlebuf);
+
+ ret = snewn(2, config_item);
+
+ ret[0].type = C_STRING;
+ ret[0].name = "Game ID";
+ ret[0].ival = 0;
+ /*
+ * The text going in here will be a string encoding of the
+ * parameters, plus a colon, plus the game seed. This is a
+ * full game ID.
+ */
+ parstr = encode_params(me->params);
+ ret[0].sval = snewn(strlen(parstr) + strlen(me->seed) + 2, char);
+ sprintf(ret[0].sval, "%s:%s", parstr, me->seed);
+ sfree(parstr);
+
+ ret[1].type = C_END;
+ ret[1].name = ret[1].sval = NULL;
+ ret[1].ival = 0;
+
+ return ret;
+ }
+
+ assert(!"We shouldn't be here");
+ return NULL;
+}
+
+char *midend_game_id(midend_data *me, char *id, int def_seed)
+{
+ char *error, *par, *seed;
+ game_params *params;
+
+ seed = strchr(id, ':');
+
+ if (seed) {
+ /*
+ * We have a colon separating parameters from game seed. So
+ * `par' now points to the parameters string, and `seed' to
+ * the seed string.
+ */
+ *seed++ = '\0';
+ par = id;
+ } else {
+ /*
+ * We only have one string. Depending on `def_seed', we
+ * take it to be either parameters or seed.
+ */
+ if (def_seed) {
+ seed = id;
+ par = NULL;
+ } else {
+ seed = NULL;
+ par = id;
+ }
+ }
+
+ if (par) {
+ params = decode_params(par);
+ error = validate_params(params);
+ if (error) {
+ free_params(params);
+ return error;
+ }
+ free_params(me->params);
+ me->params = params;
+ }
+
+ if (seed) {
+ error = validate_seed(me->params, seed);
+ if (error)
+ return error;
+
+ sfree(me->seed);
+ me->seed = dupstr(seed);
+ me->fresh_seed = TRUE;
+ }
+
+ return NULL;
+}
+
+char *midend_set_config(midend_data *me, int which, config_item *cfg)
+{
+ char *error;
+ game_params *params;
+
+ switch (which) {
+ case CFG_SETTINGS:
+ params = custom_params(cfg);
+ error = validate_params(params);
+
+ if (error) {
+ free_params(params);
+ return error;
+ }
+
+ free_params(me->params);
+ me->params = params;
+ break;
+
+ case CFG_SEED:
+ error = midend_game_id(me, cfg[0].sval, TRUE);
+ if (error)
+ return error;
+ break;
+ }
+
+ return NULL;
+}