339 Commits

Author SHA1 Message Date
6989217624 James H's patch for a keyboard-controlled cursor in Flip.
[originally from svn r6049]
2005-07-03 14:49:00 +00:00
85a29743ef Allow game backends to use even special keystrokes such as N and Q;
they will only be processed as special by the midend if unwanted by
the backend. This causes 5x5 Solo to become just about playable,
because you can now click in a square and type `n'. However, typing
`n' when a square is not selected will revert to the normal
behaviour of starting a new game.

(This isn't particularly ideal, I know, but it's better than
nothing.)

[originally from svn r6048]
2005-07-03 11:45:49 +00:00
64e114cce1 draw_polygon() and draw_circle() have always had a portability
constraint: because some front ends interpret `draw filled shape' to
mean `including its boundary' while others interpret it to mean `not
including its boundary' (and X seems to vacillate between the two
opinions as it moves around the shape!), you MUST NOT draw a filled
shape only. You can fill in one colour and outline in another, you
can fill or outline in the same colour, or you can just outline, but
just filling is a no-no.

This leads to a _lot_ of double calls to these functions, so I've
changed the interface. draw_circle() and draw_polygon() now each
take two colour arguments, a fill colour (which can be -1 for none)
and an outline colour (which must be valid). This should simplify
code in the game back ends, while also reducing the possibility for
coding error.

[originally from svn r6047]
2005-07-03 09:35:29 +00:00
8dd7ee3007 James Harvey points out that entering an invalid game ID can affect
the current midend state even if you don't subsequently enter a
valid one. Reorganise midend_game_id_int() so that (just like
midend_deserialise()) it does all its error checking before altering
anything in the midend's persistent data, so that it either succeeds
completely or fails before doing anything at all.

[originally from svn r6045]
2005-07-01 16:50:49 +00:00
091fe57e0f Prevent drags from being started outside the playing area, which was
causing invalid move descriptions to be returned from
interpret_move() and then failing an assertion when execute_move()
refused them.

[originally from svn r6044]
2005-06-30 18:11:41 +00:00
8f670292a7 Preset names retrieved from the environment must be dupstr()ed. How
did I miss this before? It just caused a segfault for me, which is
entirely fair enough, but I've no idea why it didn't fail before!

[originally from svn r6043]
2005-06-30 18:11:02 +00:00
6f47baddf9 Load and Save are now supported on all three desktop platforms, and
documented. (This means the GTK temporary dependency on an
environment variable is now gone.)

[originally from svn r6042]
2005-06-30 18:00:37 +00:00
118abb4fc9 General robustness patch from James Harvey:
- most game_size() functions now work in doubles internally and
   round to nearest, meaning that they have less tendency to try to
   alter a size they returned happily from a previous call
 - couple of fiddly fixes (memory leaks, precautionary casts in
   printf argument lists)
 - midend_deserialise() now constructs an appropriate drawstate,
   which I can't think how I overlooked myself since I _thought_ I
   went through the entire midend structure field by field!

[originally from svn r6041]
2005-06-30 09:07:00 +00:00
101324af67 Attempting to begin a drag from (i.e. just click on) the hint pegs
for a past guess caused strangeness up to and including segfault,
thanks to bad bounds checking. Well spotted John Sullivan.

[originally from svn r6040]
2005-06-30 08:25:47 +00:00
0494e94c4a Add a cast whose absence was causing a (-Werror-exacerbated) compile
warning on OS X.

[originally from svn r6037]
2005-06-29 16:32:53 +00:00
074f11edc4 Validation of random-state-type game descriptions was broken. This
meant that a Mines game saved before the first click had taken place
could not be successfully reloaded.

[originally from svn r6036]
2005-06-29 12:19:08 +00:00
238a6d08fe When serialising this game, it's probably better to keep the
half-finished guess in the game_ui rather than throwing it away.

[originally from svn r6033]
2005-06-29 08:20:49 +00:00
1c896ef18b Make peg removal accessible from the keyboard.
[originally from svn r6032]
2005-06-28 18:10:20 +00:00
ea172a0460 New {en,de}code_ui functions should be static. Oops.
[originally from svn r6031]
2005-06-28 17:43:50 +00:00
7011028b17 Actually implemented the serialise/deserialise functions in
midend.c. Also I've added an experimental front end in gtk.c only:
`Save' and `Load' options on the Game menu, which don't even show up
unless you define the magic environment variable
PUZZLES_EXPERIMENTAL_SAVE. Once I'm reasonably confident that the
whole edifice is plausibly stable, I'll take that out and turn it
into a supported feature (and also implement it in OS X and Windows
and write documentation).

