diff options
| author | Simon Tatham <anakin@pobox.com> | 2005-06-06 11:21:36 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2005-06-06 11:21:36 +0000 |
| commit | 69f7e7f8f5890946f4625fc071eb3f8313b17238 (patch) | |
| tree | 6d6dfa8255a2d7a2b5a3529bb3b9a4b0f6101e66 /solo.c | |
| parent | 57b3982c83694eb61dd97762ecfb3d53eeabf4f4 (diff) | |
| download | puzzles-69f7e7f8f5890946f4625fc071eb3f8313b17238.zip puzzles-69f7e7f8f5890946f4625fc071eb3f8313b17238.tar.gz puzzles-69f7e7f8f5890946f4625fc071eb3f8313b17238.tar.bz2 puzzles-69f7e7f8f5890946f4625fc071eb3f8313b17238.tar.xz | |
Introduce a new game backend function (there seem to have been a lot
of these recently) whose job is to update a game_ui to be consistent
with a new game_state. This is called by midend.c in every situation
where the current game_state changes _other_ than as a result of
make_move (Undo, Redo, Restart, Solve).
The introduction of this function allows a game_ui to contain
information about selections or highlights within a game_state which
simply wouldn't make sense when transferred to another game_state.
In particular, I've used it to fix a subtle bug in Solo whereby,
although you couldn't right-click to pencil-mode highlight a filled
square, you could _get_ a pencil-mode highlight in a filled square
if you used Undo and Redo. (Undo to before the square was filled,
right-click to highlight it, then Redo. Alternatively, left-click
and clear the square, right-click to highlight it, then Undo.)
[originally from svn r5912]
Diffstat (limited to 'solo.c')
| -rw-r--r-- | solo.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -1853,6 +1853,22 @@ static void free_ui(game_ui *ui) sfree(ui); } +static void game_changed_state(game_ui *ui, game_state *oldstate, + game_state *newstate) +{ + int c = newstate->c, r = newstate->r, cr = c*r; + /* + * We prevent pencil-mode highlighting of a filled square. So + * if the user has just filled in a square which we had a + * pencil-mode highlight in (by Undo, or by Redo, or by Solve), + * then we cancel the highlight. + */ + if (ui->hx >= 0 && ui->hy >= 0 && ui->hpencil && + newstate->grid[ui->hy * cr + ui->hx] != 0) { + ui->hx = ui->hy = -1; + } +} + static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds, int x, int y, int button) { @@ -2278,6 +2294,7 @@ const struct game thegame = { TRUE, game_text_format, new_ui, free_ui, + game_changed_state, make_move, game_size, game_colours, |