From 4c692867911ca67863d00f8538ce4b7d6928779e Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 3 Jul 2005 11:45:49 +0000 Subject: [PATCH] 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.) git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6048 cda61777-01e9-0310-a592-d414129be87e --- midend.c | 57 +++++++++++++++++++++++++++++---------------------------- 1 file 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, -- 2.11.0