aboutsummaryrefslogtreecommitdiff
path: root/unequal.c
diff options
context:
space:
mode:
Diffstat (limited to 'unequal.c')
-rw-r--r--unequal.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/unequal.c b/unequal.c
index 0adee9d..f778df0 100644
--- a/unequal.c
+++ b/unequal.c
@@ -1436,6 +1436,17 @@ static char *solve_game(const game_state *state, const game_state *currstate,
struct game_ui {
int hx, hy; /* as for solo.c, highlight pos */
bool hshow, hpencil, hcursor; /* show state, type, and ?cursor. */
+
+ /*
+ * User preference option: if the user right-clicks in a square
+ * and presses a number key to add/remove a pencil mark, do we
+ * hide the mouse highlight again afterwards?
+ *
+ * Historically our answer was yes. The Android port prefers no.
+ * There are advantages both ways, depending how much you dislike
+ * the highlight cluttering your view. So it's a preference.
+ */
+ bool pencil_keep_highlight;
};
static game_ui *new_ui(const game_state *state)
@@ -1446,6 +1457,8 @@ static game_ui *new_ui(const game_state *state)
ui->hpencil = false;
ui->hshow = ui->hcursor = getenv_bool("PUZZLES_SHOW_CURSOR", false);
+ ui->pencil_keep_highlight = false;
+
return ui;
}
@@ -1454,6 +1467,28 @@ static void free_ui(game_ui *ui)
sfree(ui);
}
+static config_item *get_prefs(game_ui *ui)
+{
+ config_item *ret;
+
+ ret = snewn(2, config_item);
+
+ ret[0].name = "Keep mouse highlight after changing a pencil mark";
+ ret[0].kw = "pencil-keep-highlight";
+ ret[0].type = C_BOOLEAN;
+ ret[0].u.boolean.bval = ui->pencil_keep_highlight;
+
+ ret[1].name = NULL;
+ ret[1].type = C_END;
+
+ return ret;
+}
+
+static void set_prefs(game_ui *ui, const config_item *cfg)
+{
+ ui->pencil_keep_highlight = cfg[0].u.boolean.bval;
+}
+
static void game_changed_state(game_ui *ui, const game_state *oldstate,
const game_state *newstate)
{
@@ -1632,7 +1667,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
sprintf(buf, "%c%d,%d,%d",
(char)(ui->hpencil && n > 0 ? 'P' : 'R'), ui->hx, ui->hy, n);
- if (!ui->hcursor) ui->hshow = false;
+ /*
+ * Hide the highlight after a keypress, if it was mouse-
+ * generated. Also, don't hide it if this move has changed
+ * pencil marks and the user preference says not to hide the
+ * highlight in that situation.
+ */
+ if (!ui->hcursor && !(ui->hpencil && ui->pencil_keep_highlight))
+ ui->hshow = false;
return dupstr(buf);
}
@@ -2155,7 +2197,7 @@ const struct game thegame = {
free_game,
true, solve_game,
true, game_can_format_as_text_now, game_text_format,
- NULL, NULL, /* get_prefs, set_prefs */
+ get_prefs, set_prefs,
new_ui,
free_ui,
NULL, /* encode_ui */