}
}
-void midend_size(midend *me, int *x, int *y, int expand)
+void midend_size(midend *me, int *x, int *y, int user_size)
{
int min, max;
int rx, ry;
/*
* Find the tile size that best fits within the given space. If
- * `expand' is TRUE, we must actually find the _largest_ such
- * tile size; otherwise, we bound above at the game's preferred
- * tile size.
+ * `user_size' is TRUE, we must actually find the _largest_ such
+ * tile size, in order to get as close to the user's explicit
+ * request as possible; otherwise, we bound above at the game's
+ * preferred tile size, so that the game gets what it wants
+ * provided that this doesn't break the constraint from the
+ * front-end (which is likely to be a screen size or similar).
*/
- if (expand) {
+ if (user_size) {
max = 1;
do {
max *= 2;
*/
me->tilesize = min;
+ if (user_size)
+ /* If the user requested a change in size, make it permanent. */
+ me->preferred_tilesize = me->tilesize;
midend_size_new_drawstate(me);
*x = me->winwidth;
*y = me->winheight;
* state has been updated and a redraw is called for.
*/
midend_redraw(me);
+ midend_set_timer(me);
goto done;
} else if (s) {
midend_stop_anim(me);
}
}
+/*
+ * Nasty hacky function used to implement the --redo option in
+ * gtk.c. Only used for generating the puzzles' icons.
+ */
+void midend_freeze_timer(midend *me, float tprop)
+{
+ me->anim_pos = me->anim_time * tprop;
+ midend_redraw(me);
+ deactivate_timer(me->frontend);
+}
+
void midend_timer(midend *me, float tplus)
{
+ int need_redraw = (me->anim_time > 0 || me->flash_time > 0);
+
me->anim_pos += tplus;
if (me->anim_pos >= me->anim_time ||
me->anim_time == 0 || !me->oldstate) {
me->flash_pos = me->flash_time = 0;
}
- midend_redraw(me);
+ if (need_redraw)
+ midend_redraw(me);
if (me->timing) {
float oldelapsed = me->elapsed;