Nick Bowler [Sat, 12 Mar 2022 23:16:39 +0000 (18:16 -0500)]
Reduce redrawing on resize events.
It is a waste of time redrawing parts of the window on resize that
will be redrawn due to expose events immediately afterwards. This
is particularly noticeable when the program is first started and
everything is drawn twice.
Nick Bowler [Sat, 12 Mar 2022 22:36:07 +0000 (17:36 -0500)]
Restructure motif code a bit.
Move the game input callback into motif.c, which essentially brings all
the user input parts together in one file and all the display parts in
the other file.
Nick Bowler [Sat, 12 Mar 2022 21:31:12 +0000 (16:31 -0500)]
Report changed positions from game_do_move.
Instead of manually comparing positions before and after the move,
we can just alter the definition of game_do_move to return this
information, since it has already done most of the work internally.
Nick Bowler [Sat, 12 Mar 2022 21:11:02 +0000 (16:11 -0500)]
Only redraw changed tiles when right clicking.
By changing the definition of game_check_goal to return a bit-mask
of mismatched positions, we can just pass that to the redraw mask to
reduce the amount of rendering needed.
Nick Bowler [Sat, 12 Mar 2022 21:15:24 +0000 (16:15 -0500)]
Add build-time option to help debug X11 rendering.
Add #define that can be manually set in config.h to enable additional
debug drawing. This is intended purely for development. Currently this
causes the system to highlight tiles before they are redrawn, in order
to watch things like expose handling and tile movement.
Nick Bowler [Thu, 10 Mar 2022 04:44:39 +0000 (23:44 -0500)]
Track elapsed time of the game.
Since this is a speed solving game, it is kind of important to know
how much time it took to solve the puzzle. Start by adding a timer to
the game state so we can print elapsed time at the end. Related GUI
elements will be coming later.
The game will no longer start immediately. When the program is
launched, it will begin in a winning state.
Nick Bowler [Thu, 10 Mar 2022 04:18:18 +0000 (23:18 -0500)]
Add a more direct way to specify the game background.
Rather than the user needing to know any details of the widget
hierarchy, add an application resource to set the game background
too (along with the tile colours).
We can also leverage Xt to allocate colours for us, which simplifies
things a bit.
Nick Bowler [Thu, 10 Mar 2022 03:53:18 +0000 (22:53 -0500)]
Avoid uninitialized value error in help output.
Technically simply passing an unitialized (indeterminate) arg value
to the help_print_option function has undefined behaviour even though
it is only unset in cases where it will not actually be used by the
function. But it is easy to just ensure it has a well-defined value.
Nick Bowler [Wed, 9 Mar 2022 02:03:48 +0000 (21:03 -0500)]
Generate and distribute some icon files.
Since we now have code that generates nifty icons in various sizes,
we can fairly easily make use of it to generate and install icon
files. These files need to be distributed because the application
cannot be run in the cross-compilation case, which will also avoid
the distribution depending on external image conversion utilities.
Nick Bowler [Tue, 8 Mar 2022 06:08:29 +0000 (01:08 -0500)]
Use XPM as icon test output format.
The output of this test program is very close to XPM format.
So why not make it actually produce XPM format. This gives
us a good way to have it output actual colour icons too.
Nick Bowler [Tue, 8 Mar 2022 04:35:22 +0000 (23:35 -0500)]
Allow compilation without X11.
At the moment this means nothing useful gets installed, but "make check"
is possible. The icon functions being tested don't _really_ depend on
X11, just the XColor structure for which we can supply a suitable
definition.
Nick Bowler [Sat, 5 Mar 2022 21:32:48 +0000 (16:32 -0500)]
Fix boardmove testcase typo.
Comparing "if (argv > 0)" is an obvious typo, totally invalid and bogus.
Weirdly GCC fails to complain without "-pedantic", but HP-UX cc is happy
to inform us about the error.