Nick Bowler [Fri, 18 Nov 2022 03:45:07 +0000 (22:45 -0500)]
Avoid Gnulib std-gnu11 module.
It has come to my attention that this module rewrites AC_PROG_CC in
a way that actually breaks Automake's AM_PROG_CC_C_O functionality.
This results in the "compile" script not being included or used in
packages bootstrapped with Autoconf 2.69.
With later versions of Autoconf things work because this module
doesn't touch things and thus disables itself.
I don't care about building with C11 one way or the other. Let's
just skip the module.
Nick Bowler [Wed, 16 Nov 2022 05:16:29 +0000 (00:16 -0500)]
x11: Improve redraw of empty spaces.
When the game area is showing only the middle portion with the empty
border, we can clear this with 4 or fewer draw calls instead of 16.
Let's handle this as a special case in the tile drawing code.
Moreover, we don't need to draw anything in these spaces on expose
events, as the exposed areas are already filled with the background.
Nick Bowler [Wed, 16 Nov 2022 03:25:18 +0000 (22:25 -0500)]
Fix build on older Motif without XmPIXMAP_AND_STRING.
It seems that not all versions of Motif support labels with a labelType
of XmPIXMAP_AND_STRING. This mode is used in the about dialog to
display the program's icon, but it's silly to fail compilation over
this.
Add a configure test to check if this feature is available, and fall
back to XmSTRING (which will render without the icon).
Nick Bowler [Wed, 16 Nov 2022 03:09:48 +0000 (22:09 -0500)]
Fix curses build on HP-UX.
On HP-UX, it seems that "lines" and "label_width" are defined as
object-like macros in <term.h> which causes dumb build failures
since this code is using those identifiers as variables.
Not too much hassle to just use a different name instead.
Nick Bowler [Sat, 18 Jun 2022 01:39:50 +0000 (21:39 -0400)]
Combine motifgui.dat / motifstr.str into one file.
Pull in updated gen-tree.awk with support for comments, and use a
special comment syntax to allow simple strtab definitions in a single
file. This allows keeping the menu label definitions together with the
menu tree, and reduces the number of generated headers to worry about.
Nick Bowler [Sun, 12 Jun 2022 15:51:27 +0000 (11:51 -0400)]
curses: Begin to implement a game menu system.
Add the skeleton for very simple control interface based on function
keys. Show labels along the bottom row for up to 10 functions, with
each corresponding to the first 10 function keys (or esc+number).
For now, hardcode two functions: new game and exit. More to come.
Nick Bowler [Wed, 8 Jun 2022 03:55:32 +0000 (23:55 -0400)]
Don't use leaveok() in curses.
Hiding the cursor seems unreliable, so when curs_set doesn't actually
work I think it's better to keep the cursor in some innocuous location
rather than having it randomly move around in the game area.
Nick Bowler [Wed, 8 Jun 2022 03:51:59 +0000 (23:51 -0400)]
Ensure manpages are distributed.
It seems using dist_man_MANS in an Automake conditional doesn't actually
ensure the manpage is distributed, so we need to just use man_MANS in
the conditional and EXTRA_DIST unconditionally.
Nick Bowler [Wed, 8 Jun 2022 03:44:01 +0000 (23:44 -0400)]
Add basic keyboard control to curses UI.
Since the mouse support in curses is not always available, we need to
provide a keyboard-based alternative. The arrow keys move a cursor
around the positions in the game area, and space moves the selected
tile.
Nick Bowler [Tue, 7 Jun 2022 00:01:41 +0000 (20:01 -0400)]
Fix reconfiguration when using --without-x.
We need to consider the user's selection when checking whether or not
to build the Motif UI, because the cached result may have come from a
prior configure run.
Nick Bowler [Sun, 5 Jun 2022 20:42:45 +0000 (16:42 -0400)]
Add initial curses-based UI.
To start getting an idea of what it takes to implement a game like this
with many different frontends, let's start by implementing a text-mode
user interface based on curses.
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.