2178 Commits

Author SHA1 Message Date
56781e60ba Update copyright dates at head of manual to match others 2023-08-21 23:28:16 +01:00
7c105846b6 KaiOS: set show-labels=true in preferences for Guess
On a device with a phone keypad, driving Guess by typing numbers rather
than using the arrow keys seems natural.  But if you're going to do
that, showing the labels makes it a lot easier.  KaiOS doesn't have any
way for the user to control this, so we should default to the friendlier
state.
2023-08-21 23:06:39 +01:00
f97d11df67 js: allow for multiple environment blocks in HTML
Not that I actually need it, but it's just as easy to load multiple
environment <script>s from the DOM as it is to load one, so we may as
well do that.  Since only one element can have id="environment", we do
this by matching class="environment" as well.
2023-08-21 23:06:39 +01:00
b5367ed18a js: load preferences from HTML elements
It will be useful on KaiOS to be able to specify default user
preferences that aren't the standard ones, in the same way that we
specify some environment variables.  As with environment variables, we
can now do this be embedding a <script> element in the HTML like this:

<script class="preferences" type="text/plain">
show-labels=true
</script>

These are loaded before the preferences from localStorage, so they just
set defaults and can be overridden by the user (but not on KaiOS yet,
because we still don't have dialogue boxes there).
2023-08-21 23:06:32 +01:00
85b00e56a0 js: prefer some puzzle size even if loading isn't complete
The js_canvas_get_preferred_size() function was declining to suggest a
size for the puzzle if document.readyState wasn't "complete".  I think
my idea here was that if the document wasn't fully loaded then I
couldn't trust the size of the containing <div>.  While this was true,
declining to provide a size didn't help much since the puzzle still
needed a size, and the size of the containing <div> was the best guess
we had.

Now that function always returns the size of the containing <div> if
it exists.  This appears to mean that puzzles don't show a brief flash
of being the wrong size on KaiOS.  That was particularly visible with
Flood, where the wrong-size version had borders around the tiles that
the right-size version lacked.  The containing <div> isn't used on the
standard Web versions, so there's no change to behaviour there.
2023-08-21 22:06:21 +01:00
26a3b98f4f Remove a comment suggesting use of localStorage for prefs
Preferences in the JavaScript version _are_ stored in localStorage
now.
2023-08-21 09:54:49 +01:00
eeec6b867a Untangle: make snapping grid invariant under window resize
In grid-snapping mode, Untangle was still recording vertex positions
in increments of one pixel.  This meant that if you positioned
vertices on a small window, then enlarged the window and positioned
more vertices, the two sets of vertices generally wouldn't line up
with one another.  This was annoying, and obviously silly when
Untangle has a resolution-independent co-ordinate system.  So now the
snapped positions are recorded in a form that doesn't depend on the
tilesize.
2023-08-14 17:13:01 +01:00
899c7c41ef Flood: fix interpret_move() return value for CURSOR_SELECT2
If there's no solution in progress, it should return MOVE_NO_EFFECT,
not MOVE_UNUSED.
2023-08-14 01:55:42 +01:00
462a5450c6 Flood: correctly handle clicks that only hide cursor
If you clicked somewhere that had no effect (outside the grid or on a
square matching the colour of the top-left corner), interpret_move()
would return MOVE_NO_EFFECT (previously NULL) even though it had unset
ui->cursor.  So the keyboard cursor would remain visible until the
next window resize (or similar) when it would vanish.  Now
interpret_move() correctly returns MOVE_UI_UPDATE in these cases, so
the cursor vanishes immediately.
2023-08-14 01:49:24 +01:00
3c6493e7b3 Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Flood
Clicking outside the grid hides the keyboard cursor, so it's not
MOVE_UNUSED like it usually is.
2023-08-14 01:46:20 +01:00
a409cfe169 Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Unruly 2023-08-13 16:44:24 +01:00
20bd61bf49 Unruly: correctly handle clicks that only hide cursor
If you clicked somewhere that had no effect (on an immutable square or
a middle click on an empty square), interpret_move() would return NULL
even though it had unset ui->cursor.  So the keyboard cursor would
remain visible until the next window resize (or similar) when it would
vanish.  Now interpret_move() correctly returns MOVE_UI_UPDATE in
these cases, so the cursor vanishes immediately.
2023-08-13 16:44:24 +01:00
be9e4f8957 Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Untangle 2023-08-13 16:44:24 +01:00
92ac45fe24 Add user preference for Singles' show_black_nums
I missed this in my main commit for UI preferences
(4227ac1fd5dc25c247e7526526079b85e1890766) because it wasn't documented.
Now it is documented and it has a preference.
2023-08-13 16:44:24 +01:00
3a841891ba Unruly: use new move_cursor() features 2023-08-13 16:44:24 +01:00
4bd8822725 Unequal: use new move_cursor() features for normal movement
The shift+arrow controls for dimming clues don't currently use it
because they're a bit fiddly.
2023-08-13 16:44:24 +01:00
f8c2477ccb Twiddle: use move_cursor() for cursor movement 2023-08-13 16:44:24 +01:00
568c222106 Towers: use new move_cursor() features 2023-08-13 16:44:24 +01:00
0fa62ae4ff Tents: use new move_cursor() features 2023-08-13 16:44:24 +01:00
f7fa9d45f5 Solo: use new move_cursor() features 2023-08-13 16:44:24 +01:00
7e7545cb56 Slant: use new move_cursor() features 2023-08-13 16:44:24 +01:00
f13fbf2285 Singles: use new move_cursor() features 2023-08-13 16:44:24 +01:00
a0c7156fc8 Signpost: use new move_cursor() features 2023-08-13 16:44:24 +01:00
2aa5708bc7 Rectangles: use new move_cursor() features 2023-08-13 16:44:24 +01:00
f7c2d45fba Pattern: use new move_cursor() features 2023-08-13 16:44:24 +01:00
9f98144a0f Palisade: use new move_cursor() features 2023-08-13 16:44:24 +01:00
dfca994cf6 Mosaic: use new move_cursor() features 2023-08-13 16:44:24 +01:00
205508e969 Mosaic: remove some unused structure members
As far as I could tell, cur_x, cur_y, prev_cur_x, and prev_cur_y in
game_drawstate were never used.  prev_cur_x and prev_cur_y in game_ui
were assigned but never referenced.  So they may as well all go.
2023-08-13 16:44:24 +01:00
029cc39968 Mines: use new move_cursor() features 2023-08-13 16:44:24 +01:00
6a9a0cd8f6 Magnets: use new move_cursor() features 2023-08-13 16:44:24 +01:00
df2d6d347e Keen: use new move_cursor() features 2023-08-13 16:44:24 +01:00
995bcef981 Galaxies: use new move_cursor() features 2023-08-13 16:44:24 +01:00
4e724b25c2 Flip: use move_cursor() for cursor movement 2023-08-13 16:44:24 +01:00
2b6c6dce34 Flood: use move_cursor() for cursor movement 2023-08-13 16:44:24 +01:00
df31bc7a51 Group: make keyboard play work again.
It looks as if it's been broken for about nine years, ever since
commit 822243de1bc1fc6d introduced the system for drag-selecting a
diagonal of squares. The effect of moving the keyboard cursor and then
pressing a button was to cause crashes because the ui fields
introduced for that system to use (ohx, ohy, odx, ody, odn) were all
completely uninitialised.
2023-08-13 14:36:30 +01:00
a11ee53ef8 Keen, Solo, Towers, Undead, Unequal, Group: new UI preference.
If you're using the mouse to change pencil marks, you have to
right-click to pencil-highlight a square, then press a number or
letter key to add or remove a highlight. That causes the highlight to
vanish again. So adding or removing multiple pencil marks requires a
right-click + keypress per mark.

Chris's Android port reversed that decision, making the pencil
highlight persist so that you could 'click' just once and then press
multiple pencil keys. That makes it easier to add lots of highlights,
but harder to just remove a single one (click + press + click to
remove the highlight), unless you don't mind keeping the highlight
around afterwards cluttering up your view.

In other words, this is just the sort of thing users might reasonably
disagree on. So now we have an organised preferences system, we can
let them disagree, and each configure it whichever way they like!

This only affects mouse-based play. The keyboard cursor has _always_
worked this way, because it doesn't disappear at all; its behaviour is
unchanged, and independent of the new preference.
2023-08-13 14:35:50 +01:00
503f1c4ab8 Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Light Up
Light Up is unusual in that clicking outside the grid hides the
cursor, so the return value from clicks outside the grid is
MOVE_NO_EFFECT or MOVE_UI_UPDATE rather than the more usual
MOVE_UNUSED.
2023-08-09 15:58:34 +01:00
e30d11ecd1 Light Up: use new move_cursor() features 2023-08-09 15:48:14 +01:00
e6d25d75ba Dominosa: use new move_cursor() features 2023-08-09 15:41:55 +01:00
7e9228f154 Use move_cursor() for cursor movement in Same Game
No significant behavioural change.
2023-08-09 14:32:31 +01:00
785de41a92 Appropriately generate MOVE_NO_EFFECT from '\b' in Guess
This is the case that I care about for KaiOS.
2023-08-09 11:47:41 +01:00
8c768e7444 Use move_cursor() for cursor movement in Guess
This makes interpret_move() properly return MOVE_NO_EFFECT when the
cursor can't move, and simplifies the code as well.
2023-08-09 11:47:41 +01:00
5ec86c03a8 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.
2023-08-09 11:44:25 +01:00
7ada9a5742 Guess: define constants for flags OR'ed into peg colours 2023-08-09 00:14:37 +01:00
78af0c821a Guess: move hold marker upward by two pixels
This means that it now potentially overlaps the peg above it (part of
the current guess), rather than potentially overlapping the empty hole
below.  More importantly, it means that the hold marker is erased by
the erasure of the rest of the peg area, so there's no need to
explicitly draw absent hold markers in the background colour.  That in
turn means that absent hold markers don't nibble the tops off all the
pegs at some tile sizes.

Instead of this fix, I could have properly made the hold markers part
of the first row of empty holes, but that would have been rather
fiddly and I've long thought that the hold markers were too far from
the peg that they're holding.

I've also removed part of a comment about the drawing order of hold
markers that seems to have been obsolete even before this commit.
2023-08-08 09:35:06 +01:00
6d4b20c413 Pearl: re-use a single grid structure when generating
Pearl generally has to generate quite a lot of candidate loops before
it can find one that makes a viable puzzle.  Before this change it
generated a new grid structure for each of those candidate loops.  The
result was that grid_new() accounted for over 5% of the
puzzle-generation time.

Pulling grid_new() out of the loop-generation loop makes "pearl
--generate 100 8x8dt#0" about 6% faster on my laptop, while producing
precisely the same output.  Most of this change is just renaming the
"grid" variable in new_clues() so it doesn't collide with the typedef
of the same name.
2023-08-06 13:30:38 +01:00
ff860360c3 Same Game: level-triggered keyboard cursor hiding
Same Game doesn't want to show the keyboard cursor when the game is in a
state where no move is possible.  Previously, it did this by having
game_changed_state() hide the cursor on entry to such a state.  That
meant that reaching a dead end and undoing out of it hid the cursor,
which was confusing.

Now the cursor is hidden in game_redraw() if the game is in a dead-end
state without changing the displaysel flag in the game_ui.  That way, if
you undo out of a dead end, the cursor becomes visible again if it was
visible before.

This does mean that you can move the cursor in a dead-end state without
being able to see where it's going.  I think that's tolerable, but maybe
the cursor keys should be disabled in that state as well.
2023-08-01 23:07:08 +01:00
0dd0186662 Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Same Game 2023-07-31 23:08:20 +01:00
ecb3a9d6f2 Same Game: don't hide keyboard cursor on unrecognised keys
Pressing "undo", for instance, should leave the keyboard cursor
visible if it's visible already.  Only mouse clicks should hide it.
2023-07-31 23:02:45 +01:00
56237fa5fa Same Game: scale TILE_GAP with tilesize
TILE_GAP represents the gap between the coloured parts of adjacent
different-coloured tiles.  Rather than a fixed 2 pixels, it's now 1/16
of the tilesize (rounded to nearest).

This looks the same at the default tilesize of 32, but behaves better
with larger or smaller tilesizes.  At tilesizes below 8, the gap
disappears altogether, but that seems appropriate: at 7 pixels there's
not much space for the inner and outer squares and the cursor, and those
are all more important than the gap..
2023-07-31 22:39:33 +01:00