mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
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:
@ -2446,7 +2446,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
||||
if (ui->dragging) {
|
||||
int nx = ui->cur_x, ny = ui->cur_y;
|
||||
|
||||
move_cursor(button, &nx, &ny, state->w, state->h, false);
|
||||
move_cursor(button, &nx, &ny, state->w, state->h, false, NULL);
|
||||
if (nx == ui->cur_x && ny == ui->cur_y)
|
||||
return MOVE_NO_EFFECT;
|
||||
update_drag_dst(state, ui, ds,
|
||||
|
Reference in New Issue
Block a user