Fix problems with arrow UI with non-square grid.
[sgt/puzzles] / pattern.c
index f034bd4..740f434 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -789,17 +789,28 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
     if (x >= 0 && x < state->w && y >= 0 && y < state->h &&
         (button == LEFT_BUTTON || button == RIGHT_BUTTON ||
          button == MIDDLE_BUTTON)) {
+#ifdef STYLUS_BASED
+        int currstate = state->grid[y * state->w + x];
+#endif
 
         ui->dragging = TRUE;
 
         if (button == LEFT_BUTTON) {
             ui->drag = LEFT_DRAG;
             ui->release = LEFT_RELEASE;
+#ifdef STYLUS_BASED
+            ui->state = currstate == GRID_FULL ? GRID_UNKNOWN : GRID_FULL;
+#else
             ui->state = GRID_FULL;
+#endif
         } else if (button == RIGHT_BUTTON) {
             ui->drag = RIGHT_DRAG;
             ui->release = RIGHT_RELEASE;
+#ifdef STYLUS_BASED
+            ui->state = currstate == GRID_EMPTY ? GRID_UNKNOWN : GRID_EMPTY;
+#else
             ui->state = GRID_EMPTY;
+#endif
         } else /* if (button == MIDDLE_BUTTON) */ {
             ui->drag = MIDDLE_DRAG;
             ui->release = MIDDLE_RELEASE;
@@ -963,7 +974,7 @@ static void game_set_size(drawing *dr, game_drawstate *ds,
     ds->tilesize = tilesize;
 }
 
-static float *game_colours(frontend *fe, game_state *state, int *ncolours)
+static float *game_colours(frontend *fe, int *ncolours)
 {
     float *ret = snewn(3 * NCOLOURS, float);
 
@@ -1169,11 +1180,6 @@ static float game_flash_length(game_state *oldstate,
     return 0.0F;
 }
 
-static int game_wants_statusbar(void)
-{
-    return FALSE;
-}
-
 static int game_timing_state(game_state *state, game_ui *ui)
 {
     return TRUE;
@@ -1248,7 +1254,7 @@ static void game_print(drawing *dr, game_state *state, int tilesize)
 #endif
 
 const struct game thegame = {
-    "Pattern", "games.pattern",
+    "Pattern", "games.pattern", "pattern",
     default_params,
     game_fetch_preset,
     decode_params,
@@ -1279,9 +1285,9 @@ const struct game thegame = {
     game_anim_length,
     game_flash_length,
     TRUE, FALSE, game_print_size, game_print,
-    game_wants_statusbar,
+    FALSE,                            /* wants_statusbar */
     FALSE, game_timing_state,
-    0,                                /* flags */
+    REQUIRE_RBUTTON,                  /* flags */
 };
 
 #ifdef STANDALONE_SOLVER