aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-07-03 11:45:49 +0000
committerSimon Tatham <anakin@pobox.com>2005-07-03 11:45:49 +0000
commit85a29743ef113cd26448e4e4cd04c7a34ce4fdd1 (patch)
tree8c7556cd00e18bfa8af09ea536fa8202aa2e7bb2
parent64e114cce121e55f0f90cb5692c5020d917aa202 (diff)
downloadpuzzles-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]
-rw-r--r--midend.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/midend.c b/midend.c
index 7bc2d4f..df661b5 100644
--- a/midend.c
+++ b/midend.c
@@ -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,