1720 Commits

Author SHA1 Message Date
0d36b471d8 tracks: Make the keyboard cursor more visible
The former grey was almost indistinguishable from its background colours
even on a good screen.  I've separated the cursor colour from the grid
colour and made it a lot darker. This gives a contrast ratio over 3.0
even against a darkened tile.

The cursor is still hard to see against trackwork, so maybe something
that isn't grey would be even better.
2022-12-08 11:54:23 +00:00
0b036c9e79 galaxies: Use the same code for handling all dropped arrows
The keyboard code was prone to adding null items to the undo history,
and was also unreadable.  Rather than fix it, I've replaced it with a
jump to the mouse drop handling, lightly enhanced to reject drops on
things that aren't tiles.
2022-12-07 20:41:49 +00:00
09f2052fbf guess: Much more efficient keyboard interface
Now rather than mucking around with the cursor keys, you can just type a
four-digit number and press Enter.  Of course, if you still want to muck
around with the cursor keys they work the same as before.

Since Backspace was already assigned to clear the peg under the cursor,
I haven't co-opted it for the obvious action of clearing the peg to the
left of the cursor and moving the cursor left.  The left arrow key is a
reasonable alternative anyway.

For consistency, 'L' now labels the pegs with numbers rather than
letters, and is documented.
2022-12-07 00:43:45 +00:00
14b434cb88 guess: Move the cursor to the first peg position after a guess
It's annoying having to move it to the left each time.  I suppose I
could enter the second guess in reverse order, but then I'd need to move
the cursor all the way to the right to submit it, which is just as bad.
2022-12-07 00:38:23 +00:00
a8df0189ff guess: Correct documentation to not say Space places a peg
It sets a hold now, as is mentioned in the next sentence.
2022-12-07 00:38:17 +00:00
7d61c4cee4 js: Explicitly set the height of the status bar
Otherwise it varies depending on whether it has any text in it, which
is distracting.
2022-12-06 21:48:44 +00:00
69eca65ef3 Assert that the back-end has provided a background colour
If we're going to refer to a specific colour, it seems appropriate to
insist that it exists.
2022-12-06 13:34:27 +00:00
202b7467d8 Devel docs: explain the specialness of colour 0
It's used to fill the drawing area and also by some front-ends (at
least GTK and JavaScript) to fill areas around the drawing area.
2022-12-06 13:25:47 +00:00
3e072dff91 Devel docs: Mention mid-end background clearing 2022-12-06 13:06:36 +00:00
9afdd4cca4 guess: Fix keyboard access to hold function
This has been broken since 2015.  It was accidentally using
"IS_CURSOR_SELECT(button)" in place of "button == CURSOR_SELECT" and
these are not the same thing.
2022-12-05 23:25:27 +00:00
ea223a2350 js: Put the puzzle background colour in a CSS variable
It's sometimes useful to be able to have an HTML element that visually
forms an extension of the puzzle's border.  By putting the puzzle's
colour 0 (which we assume to be its background) into a CSS variable,
such elements can do something like "background-color:
var(--puzzle-background)" to get that effect even if the puzzle uses a
non-default background colour.
2022-12-05 23:25:12 +00:00
e5b0bcae56 mosaic: Don't bother initialising fields in decode_ui()
The game_ui is guaranteed to have been freshly generated by new_ui(),
so there's no need to set fields to values that new_ui() has already
set.
2022-12-05 23:24:56 +00:00
493d2fb138 Devel docs: make it clear that decode_ui() gets a new game_ui
At least one puzzle does no actual decoding in decode_ui, but does
re-initialise some fields.  This is unnecessary because the mid-end only
calls decode_ui() with a game_ui it just allocated using new_ui().
2022-12-05 23:24:45 +00:00
8d81c1814d lightup: Remove tests for keystrokes canonicalised by mid-end
Specifically, the mid-end will never pass ' ', '\r', or '\n' to the
back-end, so it's pointless for the back-end to look for them.
2022-12-05 23:24:10 +00:00
f8ed76f815 js: Bypass our own dialogue box when loading
By constructing the <input type=file> off screen and activating it from
JavaScript, we can jump straight to the browser's upload dialogue box
without interposing our own one.  This gives a smoother experience, and
also avoids the difficult-to-handle <input type=file> ever being
visible.
2022-12-05 14:07:03 +00:00
db5d3bf10e js: Remove align=center from main <div> and make it a <main>
Instead of an align=center HTML attribute, we now centre its contents
using CSS.  Also, this element contains all the important contents of
the page, so it seems appropriate to us the HTML5 <main> element for
this.
2022-12-05 14:07:03 +00:00
83b504af27 js: Remove a layer of <div> from the HTML page
It wasn't doing anything useful, and I was getting fed up with having to
expand it in the inspector.
2022-12-05 14:07:03 +00:00
9cb0abb584 js: Specify a font for the puzzle canvas in CSS
I'd like to use this, but (a) I need it in the HTML for a little while
first, and (b) I think my current implementation may be a bit fragile.
2022-12-05 14:01:53 +00:00
b04a2cba98 js: Correct a comment describing timer_callback 2022-12-03 15:47:15 +00:00
d3ef8e65dc js: Simplify drawing context management
There's not much point in re-requesting the drawing context from the
offscreen canvas at the start of each drawing operation.  The canvas
keeps the context around and returns it on every call to getContext(),
so we may as well just keep our reference to it too.  This does mean
that the front-end won't detect puzzles drawing outside of a redraw
operation, but I think it's the mid-end's job to assert things like
that.

