Allow unlocking an island despite moving slightly.

Previously moving 1 pixel would be treated as a failed drag and not an unlock.

Now you only have to release the button somewhere on the island you started on.
This commit is contained in:
Chris Boyle
2015-11-28 13:56:39 +00:00
committed by Simon Tatham
parent 2acd8baae8
commit 346584bf6e

View File

@ -2339,14 +2339,16 @@ static char *interpret_move(const game_state *state, game_ui *ui,
if (button == LEFT_BUTTON || button == RIGHT_BUTTON) { if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
if (!INGRID(state, gx, gy)) return NULL; if (!INGRID(state, gx, gy)) return NULL;
ui->cur_visible = 0; ui->cur_visible = 0;
if ((ggrid & G_ISLAND) && !(ggrid & G_MARK)) { if (ggrid & G_ISLAND) {
ui->dragx_src = gx; ui->dragx_src = gx;
ui->dragy_src = gy; ui->dragy_src = gy;
return ""; return "";
} else } else
return ui_cancel_drag(ui); return ui_cancel_drag(ui);
} else if (button == LEFT_DRAG || button == RIGHT_DRAG) { } else if (button == LEFT_DRAG || button == RIGHT_DRAG) {
if (gx != ui->dragx_src || gy != ui->dragy_src) { if (INGRID(state, ui->dragx_src, ui->dragy_src)
&& (gx != ui->dragx_src || gy != ui->dragy_src)
&& !(GRID(state,ui->dragx_src,ui->dragy_src) & G_MARK)) {
ui->dragging = 1; ui->dragging = 1;
ui->drag_is_noline = (button == RIGHT_DRAG) ? 1 : 0; ui->drag_is_noline = (button == RIGHT_DRAG) ? 1 : 0;
return update_drag_dst(state, ui, ds, x, y); return update_drag_dst(state, ui, ds, x, y);
@ -2360,6 +2362,10 @@ static char *interpret_move(const game_state *state, game_ui *ui,
if (ui->dragging) { if (ui->dragging) {
return finish_drag(state, ui); return finish_drag(state, ui);
} else { } else {
if (!INGRID(state, ui->dragx_src, ui->dragy_src)
|| gx != ui->dragx_src || gy != ui->dragy_src) {
return ui_cancel_drag(ui);
}
ui_cancel_drag(ui); ui_cancel_drag(ui);
if (!INGRID(state, gx, gy)) return NULL; if (!INGRID(state, gx, gy)) return NULL;
if (!(GRID(state, gx, gy) & G_ISLAND)) return NULL; if (!(GRID(state, gx, gy) & G_ISLAND)) return NULL;