mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Use move_cursor() for cursor movement in Guess
This makes interpret_move() properly return MOVE_NO_EFFECT when the cursor can't move, and simplifies the code as well.
This commit is contained in:
22
guess.c
22
guess.c
@ -914,25 +914,15 @@ static char *interpret_move(const game_state *from, game_ui *ui,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* keyboard input */
|
/* keyboard input */
|
||||||
if (button == CURSOR_UP || button == CURSOR_DOWN) {
|
if (IS_CURSOR_MOVE(button)) {
|
||||||
ui->display_cur = true;
|
|
||||||
if (button == CURSOR_DOWN && (ui->colour_cur+1) < from->params.ncolours)
|
|
||||||
ui->colour_cur++;
|
|
||||||
if (button == CURSOR_UP && ui->colour_cur > 0)
|
|
||||||
ui->colour_cur--;
|
|
||||||
ret = MOVE_UI_UPDATE;
|
|
||||||
} else if (button == 'h' || button == 'H' || button == '?') {
|
|
||||||
compute_hint(from, ui);
|
|
||||||
ret = MOVE_UI_UPDATE;
|
|
||||||
} else if (button == CURSOR_LEFT || button == CURSOR_RIGHT) {
|
|
||||||
int maxcur = from->params.npegs;
|
int maxcur = from->params.npegs;
|
||||||
if (ui->markable) maxcur++;
|
if (ui->markable) maxcur++;
|
||||||
|
|
||||||
ui->display_cur = true;
|
ret = move_cursor(button, &ui->peg_cur, &ui->colour_cur,
|
||||||
if (button == CURSOR_RIGHT && (ui->peg_cur+1) < maxcur)
|
maxcur, from->params.ncolours,
|
||||||
ui->peg_cur++;
|
false, &ui->display_cur);
|
||||||
if (button == CURSOR_LEFT && ui->peg_cur > 0)
|
} else if (button == 'h' || button == 'H' || button == '?') {
|
||||||
ui->peg_cur--;
|
compute_hint(from, ui);
|
||||||
ret = MOVE_UI_UPDATE;
|
ret = MOVE_UI_UPDATE;
|
||||||
} else if (button == CURSOR_SELECT) {
|
} else if (button == CURSOR_SELECT) {
|
||||||
ui->display_cur = true;
|
ui->display_cur = true;
|
||||||
|
Reference in New Issue
Block a user