[originally from svn r6030]
2005-06-28 17:05:05 +00:00
89fdc09c29 More serialisation changes: the game_aux_info structure has now been
retired, and replaced with a simple string. Most of the games which
use it simply encode the string in the same way that the Solve move
will also be encoded, i.e. solve_game() simply returns
dupstr(aux_info). Again, this is a better approach than writing
separate game_aux_info serialise/deserialise functions because doing
it this way is self-testing (the strings are created and parsed
during the course of any Solve operation at all).

[originally from svn r6029]
2005-06-28 11:14:09 +00:00
6c9beb697b Rogue diagnostic!
[originally from svn r6028]
2005-06-28 08:35:55 +00:00
263a39e7e5 Move a rogue declaration to the top of its block.
[originally from svn r6027]
2005-06-28 08:06:56 +00:00
cdb8433c0a Another function pair required for serialisation; these ones save
and restore anything vitally important in the game_ui. Most of the
game_ui is expected to be stuff about cursor positions and currently
active mouse drags, so it absolutely _doesn't_ want to be preserved
over a serialisation; but one or two things would be disorienting or
outright wrong to reset, such as the Net origin position and the
Mines death counter.

[originally from svn r6026]
2005-06-28 07:33:49 +00:00
08410651e0 Annoying special cases for Mines.
Firstly, the `Restart' function now reconstructs an initial game
state from the game description rather than dup_game(states[0]).
This means that Restart in a game of Mines restarts to just _after_
the initial click, so you can resume the puzzle-solving part without
having to remember where you placed that click.

Secondly, the midend now contains a second `private' game desc,
which is guaranteed to actually reconstruct the initial game_state
correctly (which Mines's publicly visible game descs tend not to,
since they describe a state which has already had the first click).
This should make serialising of Mines more sensible.

[originally from svn r6025]
2005-06-28 06:59:27 +00:00
76d50e6905 Re-architecting of the game backend interface. make_move() has been
split into two functions. The first, interpret_move(), takes all the
arguments that make_move() used to get and may have the usual side
effects of modifying the game_ui, but instead of returning a
modified game_state it instead returns a string description of the
move to be made. This string description is then passed to a second
function, execute_move(), together with an input game_state, which
is responsible for actually producing the new state. (solve_game()
also returns a string to be passed to execute_move().)

The point of this is to work towards being able to serialise the
whole of a game midend into a byte stream such as a disk file, which
will eventually support save and load functions in the desktop
puzzles, as well as restoring half-finished games after a quit and
restart in James Harvey's Palm port. Making each game supply a
convert-to-string function for its game_state format would have been
an unreliable way to do this, since those functions would not have
been used in normal play, so they'd only have been tested when you
actually tried to save and load - a recipe for latent bugs if ever I
heard one. This way, you won't even be able to _make_ a move if
execute_move() doesn't work properly, which means that if you can
play a game at all I can have pretty high confidence that
serialising it will work first time.

This is only the groundwork; there will be more checkins to come on
this theme. But the major upheaval should now be done, and as far as
I can tell everything's still working normally.

[originally from svn r6024]
2005-06-27 19:34:54 +00:00
7cb29412c1 Fix GTK casts to restore correct compilation on GTK 2.0 after r6022.
[originally from svn r6023]
[r6022 == e1c84c9a4ea9e74c128c28a77ea08336350991e3]
2005-06-26 13:12:34 +00:00
e1c84c9a4e Under Gtk 1.2 (at least on Debian woody), a config or preset change that would
otherwise not cause the window size to change caused it to become very small
indeed. This change from Simon fixes that behaviour; I haven't tested it with
Gtk 2.

[originally from svn r6022]
2005-06-26 12:54:08 +00:00
258293a82a Add debugging support.
[originally from svn r6018]
2005-06-25 17:24:03 +00:00
7f7583d7f4 Further additions to the Guess docs.
[originally from svn r6014]
2005-06-25 13:52:52 +00:00
185d999b6b Make the keyboard-control cursors visible whenever a keyboard control is
activated.

[originally from svn r6013]
2005-06-25 13:43:45 +00:00
a0d0c7e795 The AngleArc() function that was being used to draw circles on Windows turns
out to be unsupported on the Win9x/Me series. Use Arc() instead (tested on
Win98 and Win2K).

[originally from svn r6012]
2005-06-25 13:24:19 +00:00
6e79ff9df5 Couple of presets.
[originally from svn r6011]
2005-06-24 16:35:42 +00:00
b873c87c37 More patches from James Harvey: enforce a maximum brightness in the
background colour (to ensure white pegs show up against it), and
convert the keyboard-control cursor into a rectangle when it's over
the hint pegs (otherwise it looks rather silly for numbers of pegs
above 4).

