diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-08-09 09:43:04 +0100 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-08-09 11:44:25 +0100 |
| commit | 5ec86c03a8bc911bb3dbd77fb7c827eeca975594 (patch) | |
| tree | 13814a3493ff9c813b6bbd28c28dc90d55524549 /pattern.c | |
| parent | 7ada9a5742dd4766cc42909ac01bbb2505f74e47 (diff) | |
| download | puzzles-5ec86c03a8bc911bb3dbd77fb7c827eeca975594.zip puzzles-5ec86c03a8bc911bb3dbd77fb7c827eeca975594.tar.gz puzzles-5ec86c03a8bc911bb3dbd77fb7c827eeca975594.tar.bz2 puzzles-5ec86c03a8bc911bb3dbd77fb7c827eeca975594.tar.xz | |
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.
Diffstat (limited to 'pattern.c')
| -rw-r--r-- | pattern.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1395,7 +1395,8 @@ static char *interpret_move(const game_state *state, game_ui *ui, if (IS_CURSOR_MOVE(button)) { int x = ui->cur_x, y = ui->cur_y, newstate; char buf[80]; - move_cursor(button, &ui->cur_x, &ui->cur_y, state->common->w, state->common->h, false); + move_cursor(button, &ui->cur_x, &ui->cur_y, + state->common->w, state->common->h, false, NULL); ui->cur_visible = true; if (!control && !shift) return MOVE_UI_UPDATE; |