aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2013-04-05 15:49:20 +0000
committerSimon Tatham <anakin@pobox.com>2013-04-05 15:49:20 +0000
commit8f87f2ce894f6ba017581abb89e2e0927067bed7 (patch)
treef5a2c1edaed00eeaec5d3093c1faf27365a177ac /midend.c
parent841c9318f3bc8a368224af4931f2f007ff288b0a (diff)
downloadpuzzles-8f87f2ce894f6ba017581abb89e2e0927067bed7.zip
puzzles-8f87f2ce894f6ba017581abb89e2e0927067bed7.tar.gz
puzzles-8f87f2ce894f6ba017581abb89e2e0927067bed7.tar.bz2
puzzles-8f87f2ce894f6ba017581abb89e2e0927067bed7.tar.xz
I've just realised that the JS puzzles' permalinks were not updating
when the user pressed 'n' for a new game, because all the front end knows is that it passed a keystroke to the puzzle, and it has no way of hearing back that a particular keypress resulted in a game id change. To fix this, I've renamed midend_request_desc_changes to midend_request_id_changes and expanded its remit to cover _any_ change to the game ids. So now that callback in the Emscripten front end is the only place from which update_permalinks is called (apart from initialising them at setup time), and that should handle everything. [originally from svn r9805]
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/midend.c b/midend.c
index d55be55..2e8b7f6 100644
--- a/midend.c
+++ b/midend.c
@@ -82,8 +82,8 @@ struct midend {
int preferred_tilesize, tilesize, winwidth, winheight;
- void (*game_desc_change_notify_function)(void *);
- void *game_desc_change_notify_ctx;
+ void (*game_id_change_notify_function)(void *);
+ void *game_id_change_notify_ctx;
};
#define ensure(me) do { \
@@ -499,6 +499,9 @@ void midend_new_game(midend *me)
me->ui = me->ourgame->new_ui(me->states[0].state);
midend_set_timer(me);
me->pressed_mouse_button = 0;
+
+ if (me->game_id_change_notify_function)
+ me->game_id_change_notify_function(me->game_id_change_notify_ctx);
}
int midend_can_undo(midend *me)
@@ -1082,10 +1085,10 @@ int midend_wants_statusbar(midend *me)
return me->ourgame->wants_statusbar;
}
-void midend_request_desc_changes(midend *me, void (*notify)(void *), void *ctx)
+void midend_request_id_changes(midend *me, void (*notify)(void *), void *ctx)
{
- me->game_desc_change_notify_function = notify;
- me->game_desc_change_notify_ctx = ctx;
+ me->game_id_change_notify_function = notify;
+ me->game_id_change_notify_ctx = ctx;
}
void midend_supersede_game_desc(midend *me, char *desc, char *privdesc)
@@ -1094,8 +1097,8 @@ void midend_supersede_game_desc(midend *me, char *desc, char *privdesc)
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);
+ if (me->game_id_change_notify_function)
+ me->game_id_change_notify_function(me->game_id_change_notify_ctx);
}
config_item *midend_get_config(midend *me, int which, char **wintitle)