[originally from svn r6010]
2005-06-24 16:35:27 +00:00
31d96181a8 Fix another display/UI glitch which triggered if you filled a row
(so that the hint pegs lit up as `ready') and then pressed Undo: the
markable flag would remain set and the redrawing wouldn't darken the
pegs again.

[originally from svn r6009]
2005-06-24 12:30:30 +00:00
029e8b85ce Turn off the keyboard-control cursor when the user reverts to mouse
control.

[originally from svn r6008]
2005-06-24 11:13:08 +00:00
5fc29f7717 Change the preprocessor symbol DEBUG' to DEBUGGING', since the
former is automatically defined by Cygwin.

[originally from svn r6007]
2005-06-24 11:05:43 +00:00
249d345ed4 My background-erasing changes in r5996/r5997 caused trouble with the
keyboard-control cursors, and when I tried to fix those more
wallpaper bubbles popped up elsewhere. Here's what I think is a
proper fix: a comprehensive overhaul of the redraw code such that,
instead of tracking the cursor positions explicitly in the
drawstate, we instead track for each peg position whether or not a
cursor is currently displayed at that position. So cursor erasing
and cursor drawing become part of the main draw loop rather than a
separate bit on the end.

[originally from svn r6006]
[r5996 == 3d58feb561ef09cf977f710d69a3562529e23f0f]
[r5997 == a46e3266558eaf5cd18ac2a6322af65c196c3655]
2005-06-24 11:03:20 +00:00
75225284c0 Array overflow fix from James Harvey.
[originally from svn r6005]
2005-06-23 23:11:59 +00:00
fda72b0f1e Make the hold marker' in Guess accessible from the keyboard (H' key, for want
of a better idea).

[originally from svn r6004]
2005-06-23 22:01:17 +00:00
7199b42623 Factual and other corrections/additions to the Guess docs.
[originally from svn r6003]
2005-06-23 21:47:55 +00:00
2dabe9458f Reinstate WinHelp topic now we have a manual chapter.
[originally from svn r6002]
2005-06-23 21:37:05 +00:00
c8d2f420f0 Credit James Harvey.
[originally from svn r6000]
2005-06-23 19:01:01 +00:00
af052f2620 James Harvey's extensions to Guess: a couple of extra game settings
plus a manual chapter.

[originally from svn r5999]
2005-06-23 18:50:58 +00:00
2ce863a76d And forgot to add guess to the Unix make install target! I need a list.
[originally from svn r5998]
2005-06-23 18:05:19 +00:00
a46e326655 Bah, not good enough. Extend those background erases by one more
pixel.

[originally from svn r5997]
2005-06-23 18:02:21 +00:00
3d58feb561 Erase backgrounds when drawing over an existing circle, for the
benefit of antialiasing platforms such as OS X. Also in this
checkin, fiddle with svn:ignore (there's a new puzzle binary).

[originally from svn r5996]
2005-06-23 17:43:43 +00:00
ebca9edc7b Allow dragging of coloured pegs from previous guesses. Also
reorganise the colours so there are fewer of those terribly
computery cyan and magenta shades, and more good old-fashioned
colours with simple names like orange and purple. Finally, change
the `right place' marking peg colour from red to black, in line with
at least _my_ old Mastermind set (I faintly suspect red marker pegs
of being an Americanism) and also so that the marker pegs and the
coloured pegs have no colours in common.

[originally from svn r5995]
2005-06-23 16:36:09 +00:00
1aed44db0b Must outline as well as filling circles, because not all platforms
can be guaranteed to draw bare filled shapes the same way.

[originally from svn r5994]
2005-06-23 12:55:47 +00:00
d781db11dd Two small fixes: add some ceil() calls to stop the puzzle shrinking
every time I press N, and revert the help topic to NULL until some
documentation materialises.

[originally from svn r5993]
2005-06-23 12:21:14 +00:00
f862a227be `Guess', a Mastermind clone from James Harvey. This checkin also
introduces a few new utility functions in misc.c, one of which is
the bitmap obfuscator from Mines (which has therefore been moved out
of mines.c).

[originally from svn r5992]
2005-06-23 09:14:19 +00:00
b909204392 Introduce a front-end function to draw circles.
[originally from svn r5991]
2005-06-23 08:24:52 +00:00
973ced1c7c This TODO comment should have been taken out in r5913 :-)
[originally from svn r5988]
[r5913 == 02035753f817173a6861d1fc4bec437508cec42d]
2005-06-22 09:26:03 +00:00
b176767dfa New front end functions to save and restore a region of the puzzle
bitmap. Can be used to implement sprite-like animations: for
example, useful for games that wish to implement a user interface
which involves dragging an object around the playing area.

[originally from svn r5987]
2005-06-22 08:30:31 +00:00
64fbdf60ee Add WinHelp topic
[originally from svn r5984]
2005-06-21 11:16:36 +00:00