Due to the new player selection dialog I did, it was possible
to rename your character - but this didn't rename the lock files
and tried to load a save from the wrong name.
This is a bit of a hack, but seems to work and didn't seem to
cause problems for the tty.
A wishlist/TODO item: when "female" is highlighted, change "caveman"
to "cavewoman" and "priest" to "priestess". If it gets toggled to
"male", change them back.
This eliminates nearly 40 warnings, most by suppressing complaints of
used function arguments but a few for unused local variables. There's
also some reformatting thrown in....
There are still 18 warnings about uses of XtSetArg(), about assigning
const to non-const.
The dialog shows the player's name, race, role, gender, and
alignment in a single window, similar to the Qt4 dialog.
Also allows randomizing the character selection.
Use the dialog by setting OPTIONS=player_selection:dialog
The X11 interface reads file NetHack.ad (after cd'ing to the playground
directory, where 'make install' puts a copy) and feeds the contents to
X Windows for use as default resources to override the compiled in
defaults. When use of #define was introduced into NetHack.ad (back in
September, 2016) this was severely hobbled and startup spit out a lot
complaints to stderr about invalid resource values. This implements
rudimentary macro expansion for '#define name value' within the data
stream that's fed to X, getting back decent default values and
eliminating the invalid value complaints.
Add MG_BW_LAVA to mapglyph() instead of hijacking MG_DETECT. Used
to display lava in inverse video if color is disabled and lava is
using the same display character as water (which is the default).
(The use_inverse option must be enabled for tty to honor it. X11's
text mode doesn't care. Win32 does care but probably shouldn't--it's
not a case like tty where the hardware might not support it.)
This implements both MG_DETECT and MG_BW_LAVA for X11, but only if
the program is built with TEXTCOLOR enabled. Those should work even
when color is not supported, but I suspect that configuration is
unlikely to ever be used so didn't want to spend the time to figure
out how to do it. (The relevant data is overloaded on the color
data, so not available when TEXTCOLOR is disabled.)
The win32 revision is untested.
Umpteenth revision of the X11 extended command menu. Add a new
resource to NetHack.ad to control its initial size.
I still hope there's a better way to do this, but this is my last
shot at it.
When the extended command menu auto-scrolls as the player types in
characters, scroll so that all matching entries come into view rather
than just the first one. For example, it someone types 'w', instead
of just highlighting and showing "wipe", it will highlight "wipe"
(because that has become the default response when <return> is used)
but also show "wiz-this", "wiz-that", and "wmode". It actually shows
one extra entry beyond the last matching one--so you can see that
there aren't any more ambiguous choices--except for 'w' where "wmode"
is the very last extended command.
Previously, on subsequent popups of the extended command menu, the
scrollbar's slider was left drawn in the position it was in during
the previous time even though menu content wasn't scrolled. Now it's
forced back to the top (non-scrolled) position when that menu is
popped up.
When the extended command menu is big enough to need a scrollbar,
leave more elbow room when forcing its height to fit on screen.
The last entry was frequently obscured by OSX's "docking tray"
desktop decoration and the resize hotspot (bottom right corner of
the menu popup) could be hard to access.
I'm not particularly happy with this code. There really has to be
a better way to accomplish what's needed.
Color was only being tracked for locations that had the pile of
objects flag set. And hilite_pile made a monster on a pile take
on the color of the top object of the pile.
This restores the tracking of color for the whole map, and makes
highlighted piles be drawn in inverse like highligted pets. The
drawing routine doesn't know the difference (but could tell, if
necessary, by testing whether the glyph is an object or a monster).
Also, variables 'inbuf', 'inptr', and 'incount' were global; limit
their scope to winmap.c.
The three line change I made previously to implement highlighting for
prompts that ask for single-character input was easy and worked well
for a tiles map, but it didn't look very good for a text map. This
handles both text map and tile map and also adds a configurable
'highlight_prompt' X resource to let the user enable or disable the
feature. The resource template file (win/X11/NetHack.ad, copied to
$HACKDIR during install) now has it enabled by default.
The highlighting--more specifically, the "lowlighting" when no prompt
is active--still looks bad if the map window has a vertical scrollbar
on left edge. I don't have any inspiration about how to fix that up.
If the user hasn't explicitly loaded application defaults (which I
haven't been doing), the X11 interface behaves differently if invoked
via the shell script than if the executable is run directly, because
the script sets up a path so that X can find $HACKDIR/NetHack.ad.
This hides the difference by reading in that file during initialization
and feeding its contents to XtAppInitialize as fallback resources.
The scroll bar on the message window doesn't work for me, just like
the one on the extend commands menu. Moving the pointer to it does
change the cursor, but neither trying to drag the slider nor clicking
above it will make it do anything. However, at some point I managed
to accidentally scroll the message window, and new messages never
restored it to the unscrolled state. New messages were hidden until
enough even newer ones had been delivered to push the hidden ones
into view. So this adds key translations to scroll the message
window via the arrow keys. Clicking on the scroll bar doesn't change
focus to the right place, so I have to click the text display area of
the message window. That triggers a beep (I suspect it's interpreted
as an attempt to move the hero beyond the map.) But then the messages
can be scrolled via the cursor keys. Getting focus back to the map
seems tricky since doing it via pointer is interpreted as a travel
command. Not quite optimal....
Anyway, being able to scroll the message window let me figure out how
to unscroll it when new messages are delivered.
For the 'slow' config (prompting for single-char input done on a
fixed line at the top of the map rather than via a popup window),
invert the background and foreground when creating it so that it
looks like part of the map, then invert again when a prompt is
active in order to highlight that prompt.
Free askname's widgets after use and free getlin's and yn_function's
persistent widgets at end of game.
When loading an entire text file into one long string in memory,
use strcpy on a pointer to the end of the string instead of having
strcat repeatedly churn through the entire string as it grows for
each line. [Since that's only used for small help files (biggest
is dat/history), this optimization is probably not noticeable.]
Also, a handful of new comments and quite a bit of reformatting.
I upgraded from OSX 10.5.8 via 10.6.3 to 10.6.8, plus Xcode to whatever
version was on the 10.6 dvd, and ended up with a more recent version of
gcc that is configured to use 64 bit longs and 64 bit pointers (by
default; presumably that can be changed if necessary). It triggered
several warnings about converting int to pointer of different size or
vice versa even when explicit casts were in use, and a couple of other
things.
The big memory allocation for tiles that was unfreed according to
heaputil was actually freed by X according to a comment in the code.
But free it explicitly for #if MONITOR_HEAP so that the alloc/free
tracking stays accurate.
Also, the cached extended commands menu was not being freed, so take
care of that. I wasn't sure where to handle it; I ended up making it
happen when the map window is torn down.
X11 had been ignoring add_menu(..., MENU_SELECTED) to specify a
pre-selected menu entry. This adds support for that.
Attempt to implement pre-selected entry for PICK_ONE menu sanely by
returning the pre-selected entry instead of toggling it off if the
user chooses it explicitly. Inner workings of menus are convoluted
so I'm not sure it's 100% correct, although testing hasn't found any
problems. (tty currently returns 0 for "nothing picked" when
explicitly picking a pre-selected entry in a PICK_ONE menu, and the
core jumps through hoops to handle it. That can't be cleaned up until
all interfaces which support pre-selected entries achieve sanity.)
Make "random" be chosen for <return> or <enter> during role selection
and highlight it to reflect that. (Role selection for X11 uses its
own code instead of nethack menus, so pre-selection isn't applicable.)
Without this, the keyboard commands don't work in the extended
command window on Linux. If the translations are removed from
menuformview, then the keyboard commands don't work on Mac.
Having the translations in both doesn't seem to hurt.
Make the six buttons (ok, cancel, all, none, invert, search) on
menus for X11 all have the same width.
'ok' should probably be changed to 'okay' to be consistent with
X11_getlin(). (Another inconsistency: the extended commands
menu uses 'dismiss' rather than 'cancel'.)
Two cosmetic changes for the X11 version of the getlin() routine:
1) Make the text entry box big enough to hold 60 characters before
sliding the beginning input off the left edge, instead of just 13,
so that user can see much more of what is being typed;
2) Make the cancel button be a little wider, and the okay button be
the same width as the cancel button so they look a little nicer.
When entering an extended command, allow the user just type
and match a new command immediately, if no match was found,
instead of needing to wait the 2.5 seconds.