Rumours that I'm doing this because I had a mysterious bug whereby ctx
was unexpectedly null are entirely true.
2022-12-03 15:46:58 +00:00
f0d4705364 js: Switch to using the resize handle in the HTML 2022-12-02 23:49:00 +00:00
2522dd249b js: Don't bother resizing offscreen canvas at startup
It will get its size set soon enough once we know the size of the
puzzle anyway.
2022-12-02 23:49:00 +00:00
85dabc1eb9 js: Improve comment explaining same-origin policy for file:
Also a way around it, at least in Firefox.
2022-12-02 23:49:00 +00:00
acd1f45152 js: Add an SVG resize handle to the HTML
This is more compact than carefully drawing it on a canvas in
JavaScript.  More importantly, the SVG resize handle scales nicely as
the page is zoomed, or on high-DPI screens.

At the moment, the nice SVG resize handle is removed by JavaScript,
but we need to wait a little while for everyone to get the new HTML
cached before changing that.
2022-12-02 23:43:51 +00:00
66a927920a js: Remove a JavaScript construct that confused emcc -O3 2022-12-02 02:10:19 +00:00
2b5a4a062c Document how Enter and Space are handled in the mid-end
They've been canonicalised to CURSOR_SELECT and CURSOR_SELECT2 since
2008.
2022-11-30 13:11:13 +00:00
dbb2d2adb2 js: Allow for putting a resize handle in HTML 2022-11-29 23:34:43 +00:00
1611a5e058 Developer doc correction: list.c is not generated by Perl any more 2022-11-29 21:13:52 +00:00
b967a3ea86 js: Remove support for creating the status bar in JavaScript
Now we depend on its being in the HTML.
2022-11-28 22:51:15 +00:00
e8cdac58e5 js: Don't word-wrap the status bar
With word-wrapping disabled, long status-bar texts fall off the
right-hand end rather than wrapping onto an invisible second line.
This is less confusing because it makes the overflow more obvious.
I've also turned on "text-overflow: ellipsis" for extra obviousness.
Finally, this also the need to explicitly set the height of the status
bar, not that that was doing any harm.
2022-11-28 22:49:30 +00:00
4be221ba49 Update current-as-of commit ID in developer docs
I think I've made all the updates necessary already.
2022-11-27 19:52:47 +00:00
c6e312b252 js: Remove "width" and "height" attributes from HTML <canvas>
They were set to "1px", which isn't a valid value since they're meant to
be integers.  Since they weren't valid, they were ignored.  This doesn't
seem to have caused any trouble, so they may as well be removed.  In any
case, the canvas is invisible until after its size has been set by
JavaScript.
2022-11-27 19:39:18 +00:00
19540d2ef8 js: Hide menus and resize handle when printing 2022-11-26 08:55:36 +00:00
115edab459 js: Remove alpha channel from almost all our canvases
Specifying the { alpha: false } option when creating a rendering context
tells the browser that we won't use transparency, and the standard
puzzle canvases, along with blitters, are all opaque.  No obvious
effect, but the MDN suggests that this should reduce CPU usage.

