2193 Commits

Author SHA1 Message Date
e20644a3ba Emscripten build: stop setting MIN_EDGE_VERSION.
Emscripten 3.1.51 withdrew support for legacy (pre-Chrome) Edge
completely, and this command-line option now provokes an error from
the compiler.
2024-02-29 07:55:38 +00:00
7a93ae5d3c It's a new year. 2024-01-02 23:34:28 +00:00
4d45ea5bf2 js: Turn the resize handle into embedded SVG
This means that it can inherit the current colour from the HTML around
it, and hence adapt properly to changes of colour scheme.
2023-12-07 18:46:03 +00:00
3243a1fd77 Wrap a few long lines in Keen 2023-12-06 22:39:14 +00:00
08365fb260 Windows: add a VERSIONINFO resource to the puzzle binaries.
This includes the textual version number in its existing
form (yyyymmdd followed by an abbreviated git hash). The four-part
binary version is set to 1 followed by year, month and day; if I ever
want to change that, I can increment the initial 1.

FileDescription is taken from the existing DESCRIPTION string provided
to each puzzle() statement in CMakeLists.txt.

This means that puzzles.rc now always defines at least one resource,
so we can remove the workaround for MinGW's windres not being able to
cope with an empty .rc file, which added a dummy resource in the
absence of an icon.
2023-11-19 15:12:47 +00:00
595338fa43 Windows: leave puzzles.rc out of auxiliary GUI tools.
There's no reason to put the .rc file into developer tools like
galaxieseditor at all. Its current job is to add an icon, and those
tools don't have any. I'm about to add version information, and they
won't have that either (in particular, no description string like the
games do).

The CLI developer tools already don't include puzzles.rc, and GUI dev
tools are more like those than they are like puzzles.

puzzles.rc was being added to an aux GUI tool's source file list by
get_platform_puzzle_extra_source_files(), which is called for aux GUI
tools as well as for puzzles proper. However, it's not as simple as
just eliminating that call, because on Unix, we _do_ need to add the
same extra source files to GUI dev tools that we do for puzzles,
because gtk.c contains external references to either an array of the
puzzle's icons or an empty array indicating that there aren't any, so
_something_ has to provide that.

So instead, get_platform_puzzle_extra_source_files now takes an extra
argument saying whether the program is a real puzzle or an aux tool;
windows.cmake leaves out puzzles.rc in the latter case, but unix.cmake
puts the icon array in unconditionally.
2023-11-19 15:04:50 +00:00
cb8dcc34f7 Untangle: turn #define VERTEX_NUMBERS into a preference.
This compile-time definition switches the game into showing a distinct
non-negative integer for each vertex, instead of indistinguishable
blobs.

Its main use to me in the past has been when I'm trying to planarise
'real' graphs, that is, graphs I got from outside the game and wanted
a planar embedding of. Having made one in Untangle's UI I could then
read off which vertex was which.

That's an unusual use of the game, but _might_ be useful to someone
else. Perhaps a more interesting use of this feature would be to
direct someone else's play verbally - it would be much easier to tell
them which vertex to click on that way!
2023-11-18 13:56:42 +00:00
96d65e852c Untangle: turn #define SHOW_CROSSINGS into a preference.
I just found this #define in the Untangle source code, which I'd
completely forgotten was there. It causes each graph edge to be
highlighted in red if another edge crosses it, so that when you only
have a small number of crossings left to sort out, it's obvious where
they are.

Now we have a preferences system, there's no need to make this a
compile-time option! We can make it run-time selectable, for users who
want the extra help.
2023-11-14 12:59:44 +00:00
3ae90bcd3a Map: document explicitly that initial regions are immutable.
Chris Boyle reports that a few users of the Android port were confused
by this, e.g. https://github.com/chrisboyle/sgtpuzzles/issues/624 .

(That seems surprising to me, since I view Map as extremely closely
related to Solo - both are special cases of the general game class
'here is a partial k-colouring of a graph, find the unique total
k-colouring that extends it', just with different ranges of k and
different valid graphs. And surely nobody approaches a Sudoku puzzle
and expects to be able to rub out provided clues they don't like! But
I suppose if you're thinking of Map as a completely separate puzzle
then perhaps that analogy doesn't have the same force.)
2023-11-14 12:42:37 +00:00
3264d56791 Fix display glitch in Jigsaw Solo's pencil-mode cursor.
In Jigsaw Solo, block boundaries aren't convex, so it's possible for
one of them to have an inward corner. If that corner is in the top
left of a selectable cell, and you right-click that cell to display
the pencil-mode 'cursor' in the form of a triangle in the top left,
then the cursor was accidentally drawn on top of the block boundary,
where it ought to be underneath it.

For example, in game id 5j:d1d4_4c3_1d2d,bb_baaa_dca_baaba, right-
clicking in the bottom right square of the grid demonstrates the
problem.

Jonas Kölker fixed this for Keen in 2015, in commit 6482ed0e3c886af.
This is the identical fix, in Solo's very similar-looking drawing
routine. I feel embarrassed to have taken eight years to get round to
it!
2023-11-14 12:36:41 +00:00
35f796542e Singles: fix error highlighting when grid is disconnected.
The loop that selects one of the disconnected regions (represented as
equivalence classes in a dsf) to _not_ highlight as an error was
failing to call dsf_canonify() to get the canonical element of the
class.

Instead, it was relying on having met the canonical element of the
class first, because it iterates up the array in order, and in the old
dsf implementation, canonical elements were always minimal ones. But
the DSF refactoring made that untrue, so now we have to explicitly
canonify each value we come to.

Thanks to Steffen Bauer for the diagnosis and suggested fix.
2023-10-24 18:54:26 +01:00
2d9e414ee3 Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Inertia 2023-09-17 23:22:32 +01:00
67496e74f6 Singles: prevent hangs at low puzzle sizes.
A user reports that trying to generate a 2x2 or 3x3 puzzle at Tricky
difficulty causes the generator to hang, for the usual reason that
there aren't any - puzzles of that size are either ambiguous or Easy.

The usual response in this code base is to quietly downgrade the
puzzle difficulty when absolutely necessary, so here's some code to do
that (and also for 2x3, which the user didn't test, but unsurprisingly
behaves the same way).
2023-08-27 13:26:01 +01:00
d3f825c98c Singles: fix spelling in a validate_params error.
'height', not 'neight'. Apparently has been misspelled since the
puzzle was first committed. I suppose they look similar enough that it
never caused a problem.
2023-08-27 13:24:31 +01:00
f279c5eba0 midend_request_keys: fix memory leak of a game_params.
Thanks to Steffen Bauer for spotting this. The call to
midend_get_params(me) was making a duplicate of me->params, and
nothing was freeing it.

Since the game_params is passed to request_keys as a const pointer, it
should be safe to pass me->params itself, so that instead of adding a
free, we can remove the unnecessary allocation.
2023-08-24 12:46:38 +01:00
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