aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2011-12-21 13:46:48 +0000
committerSimon Tatham <anakin@pobox.com>2011-12-21 13:46:48 +0000
commitc4e486c2a1aea38df9c573d168979536ced9ad15 (patch)
treeb0038397b8cdc8384c148bf5dfff756ee8dbf628
parent3107237af4aa82f538826e989ee7633e0a1ba22c (diff)
downloadpuzzles-c4e486c2a1aea38df9c573d168979536ced9ad15.zip
puzzles-c4e486c2a1aea38df9c573d168979536ced9ad15.tar.gz
puzzles-c4e486c2a1aea38df9c573d168979536ced9ad15.tar.bz2
puzzles-c4e486c2a1aea38df9c573d168979536ced9ad15.tar.xz
In Group, the keyboard-controlled cursor should respect user
rearrangement of the rows and columns. [originally from svn r9372]
-rw-r--r--unfinished/group.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/unfinished/group.c b/unfinished/group.c
index 79bd3fa..b2c62d6 100644
--- a/unfinished/group.c
+++ b/unfinished/group.c
@@ -1201,6 +1201,18 @@ static int check_errors(game_state *state, long *errors)
return errs;
}
+static int find_in_sequence(digit *seq, int len, digit n)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (seq[i] == n)
+ return i;
+
+ assert(!"Should never get here");
+ return -1;
+}
+
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
int x, int y, int button)
{
@@ -1292,7 +1304,11 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
}
if (IS_CURSOR_MOVE(button)) {
- move_cursor(button, &ui->hx, &ui->hy, w, w, 0);
+ int cx = find_in_sequence(state->sequence, w, ui->hx);
+ int cy = find_in_sequence(state->sequence, w, ui->hy);
+ move_cursor(button, &cx, &cy, w, w, 0);
+ ui->hx = state->sequence[cx];
+ ui->hy = state->sequence[cy];
ui->hshow = ui->hcursor = 1;
return "";
}