Don't rush move animation to a conclusion on a subsequent keypress

unless there's actual activity happening as a result of the move.
Net animations were tending to get rushed to conclusion by the mouse
button release now that it's being reported to the mid-end.

[originally from svn r4211]
This commit is contained in:
Simon Tatham
2004-05-11 18:37:20 +00:00
parent eb8a374d0d
commit cdfc740fe4

View File

@ -158,29 +158,36 @@ static void midend_finish_move(midend_data *me)
activate_timer(me->frontend); activate_timer(me->frontend);
} }
static void midend_stop_anim(midend_data *me)
{
if (me->oldstate || me->anim_time) {
midend_finish_move(me);
midend_redraw(me);
}
}
int midend_process_key(midend_data *me, int x, int y, int button) int midend_process_key(midend_data *me, int x, int y, int button)
{ {
game_state *oldstate = dup_game(me->states[me->statepos - 1]); game_state *oldstate = dup_game(me->states[me->statepos - 1]);
float anim_time; float anim_time;
if (me->oldstate || me->anim_time) {
midend_finish_move(me);
midend_redraw(me);
}
if (button == 'n' || button == 'N' || button == '\x0E') { if (button == 'n' || button == 'N' || button == '\x0E') {
midend_stop_anim(me);
midend_new_game(me); midend_new_game(me);
midend_redraw(me); midend_redraw(me);
return 1; /* never animate */ return 1; /* never animate */
} else if (button == 'r' || button == 'R') { } else if (button == 'r' || button == 'R') {
midend_stop_anim(me);
midend_restart_game(me); midend_restart_game(me);
midend_redraw(me); midend_redraw(me);
return 1; /* never animate */ return 1; /* never animate */
} else if (button == 'u' || button == 'u' || } else if (button == 'u' || button == 'u' ||
button == '\x1A' || button == '\x1F') { button == '\x1A' || button == '\x1F') {
midend_stop_anim(me);
if (!midend_undo(me)) if (!midend_undo(me))
return 1; return 1;
} else if (button == '\x12') { } else if (button == '\x12') {
midend_stop_anim(me);
if (!midend_redo(me)) if (!midend_redo(me))
return 1; return 1;
} else if (button == 'q' || button == 'Q' || button == '\x11') { } else if (button == 'q' || button == 'Q' || button == '\x11') {
@ -199,6 +206,7 @@ int midend_process_key(midend_data *me, int x, int y, int button)
midend_redraw(me); midend_redraw(me);
return 1; return 1;
} else if (s) { } else if (s) {
midend_stop_anim(me);
while (me->nstates > me->statepos) while (me->nstates > me->statepos)
free_game(me->states[--me->nstates]); free_game(me->states[--me->nstates]);
ensure(me); ensure(me);