diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-08-01 23:07:08 +0100 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-08-01 23:07:08 +0100 |
| commit | ff860360c3eb6b146674384a15d10fde788bd545 (patch) | |
| tree | eefef920b3316a8eea65e204c0a76a590a03bb13 | |
| parent | 0dd01866627e82ea21ed0e85021abdb070e0159c (diff) | |
| download | puzzles-ff860360c3eb6b146674384a15d10fde788bd545.zip puzzles-ff860360c3eb6b146674384a15d10fde788bd545.tar.gz puzzles-ff860360c3eb6b146674384a15d10fde788bd545.tar.bz2 puzzles-ff860360c3eb6b146674384a15d10fde788bd545.tar.xz | |
Same Game: level-triggered keyboard cursor hiding
Same Game doesn't want to show the keyboard cursor when the game is in a
state where no move is possible. Previously, it did this by having
game_changed_state() hide the cursor on entry to such a state. That
meant that reaching a dead end and undoing out of it hid the cursor,
which was confusing.
Now the cursor is hidden in game_redraw() if the game is in a dead-end
state without changing the displaysel flag in the game_ui. That way, if
you undo out of a dead end, the cursor becomes visible again if it was
visible before.
This does mean that you can move the cursor in a dead-end state without
being able to see where it's going. I think that's tolerable, but maybe
the cursor keys should be disabled in that state as well.
| -rw-r--r-- | samegame.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -1093,14 +1093,6 @@ static void game_changed_state(game_ui *ui, const game_state *oldstate, const game_state *newstate) { sel_clear(ui, newstate); - - /* - * If the game state has just changed into an unplayable one - * (either completed or impossible), we vanish the keyboard- - * control cursor. - */ - if (newstate->complete || newstate->impossible) - ui->displaysel = false; } static const char *current_key_label(const game_ui *ui, @@ -1572,8 +1564,13 @@ static void game_redraw(drawing *dr, game_drawstate *ds, if ((tile & TILE_JOINRIGHT) && (tile & TILE_JOINDOWN) && COL(state,x+1,y+1) == col) tile |= TILE_JOINDIAG; - - if (ui->displaysel && ui->xsel == x && ui->ysel == y) + /* + * If the game state is an unplayable one (either + * completed or impossible), we hide the keyboard-control + * cursor. + */ + if (ui->displaysel && ui->xsel == x && ui->ysel == y && + !(state->complete || state->impossible)) tile |= TILE_HASSEL; /* For now we're never expecting oldstate at all (because we have |