diff options
| author | Jonas Kölker <jonaskoelker@yahoo.com> | 2015-09-21 17:33:02 +0200 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2015-10-03 16:58:24 +0100 |
| commit | 7478275c8b46c24eb457dd3458ace3a31263295b (patch) | |
| tree | ad4c6f7d4cea4e7d4ea198d707da230d9f0117d5 /pattern.c | |
| parent | 9e1a7d87cd30e1f3fde7eedf1439b48ce1610009 (diff) | |
| download | puzzles-7478275c8b46c24eb457dd3458ace3a31263295b.zip puzzles-7478275c8b46c24eb457dd3458ace3a31263295b.tar.gz puzzles-7478275c8b46c24eb457dd3458ace3a31263295b.tar.bz2 puzzles-7478275c8b46c24eb457dd3458ace3a31263295b.tar.xz | |
Pattern: color multiple squares with Ctrl- or Shift-cursor keys.
Diffstat (limited to 'pattern.c')
| -rw-r--r-- | pattern.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1056,6 +1056,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, const game_drawstate *ds, int x, int y, int button) { + int control = button & MOD_CTRL, shift = button & MOD_SHFT; button &= ~MOD_MASK; x = FROMCOORD(state->w, x); @@ -1156,10 +1157,23 @@ static char *interpret_move(const game_state *state, game_ui *ui, } if (IS_CURSOR_MOVE(button)) { + int x = ui->cur_x, y = ui->cur_y, newstate; + char buf[80]; move_cursor(button, &ui->cur_x, &ui->cur_y, state->w, state->h, 0); ui->cur_visible = 1; - return ""; + if (!control && !shift) return ""; + + newstate = control ? shift ? GRID_UNKNOWN : GRID_FULL : GRID_EMPTY; + if (state->grid[y * state->w + x] == newstate && + state->grid[ui->cur_y * state->w + ui->cur_x] == newstate) + return ""; + + sprintf(buf, "%c%d,%d,%d,%d", control ? shift ? 'U' : 'F' : 'E', + min(x, ui->cur_x), min(y, ui->cur_y), + abs(x - ui->cur_x) + 1, abs(y - ui->cur_y) + 1); + return dupstr(buf); } + if (IS_CURSOR_SELECT(button)) { int currstate = state->grid[ui->cur_y * state->w + ui->cur_x]; int newstate; |