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.
This commit is contained in:
Ben Harris
2023-08-01 23:07:08 +01:00
parent 0dd0186662
commit ff860360c3

View File

@ -1093,14 +1093,6 @@ static void game_changed_state(game_ui *ui, const game_state *oldstate,
const game_state *newstate) const game_state *newstate)
{ {
sel_clear(ui, 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, 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) && if ((tile & TILE_JOINRIGHT) && (tile & TILE_JOINDOWN) &&
COL(state,x+1,y+1) == col) COL(state,x+1,y+1) == col)
tile |= TILE_JOINDIAG; 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; tile |= TILE_HASSEL;
/* For now we're never expecting oldstate at all (because we have /* For now we're never expecting oldstate at all (because we have