move_cursor(): handle visible flag; return useful value

This adds an extra parameter to move_cursor() that's an optional pointer
to a bool indicating whether the cursor is visible.  This allows for
centralising the common idiom of having the keyboard cursor become
visible when a cursor key is pressed.  Consistently with the vast
majority of existing puzzles, the cursor moves even if it was invisible
before, and becomes visible even if it can't move.

The function now also returns one of the special constants that can be
returned by interpret_move(), so that the caller can correctly return
MOVE_UI_UPDATE or MOVE_NO_EFFECT without needing to carefully check for
changes itself.

Callers are updated only to the extent that they all pass NULL as the
new argument.  Most of them could now be substantially simplified.
This commit is contained in:
Ben Harris
2023-08-09 09:43:04 +01:00
parent 7ada9a5742
commit 5ec86c03a8
30 changed files with 64 additions and 39 deletions

View File

@ -1501,7 +1501,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
}
return NULL;
}
move_cursor(button, &ui->hx, &ui->hy, w, w, false);
move_cursor(button, &ui->hx, &ui->hy, w, w, false, NULL);
ui->hshow = true;
ui->hcursor = true;
return MOVE_UI_UPDATE;