aboutsummaryrefslogtreecommitdiff
path: root/mines.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-05-31 18:38:01 +0000
committerSimon Tatham <anakin@pobox.com>2005-05-31 18:38:01 +0000
commita50a65120c3b4230b6a1b95a52c8b6d3299a43c7 (patch)
treeefc4109cb80592e582561805dd707f2f2a43f388 /mines.c
parent437b69542fc34ae48bee14dc821ef9df1c71c62a (diff)
downloadpuzzles-a50a65120c3b4230b6a1b95a52c8b6d3299a43c7.zip
puzzles-a50a65120c3b4230b6a1b95a52c8b6d3299a43c7.tar.gz
puzzles-a50a65120c3b4230b6a1b95a52c8b6d3299a43c7.tar.bz2
puzzles-a50a65120c3b4230b6a1b95a52c8b6d3299a43c7.tar.xz
Better mouse button handling in Mines:
- middle button now also triggers the clear-around-square action - a special-case handler in midend_process_key() arranges that the left button always trumps the right button if both are pressed together, meaning that Windows Minesweeper players used to pressing L+R to clear around a square should still be able to do so without any strange behaviour. (The latter touches all game backends, yet again, to add a field to the game structure which is zero in everything except Mines.) [originally from svn r5888]
Diffstat (limited to 'mines.c')
-rw-r--r--mines.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/mines.c b/mines.c
index d1ca4ff..fcf439d 100644
--- a/mines.c
+++ b/mines.c
@@ -2457,7 +2457,8 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds,
if (cx < 0 || cx >= from->w || cy < 0 || cy > from->h)
return NULL;
- if (button == LEFT_BUTTON || button == LEFT_DRAG) {
+ if (button == LEFT_BUTTON || button == LEFT_DRAG ||
+ button == MIDDLE_BUTTON || button == MIDDLE_DRAG) {
/*
* Mouse-downs and mouse-drags just cause highlighting
* updates.
@@ -2487,7 +2488,7 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds,
return ret;
}
- if (button == LEFT_RELEASE) {
+ if (button == LEFT_RELEASE || button == MIDDLE_RELEASE) {
ui->hx = ui->hy = -1;
ui->hradius = 0;
@@ -2501,8 +2502,9 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds,
* permitted if the tile is marked as a mine, for safety.
* (Unmark it and _then_ open it.)
*/
- if (from->grid[cy * from->w + cx] == -2 ||
- from->grid[cy * from->w + cx] == -3) {
+ if (button == LEFT_RELEASE &&
+ (from->grid[cy * from->w + cx] == -2 ||
+ from->grid[cy * from->w + cx] == -3)) {
ret = dup_game(from);
ret->just_used_solve = FALSE;
open_square(ret, cx, cy);
@@ -2512,10 +2514,10 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds,
}
/*
- * Left-clicking on an uncovered tile: first we check to see if
- * the number of mine markers surrounding the tile is equal to
- * its mine count, and if so then we open all other surrounding
- * squares.
+ * Left-clicking or middle-clicking on an uncovered tile:
+ * first we check to see if the number of mine markers
+ * surrounding the tile is equal to its mine count, and if
+ * so then we open all other surrounding squares.
*/
if (from->grid[cy * from->w + cx] > 0) {
int dy, dx, n;
@@ -3006,4 +3008,5 @@ const struct game thegame = {
game_flash_length,
game_wants_statusbar,
TRUE, game_timing_state,
+ BUTTON_BEATS(LEFT_BUTTON, RIGHT_BUTTON),
};