A UI suggestion from Ben: label the Custom element in the dropdown
with a trailing "..." to hint that it opens a further dialog box.
However, the _invisible_ Custom option is merely indicating what you
_do_ have selected, so we leave that one as it is. (So now they're no
longer exact twins of each other, of course.)


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9796 cda61777-01e9-0310-a592-d414129be87e
Fix the icon makefile in the wake of r9795.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9797 cda61777-01e9-0310-a592-d414129be87e
Greg Hewgill points out a code path on which the angle parameter to
the Penrose grid generation function can fail to be initialised.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9798 cda61777-01e9-0310-a592-d414129be87e
Rewrite trim_rect() for robustness.

The previous version dealt adequately with rectangles _partially_
overlapping the edge of the canvas, but doesn't correctly handle a
rectangle that's completely out of bounds in one direction. Replace
with a complete rewrite which is more easily seen to be correct. Also,
while I'm at it, add a missing condition to draw_update() so that we
don't even bother calling the Javascript half of it on any rectangle
that's been trimmed into nonexistence.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9800 cda61777-01e9-0310-a592-d414129be87e
Fix a grammatical confusion on the Unruly web page.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9801 cda61777-01e9-0310-a592-d414129be87e
Try to give a more friendly message if anything goes wrong during
puzzle startup. The puzzle web pages now enclose the whole puzzle
(buttons, canvas, permalinks) in a div set to display:none, and
instead display an apologetic message saying 'sorry, it didn't work';
then, if we get through the whole init function without crashing, we
show the puzzle and hide the apology.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9802 cda61777-01e9-0310-a592-d414129be87e
Clarify header comments in the Emscripten frontend's source files to
mention that the HTML pages generated by html/jspage.pl are also an
integral part of this front end. (The NestedVM frontend is more
self-contained, needing only an appropriate <applet> tag, but this one
expects quite a few components to exist on the page and have the right
ids.)


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9803 cda61777-01e9-0310-a592-d414129be87e
Remove trailing commas at the ends of initialiser lists. IE 8 and 9
didn't like them, which doesn't matter as such since they won't run
these JS puzzles anyway (no TypedArray support) but it hints that
other JS implementations might be picky about this too.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9804 cda61777-01e9-0310-a592-d414129be87e
I've just realised that the JS puzzles' permalinks were not updating
when the user pressed 'n' for a new game, because all the front end
knows is that it passed a keystroke to the puzzle, and it has no way
of hearing back that a particular keypress resulted in a game id
change.

To fix this, I've renamed midend_request_desc_changes to
midend_request_id_changes and expanded its remit to cover _any_ change
to the game ids. So now that callback in the Emscripten front end is
the only place from which update_permalinks is called (apart from
initialising them at setup time), and that should handle everything.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9805 cda61777-01e9-0310-a592-d414129be87e
IE doesn't default to giving focus to the puzzle canvas on a mouse
click, so manually implement that behaviour. (Without it, it's quite
hard to focus the canvas at all in IE.)


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9806 cda61777-01e9-0310-a592-d414129be87e
Implement debug_printf() in the Emscripten front end, since that's the
easiest way to call js_debug with formatted parameters.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9807 cda61777-01e9-0310-a592-d414129be87e
Stop accidentally subtracting onscreen_canvas.offset{Left,Top} from
the return value of relative_mouse_coords! I only got away with that
error because the canvas was at offset zero compared to its immediate
parent element.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9808 cda61777-01e9-0310-a592-d414129be87e
Assorted HTML/CSS fiddlings to make things work better in IE. I've
added a trivial doctype (IE complained without it), but that caused a
gap to appear between the puzzle and the status bar, so I tinkered a
bit more and ended up removing the <table> completely (no great loss)
as well as adding display:block to the canvas and explicitly setting
the width of not only the status bar div but also its parent div.
Meanwhile, I'm putting the "px" on the end of a lot of properties I
set from JS, because IE complains about that too if I don't.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9809 cda61777-01e9-0310-a592-d414129be87e
Rewrite the JS keyboard handling to cope with IE and Chrome.

Unlike Firefox, IE and Chrome don't generate keypress events at all if
you suppress the default handling of keydowns. Therefore, we have to
figure out everything from the keydown event, because if we unsuppress
the default handling of any keydowns then we'll get annoyances like ^R
going back to meaning reload-page rather than redo-move.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9810 cda61777-01e9-0310-a592-d414129be87e
Regretfully remove my trickery with a hidden <option> element inside
the game-type <select>, since IE turns out to ignore display:none on
options. Oh well.

Instead I now do a more transparent thing: when custom game params are
in use, there's a "Custom" option selected in the dropdown, and a
separate 'Re-customise' option which brings the config box back up.
When an ordinary preset is selected, the Custom option is missing, and
there's just a 'Customise'.

In the process I've tinkered a bit to arrange that the custom 'preset'
is always represented by a negative number rather than one past the
last real preset; that seems more consistent overall.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9811 cda61777-01e9-0310-a592-d414129be87e
Update the list of tested browsers.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9812 cda61777-01e9-0310-a592-d414129be87e
Mention Safari in the list of tested browsers.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9816 cda61777-01e9-0310-a592-d414129be87e
Don't forget to NULL out the new game id notification callback, or
else it might start off accidentally initialised to nonsense in front
ends which don't use it.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9817 cda61777-01e9-0310-a592-d414129be87e
Fix the 'puzzle doesn't work' apology, which I'd accidentally moved
inside the top-level display:none puzzle container as a side effect of
r9809.

Also, while I'm at it, reword the apology to mention typed arrays as
the most likely cause of failure (AFAIK that's the most modern feature
required by the JS front end), and fix indecision between singular and
plural ('this puzzle' doesn't work, perhaps a feature 'they depend on'
is missing).


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9818 cda61777-01e9-0310-a592-d414129be87e
Small refactor to relative_mouse_coords: now the functionality which
returns an element's absolute position on the web page is split out
into a subfunction that can be called directly.


git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9819 cda61777-01e9-0310-a592-d414129be87e