The one exception here is the resize handle, which actually is
transparent.
2022-11-25 19:13:43 +00:00
a6a799720f js: Correct co-ordinate-mapping function for what CSS actually does
By default, CSS uses "object-fit: fill", which means that an object is
independently scaled in both dimensions to fit its containing box.
This is simpler than what I'd assumed (which was "object-fill:
contain").  Obviously, the HTML could be changed to use a different
object-fit, in which case this code would have to detect it, but for
now following the CSS default is more correct than not.
2022-11-25 18:42:44 +00:00
d90c0a9edb flip: Set a lower bound on the size of little diagrams
This ensures that they don't vanish entirely and small tile sizes.
2022-11-25 18:04:39 +00:00
0b36c01639 mines: Ensure highlights don't vanish at small tile sizes
The highlights for covered squares now have a minimum width of 1 pixel,
which means that Mines is comfortably playabale down to about 8 pixel
tilesize, below which the numbers become unreadable.
2022-11-25 13:29:04 +00:00
5a2ea91cad js: Subtle extra padding for menus
Each menu item has a -0.5px margin so that the borders of adjacent menu
items overlap, but we don't actually want the menu items to protrude
beyond the containing <ul>.  Adding 0.5px of padding to the <ul>
achieves that.
2022-11-24 23:28:28 +00:00
38e17ebab2 js: If the HTML contains a dialogue-box form, delete it
This is so that (given time for caches to expire) I can switch to having
a persistent dialogue box in HTML rather than fabricating it from
scratch in JavaScript each time it's used.
2022-11-24 21:03:31 +00:00
36c9062cbd js: Disable menu keyboard controls when dialogue box is active
I think this is broadly the wrong approach, but it's an improvement
until I implement the right one.
2022-11-24 18:26:59 +00:00
271fb7f47c js: More conventional marking of menu item types
Menu items that open dialogue boxes are now marked with ellipses, while
menu items that lead to submenus have pointing triangles.

The triangles are implemented as SVG files embedded in data: URLs in the
CSS, which is kind of silly but also works really well.  There are
suitable characters in Unicode, but some of my test systems don't have
fonts containing them, so maybe the SVG is better.
2022-11-24 16:24:59 +00:00
fe29d1cbf5 js: Replace status-bar holder in HTML with status bar itself
This makes the HTML simpler, and will allow for simplifying the JS too.
2022-11-23 23:19:28 +00:00
b5ccb0c9af js: Add actions for more keys in menus
I expect Escape to exit the menu, and SoftRight should do that as well
for KaiOS.  Backspace goes up one level through the menus, again because
that's conventional on KaiOS and not too confusing elsewhere.
2022-11-23 22:27:54 +00:00
e79270368b js: Move global keyboard handler to capturing phase
In the bubbling phase it managed to catch the "Enter" keypress that
opened a dialogue box from the menu and use it to close the dialogue
box again.  I think it's probably reasonable to have it run earlier and
just permanently steal any keypresses it wants.
2022-11-23 21:56:42 +00:00
2d439dd00e js: Move focus-tracking to entirely "focus" events
When we disable a button, it loses focus but doesn't generate a "blur"
event.  This means our "focus-within" class goes wrong.  Instead of
relying on "blur" events to remove the class, remove it from any
inappropriate elements in the "focus" handler.  This requires attaching
the handler to the root element of the document, but I've got plans that
need that anyway.
2022-11-23 21:56:42 +00:00
8445f07827 js: Replace :focus-within with JS-maintained .focus-within
Old browsers (like KaiOS 2.5) don't have :focus-within, but it's pretty
easy to replace the pseudo-class with a real .focus-within class
maintained by JavaScript event handlers.  This is made only marginally
fiddlier by the odd fact that "focus" and "blur" events don't bubble.
2022-11-23 21:56:42 +00:00
52cd58043a js: Add keyboard navigation for menus
Once the input focus is in the menu system (for instance by Shift+Tab
from the puzzle), you can move left and right through the menu bar and
up and down within each menu.  Enter selects a menu item.  The current
menu item is tracked by giving it the input focus.
2022-11-23 21:53:59 +00:00
b1b2da9896 Mid-move icon for Cube 2022-11-23 21:28:10 +00:00
96cda05b89 Add missing dependency of screenshots on their save files 2022-11-23 14:34:37 +00:00
fffeae956a nullgame: Don't bother blanking the puzzle window
This is now centralised in the mid-end.
2022-11-22 13:54:30 +00:00