diff options
| author | Jonas Kölker <jonaskoelker@yahoo.com> | 2015-10-19 02:48:39 +0200 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2015-10-21 22:34:12 +0100 |
| commit | 3234912f921916a1b8da164fd61dc75579358577 (patch) | |
| tree | fa502a45dad79f4119c9075d61b7ac220ce59fe7 | |
| parent | 67178751e923691e76b410dc90bea3cfb24ae7af (diff) | |
| download | puzzles-3234912f921916a1b8da164fd61dc75579358577.zip puzzles-3234912f921916a1b8da164fd61dc75579358577.tar.gz puzzles-3234912f921916a1b8da164fd61dc75579358577.tar.bz2 puzzles-3234912f921916a1b8da164fd61dc75579358577.tar.xz | |
Tents: mark squares as non-tents with {Shift,Control}-cursor keys.
| -rw-r--r-- | puzzles.but | 4 | ||||
| -rw-r--r-- | tents.c | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/puzzles.but b/puzzles.but index 7e8eeac..6b39630 100644 --- a/puzzles.but +++ b/puzzles.but @@ -2110,7 +2110,9 @@ remainder of a row once you have placed all its tents.) You can also use the cursor keys to move around the grid. Pressing the return key over an empty square will place a tent, and pressing the space bar over an empty square will colour it green; either key will -clear an occupied square. +clear an occupied square. Holding Shift and pressing the cursor keys +will colour empty squares green. Holding Control and pressing the +cursor keys will colour green both empty squares and squares with tents. (All the actions described in \k{common-actions} are also available.) @@ -1544,6 +1544,9 @@ static char *interpret_move(const game_state *state, game_ui *ui, { int w = state->p.w, h = state->p.h; char tmpbuf[80]; + int shift = button & MOD_SHFT, control = button & MOD_CTRL; + + button &= ~MOD_MASK; if (button == LEFT_BUTTON || button == RIGHT_BUTTON) { x = FROMCOORD(x); @@ -1640,8 +1643,26 @@ static char *interpret_move(const game_state *state, game_ui *ui, } if (IS_CURSOR_MOVE(button)) { - move_cursor(button, &ui->cx, &ui->cy, w, h, 0); ui->cdisp = 1; + if (shift || control) { + int len = 0, i, indices[2]; + indices[0] = ui->cx + w * ui->cy; + move_cursor(button, &ui->cx, &ui->cy, w, h, 0); + indices[1] = ui->cx + w * ui->cy; + + /* NONTENTify all unique traversed eligible squares */ + for (i = 0; i <= (indices[0] != indices[1]); ++i) + if (state->grid[indices[i]] == BLANK || + (control && state->grid[indices[i]] == TENT)) { + len += sprintf(tmpbuf + len, "%sN%d,%d", len ? ";" : "", + indices[i] % w, indices[i] / w); + assert(len < lenof(tmpbuf)); + } + + tmpbuf[len] = '\0'; + if (len) return dupstr(tmpbuf); + } else + move_cursor(button, &ui->cx, &ui->cy, w, h, 0); return ""; } if (ui->cdisp) { |