diff options
| author | Simon Tatham <anakin@pobox.com> | 2005-07-03 11:45:49 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2005-07-03 11:45:49 +0000 |
| commit | 85a29743ef113cd26448e4e4cd04c7a34ce4fdd1 (patch) | |
| tree | 8c7556cd00e18bfa8af09ea536fa8202aa2e7bb2 /midend.c | |
| parent | 64e114cce121e55f0f90cb5692c5020d917aa202 (diff) | |
| download | puzzles-85a29743ef113cd26448e4e4cd04c7a34ce4fdd1.zip puzzles-85a29743ef113cd26448e4e4cd04c7a34ce4fdd1.tar.gz puzzles-85a29743ef113cd26448e4e4cd04c7a34ce4fdd1.tar.bz2 puzzles-85a29743ef113cd26448e4e4cd04c7a34ce4fdd1.tar.xz | |
Allow game backends to use even special keystrokes such as N and Q;
they will only be processed as special by the midend if unwanted by
the backend. This causes 5x5 Solo to become just about playable,
because you can now click in a square and type `n'. However, typing
`n' when a square is not selected will revert to the normal
behaviour of starting a new game.
(This isn't particularly ideal, I know, but it's better than
nothing.)
[originally from svn r6048]
Diffstat (limited to 'midend.c')
| -rw-r--r-- | midend.c | 57 |
1 files changed, 29 insertions, 28 deletions
@@ -387,37 +387,38 @@ static int midend_really_process_key(midend_data *me, int x, int y, int button) me->ourgame->dup_game(me->states[me->statepos - 1].state); int special = FALSE, gotspecial = FALSE, ret = 1; float anim_time; + game_state *s; + char *movestr; + + movestr = + me->ourgame->interpret_move(me->states[me->statepos-1].state, + me->ui, me->drawstate, x, y, button); - if (button == 'n' || button == 'N' || button == '\x0E') { - midend_stop_anim(me); - midend_new_game(me); - midend_redraw(me); - goto done; /* never animate */ - } else if (button == 'u' || button == 'u' || - button == '\x1A' || button == '\x1F') { - midend_stop_anim(me); - special = special(me->states[me->statepos-1].movetype); - gotspecial = TRUE; - if (!midend_undo(me)) + if (!movestr) { + if (button == 'n' || button == 'N' || button == '\x0E') { + midend_stop_anim(me); + midend_new_game(me); + midend_redraw(me); + goto done; /* never animate */ + } else if (button == 'u' || button == 'u' || + button == '\x1A' || button == '\x1F') { + midend_stop_anim(me); + special = special(me->states[me->statepos-1].movetype); + gotspecial = TRUE; + if (!midend_undo(me)) + goto done; + } else if (button == 'r' || button == 'R' || + button == '\x12' || button == '\x19') { + midend_stop_anim(me); + if (!midend_redo(me)) + goto done; + } else if (button == 'q' || button == 'Q' || button == '\x11') { + ret = 0; + goto done; + } else goto done; - } else if (button == 'r' || button == 'R' || - button == '\x12' || button == '\x19') { - midend_stop_anim(me); - if (!midend_redo(me)) - goto done; - } else if (button == 'q' || button == 'Q' || button == '\x11') { - ret = 0; - goto done; } else { - game_state *s; - char *movestr; - - movestr = - me->ourgame->interpret_move(me->states[me->statepos-1].state, - me->ui, me->drawstate, x, y, button); - if (!movestr) - s = NULL; - else if (!*movestr) + if (!*movestr) s = me->states[me->statepos-1].state; else { s = me->ourgame->execute_move(me->states[me->statepos-1].state, |