X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/7b3481c8f4811460f8d0ba42f2a3e5af3a73a2dc..2711f410eb53e9c632ed3021b41f00120913017b:/rect.c diff --git a/rect.c b/rect.c index af369e1..72a00e1 100644 --- a/rect.c +++ b/rect.c @@ -2377,13 +2377,31 @@ static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds, coord_round(FROMCOORD((float)x), FROMCOORD((float)y), &xc, &yc); if (button == LEFT_BUTTON || button == RIGHT_BUTTON) { + if (ui->drag_start_x >= 0 && ui->cur_dragging) { + /* + * If a keyboard drag is in progress, unceremoniously + * cancel it. + */ + ui->drag_start_x = -1; + ui->drag_start_y = -1; + ui->drag_end_x = -1; + ui->drag_end_y = -1; + ui->x1 = -1; + ui->y1 = -1; + ui->x2 = -1; + ui->y2 = -1; + ui->dragged = FALSE; + } startdrag = TRUE; ui->cur_visible = ui->cur_dragging = FALSE; active = TRUE; erasing = (button == RIGHT_BUTTON); } else if (button == LEFT_RELEASE || button == RIGHT_RELEASE) { /* We assert we should have had a LEFT_BUTTON first. */ - assert(!ui->cur_visible); + if (ui->cur_visible) { + ui->cur_visible = FALSE; + active = TRUE; + } assert(!ui->cur_dragging); enddrag = TRUE; erasing = (button == RIGHT_RELEASE); @@ -2394,6 +2412,13 @@ static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds, if (!ui->cur_dragging) return ""; coord_round((float)ui->cur_x + 0.5F, (float)ui->cur_y + 0.5F, &xc, &yc); } else if (IS_CURSOR_SELECT(button)) { + if (ui->drag_start_x >= 0 && !ui->cur_dragging) { + /* + * If a mouse drag is in progress, ignore attempts to + * start a keyboard one. + */ + return NULL; + } if (!ui->cur_visible) { assert(!ui->cur_dragging); ui->cur_visible = TRUE; @@ -2431,9 +2456,10 @@ static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds, (xc != ui->drag_end_x || yc != ui->drag_end_y)) { int t; + if (ui->drag_end_x != -1 && ui->drag_end_y != -1) + ui->dragged = TRUE; ui->drag_end_x = xc; ui->drag_end_y = yc; - ui->dragged = TRUE; active = TRUE; if (xc >= 0 && xc <= 2*from->w && @@ -2813,7 +2839,8 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate, { char buf[256]; - if (ui->x1 >= 0 && ui->y1 >= 0 && + if (ui->dragged && + ui->x1 >= 0 && ui->y1 >= 0 && ui->x2 >= 0 && ui->y2 >= 0) { sprintf(buf, "%dx%d ", ui->x2-ui->x1, @@ -2853,6 +2880,11 @@ static float game_flash_length(game_state *oldstate, return 0.0F; } +static int game_status(game_state *state) +{ + return state->completed ? +1 : 0; +} + static int game_timing_state(game_state *state, game_ui *ui) { return TRUE; @@ -2958,6 +2990,7 @@ const struct game thegame = { game_redraw, game_anim_length, game_flash_length, + game_status, TRUE, FALSE, game_print_size, game_print, TRUE, /* wants_statusbar */ FALSE, game_timing_state,