Introduce a mechanism by which calls to midend_supersede_game_desc()

can trigger a call to a front end notification function. Use this to
update the game ID permalink when Mines supersedes its game ID.

[originally from svn r9793]
This commit is contained in:
Simon Tatham
2013-03-31 09:58:52 +00:00
parent bf696f83fc
commit bb14689b4a
4 changed files with 54 additions and 0 deletions

View File

@ -81,6 +81,9 @@ struct midend {
int pressed_mouse_button;
int preferred_tilesize, tilesize, winwidth, winheight;
void (*game_desc_change_notify_function)(void *);
void *game_desc_change_notify_ctx;
};
#define ensure(me) do { \
@ -1079,12 +1082,20 @@ int midend_wants_statusbar(midend *me)
return me->ourgame->wants_statusbar;
}
void midend_request_desc_changes(midend *me, void (*notify)(void *), void *ctx)
{
me->game_desc_change_notify_function = notify;
me->game_desc_change_notify_ctx = ctx;
}
void midend_supersede_game_desc(midend *me, char *desc, char *privdesc)
{
sfree(me->desc);
sfree(me->privdesc);
me->desc = dupstr(desc);
me->privdesc = privdesc ? dupstr(privdesc) : NULL;
if (me->game_desc_change_notify_function)
me->game_desc_change_notify_function(me->game_desc_change_notify_ctx);
}
config_item *midend_get_config(midend *me, int which, char **wintitle)