- 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.)
git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5888
cda61777-01e9-0310-a592-
d414129be87e
game_flash_length,
game_wants_statusbar,
FALSE, game_timing_state,
+ 0, /* mouse_priorities */
};
game_flash_length,
game_wants_statusbar,
FALSE, game_timing_state,
+ 0, /* mouse_priorities */
};
* pressed, invent a button-up for the first one and then
* pass the button-down through as before.
*
+ * 2005-05-31: An addendum to the above. Some games might want
+ * a `priority order' among buttons, such that if one button is
+ * pressed while another is down then a fixed one of the
+ * buttons takes priority no matter what order they're pressed
+ * in. Mines, in particular, wants to treat a left+right click
+ * like a left click for the benefit of users of other
+ * implementations. So the last of the above points is modified
+ * in the presence of an (optional) button priority order.
*/
if (IS_MOUSE_DRAG(button) || IS_MOUSE_RELEASE(button)) {
if (me->pressed_mouse_button) {
} else
return ret; /* ignore it */
} else if (IS_MOUSE_DOWN(button) && me->pressed_mouse_button) {
+ /*
+ * If the new button has lower priority than the old one,
+ * don't bother doing this.
+ */
+ if (me->ourgame->mouse_priorities &
+ BUTTON_BEATS(me->pressed_mouse_button, button))
+ return ret; /* just ignore it */
+
/*
* Fabricate a button-up for the previously pressed button.
*/
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.
return ret;
}
- if (button == LEFT_RELEASE) {
+ if (button == LEFT_RELEASE || button == MIDDLE_RELEASE) {
ui->hx = ui->hy = -1;
ui->hradius = 0;
* 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);
}
/*
- * 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;
game_flash_length,
game_wants_statusbar,
TRUE, game_timing_state,
+ BUTTON_BEATS(LEFT_BUTTON, RIGHT_BUTTON),
};
game_flash_length,
game_wants_statusbar,
FALSE, game_timing_state,
+ 0, /* mouse_priorities */
};
game_flash_length,
game_wants_statusbar,
FALSE, game_timing_state,
+ 0, /* mouse_priorities */
};
game_flash_length,
game_wants_statusbar,
FALSE, game_timing_state,
+ 0, /* mouse_priorities */
};
game_flash_length,
game_wants_statusbar,
FALSE, game_timing_state,
+ 0, /* mouse_priorities */
};
#ifdef STANDALONE_SOLVER
#define IS_MOUSE_RELEASE(m) ( (unsigned)((m) - LEFT_RELEASE) <= \
(unsigned)(RIGHT_RELEASE - LEFT_RELEASE))
+/* Bit flags indicating mouse button priorities */
+#define BUTTON_BEATS(x,y) ( 1 << (((x)-LEFT_BUTTON)*3+(y)-LEFT_BUTTON) )
+
#define IGNOREARG(x) ( (x) = (x) )
typedef struct frontend frontend;
int (*wants_statusbar)(void);
int is_timed;
int (*timing_state)(game_state *state);
+ int mouse_priorities;
};
/*
game_flash_length,
game_wants_statusbar,
FALSE, game_timing_state,
+ 0, /* mouse_priorities */
};
game_flash_length,
game_wants_statusbar,
FALSE, game_timing_state,
+ 0, /* mouse_priorities */
};
game_flash_length,
game_wants_statusbar,
FALSE, game_timing_state,
+ 0, /* mouse_priorities */
};
#ifdef STANDALONE_SOLVER
game_flash_length,
game_wants_statusbar,
FALSE, game_timing_state,
+ 0, /* mouse_priorities */
};