void pearl_loopgen(int w, int h, char *lines, random_state *rs)
{
- grid *g = grid_new(GRID_SQUARE, w-1, h-1, NULL);
+ grid *g = grid_new(GRID_SQUARE, w-1, h-1, 0, NULL);
char *board = snewn(g->num_faces, char);
int i, s = g->tilesize;
struct pearl_loopgen_bias_ctx biasctx;
break; /* got it */
}
+ debug(("%d %dx%d loops before finished puzzle.\n", ngen, w, h));
+
return ngen;
}
{
char *grid, *clues;
char *desc;
- int ngen, w = params->w, h = params->h, i, j;
+ int w = params->w, h = params->h, i, j;
grid = snewn(w*h, char);
clues = snewn(w*h, char);
- ngen = new_clues(params, rs, clues, grid);
-
- debug(("%d %dx%d loops before finished puzzle.\n", ngen, w, h));
+ new_clues(params, rs, clues, grid);
desc = snewn(w * h + 1, char);
for (i = j = 0; i < w*h; i++) {
int gx = FROMCOORD(x), gy = FROMCOORD(y), i;
char tmpbuf[80];
- if (button == LEFT_BUTTON) {
+ if (IS_MOUSE_DOWN(button)) {
if (!INGRID(state, gx, gy)) return NULL;
ui->clickx = x; ui->clicky = y;
return "";
}
- if (IS_MOUSE_DRAG(button)) {
+ if (button == LEFT_DRAG) {
update_ui_drag(state, ui, gx, gy);
return "";
}
return buf ? buf : "";
} else {
- /* Click (or tiny drag). Work out which edge we were closest to. */
- int cx = COORD(gx) + TILE_SIZE/2, cy = COORD(gy) + TILE_SIZE/2;
+ /* Click (or tiny drag). Work out which edge we were
+ * closest to. */
+ int cx, cy;
int gx2, gy2, l1, l2, ismark = (button == RIGHT_RELEASE);
char movec = ismark ? 'M' : 'F';
+ /*
+ * We process clicks based on the mouse-down location,
+ * because that's more natural for a user to carefully
+ * control than the mouse-up.
+ */
+ x = ui->clickx;
+ y = ui->clicky;
+
+ gx = FROMCOORD(x);
+ gy = FROMCOORD(y);
+ cx = COORD(gx) + TILE_SIZE/2;
+ cy = COORD(gy) + TILE_SIZE/2;
+
if (!INGRID(state, gx, gy)) return "";
if (max(abs(x-cx),abs(y-cy)) < TILE_SIZE/4) {