Adjust window-port related option processing

to allow common parsing in the core, and direct access to the
results by the window port.

Notes:

o Adds a new field, wincap, to the window_procs
structure for setting bits related to the preference
features that the window port supports.  This allows
run-time determination of whether a particular option
setting is applicable to the running window port.  A
window-port is free to support as many, or as few,
of the available options as it wants.  Ensure that
only the ones supported have their corresponding bit
set in window_proc.wincap. [see chart in
doc/window.doc for help with that.]

o The settings I stuck into wincap for each window
port are almost certainly not accurate, so each port
team should review them.  You should only include
the ones that you will actually react to and make
adjustments for if the user changes that option.
Without the setting in wincap, the option won't even
show up in the 'O'ptions menu.

o preference_update() added to the window-port
interface, so that the window-port can be notified
if an option of interest (an option with its
corresponding bit set in wincap field) is
changed.

o provided a genl_preference_update() routine in
windows.c and used it for all the existing
window ports since they don't have a functional
one of their own yet.

o this messes around heavily with iflags and the options
arrays in options.c

o I hope I didn't break any port's existing code. I
tried not to.  The Mac however, in particular, should
be looked at because it suffered a namespace collision
with what I was working on around fontname.  It had
Mac specific font stuff in options.c. Please test
the Mac.
This commit is contained in:
nethack.allison
2002-02-03 05:31:47 +00:00
parent 830fc78d36
commit cb6a93641b
17 changed files with 992 additions and 362 deletions

View File

@@ -1635,9 +1635,6 @@ Check free disk space before writing files to disk (default on).
You may have to turn this off if you have more than 2 GB free space
on the partition used for your save and level files.
Only applies when MFLOPPY was defined during compilation.
.lp "color "
Use color for different monsters, objects, and dungeon features
(default on for microcomputers).
.lp "confirm "
Have user confirm attacks on pets, shopkeepers, and other
peaceable creatures (default on).
@@ -1748,11 +1745,6 @@ Note that in the next release, new symbols may be added,
or the present ones rearranged.
Cannot be set with the `O' command.
.lp eight_bit_tty
Pass eight-bit character values (for example, specified with the
.op traps
option) straight through to your terminal (default off). Only applies
to the tty port.
.lp extmenu
Changes the extended commands interface to pop-up a menu of available commands.
It is keystroke compatible with the traditional interface except that it does
@@ -1783,11 +1775,6 @@ with the `/' command, ask if you want to see it (default on). Turning help
off makes just looking at things faster, since you aren't interrupted with the
``More info?'' prompt, but it also means that you might miss some
interesting and/or important information.
.lp hilite_pet
Visually distinguish pets from similar animals (default off).
The behavior of this option depends on the type of windowing you use.
In text windowing, text highlighting or inverse video is often used;
with tiles, generally displays a heart symbol near pets.
.lp horsename
Name your starting horse (ex. ``horsename:Trigger'').
Cannot be set with the `O' command.
@@ -1954,11 +1941,6 @@ Specify the object types to be picked up when
is on. Default is all types.
.lp prayconfirm
Prompt for confirmation before praying (default on).
.lp preload_tiles
For the protected mode MSDOS version, control whether tiles
get pre-loaded into RAM at the start of the game. Doing so
enhances performance of the tile graphics, but uses more memory. (default on).
Cannot be set with the `O' command.
.lp pushweapon
Using the `w' (wield) command when already wielding
something pushes the old item into your secondary weapon slot (default off).
@@ -2054,6 +2036,88 @@ Select which windowing system to use, such as ``tty'' or ``X11''
(default depends on version).
Cannot be set with the `O' command.
.hn 2
Window Port Customization options
.pg
Here are explanations of the various options that are
used to customize and change the characteristics of the
windowtype that you have chosen.
Character strings that are too long may be truncated.
Not all window ports will adjust for all settings listed
here. You can safely add any of these options to your config
file, and if the window port is capable of adjusting to
suit your preferences, it will attempt to do so. If it
can't it will silently ignore it. You can find out if an
option is supported by the window port that you are currently
using by checking to see if it shows up in the Options list.
Some options are dynamic and can be specified during the game
with the `O' command.
.lp align_message
Where to align or place the message window (top, bottom, left, or right)
.lp align_status
Where to align or place the status window (top, bottom, left, or right).
.lp ascii_map
NetHack should display an ascii character map if it can.
.lp color
NetHack should display color if it can for different monsters,
objects, and dungeon features
.lp eight_bit_tty
NetHack should pass eight-bit character values (for example, specified with the
.op traps
option) straight through to your terminal (default off).
.lp font_map
NetHack should use a font by the chosen name for the map window.
.lp font_menu
NetHack should use a font by the chosen name for menu windows.
.lp font_message
NetHack should use a font by the chosen name for the message window.
.lp font_status
NetHack should use a font by the chosen name for the status window.
.lp font_text
NetHack should use a font by the chosen name for text windows.
.lp font_size_map
NetHack should use this size font for the map window.
.lp font_size_menu
NetHack should use this size font for menu windows.
.lp font_size_message
NetHack should use this size font for the message window.
.lp font_size_status
NetHack should use this size font for the status window.
.lp font_size_text
NetHack should use this size font for text windows.
.lp hilite_pet
Visually distinguish pets from similar animals (default off).
The behavior of this option depends on the type of windowing you use.
In text windowing, text highlighting or inverse video is often used;
with tiles, generally displays a heart symbol near pets.
.lp large_font
NetHack should use a large font.
.lp map_mode
NetHack should display the map in the manner specified.
.lp popup_dialog
NetHack should pop up dialog boxes for input.
.lp preload_tiles
NetHack should preload tiles into memory.
For example, in the protected mode MSDOS version, control whether tiles
get pre-loaded into RAM at the start of the game. Doing so
enhances performance of the tile graphics, but uses more memory. (default on).
Cannot be set with the `O' command.
.lp scroll_margin
NetHack should scroll the display when the hero or cursor
is this number of cells away from the edge of the window.
.lp tiled_map
NetHack should display a tiled map if it can.
.lp tiles_16x16
NetHack should display 16x16 tiles if it can.
.lp tiles_32x32
NetHack should display 32x32 tiles if it can.
.lp tiles_8x16
NetHack should display 8x16 tiles if it can.
.lp use_inverse
NetHack should display inverse when the game specifies it.
.lp vary_msgcount
NetHack should display this number of messages at a time in
the message window.
.hn 2
Configuring NetHack for Play by the Blind
.pg
NetHack can be set up to use only standard ASCII characters for making

View File

@@ -2053,10 +2053,6 @@ You may have to turn this off if you have more than 2 GB free space
on the partition used for your save and level files.
Only applies when MFLOPPY was defined during compilation.
%.lp
\item[\ib{color}]
Use color for different monsters, objects, and dungeon features
(default on for microcomputers).
%.lp
\item[\ib{confirm}]
Have user confirm attacks on pets, shopkeepers, and other
peaceable creatures (default on).
@@ -2167,11 +2163,6 @@ or the present ones rearranged.
Cannot be set with the `{\tt O}' command.
%.lp
\item[\ib{eight\_bit\_tty}]
Pass eight-bit character values (for example, specified with the {\it
traps \/} option) straight through to your terminal (default off).
Only applies to the tty port.
%.lp
\item[\ib{extmenu}]
Changes the extended commands interface to pop-up a menu of available commands.
It is keystroke compatible with the traditional interface except that it does
@@ -2208,12 +2199,6 @@ Turning help off makes just looking at things faster, since you aren't
interrupted with the ``{\tt More info?}'' prompt, but it also means that you
might miss some interesting and/or important information.
%.lp
\item[\ib{hilite\_pet}]
Visually distinguish pets from similar animals (default off).
The behavior of this option depends on the type of windowing you use.
In text windowing, text highlighting or inverse video is often used;
with tiles, generally displays a heart symbol near pets.
%.lp
\item[\ib{horsename}]
Name your starting horse (ex.\ ``{\tt horsename:Trigger}'').
Cannot be set with the `{\tt O}' command.
@@ -2397,12 +2382,6 @@ is on. Default is all types.
\item[\ib{prayconfirm}]
Prompt for confirmation before praying (default on).
%.lp
\item[\ib{preload\_tiles}]
For the protected mode MSDOS version, control whether tiles
get pre-loaded into RAM at the start of the game. Doing so
enhances performance of the tile graphics, but uses more memory. (default on).
Cannot be set with the `{\tt O}' command.
%.lp
\item[\ib{pushweapon}]
Using the `w' (wield) command when already wielding
something pushes the old item into your secondary weapon slot (default off).
@@ -2519,6 +2498,118 @@ Select which windowing system to use, such as ``{\tt tty}'' or ``{\tt X11}''
Cannot be set with the `{\tt O}' command.
\elist
%.hn 2
\subsection*{Window Port Customization options}
%.pg
Here are explanations of the various options that are
used to customize and change the characteristics of the
windowtype that you have chosen.
Character strings that are too long may be truncated.
Not all window ports will adjust for all settings listed
here. You can safely add any of these options to your
config file, and if the window port is capable of adjusting
to suit your preferences, it will attempt to do so. If it
can't it will silently ignore it. You can find out if an
option is supported by the window port that you are currently
using by checking to see if it shows up in the Options list.
Some options are dynamic and can be specified during the game
with the `{\tt O}' command.
\blist{}
%.lp
\item[\ib{align\_message}]
Where to align or place the message window (top, bottom, left, or right)
%.lp
\item[\ib{align\_status}]
Where to align or place the status window (top, bottom, left, or right).
%.lp
\item[\ib{ascii\_map}]
NetHack should display an ascii map if it can.
%.lp
\item[\ib{color}]
NetHack should display color if it can for different monsters,
objects, and dungeon features
%.lp
\item[\ib{eight\_bit\_tty}]
Pass eight-bit character values (for example, specified with the {\it
traps \/} option) straight through to your terminal (default off).
%.lp
\item[\ib{font\_map}]
NetHack should use a font by the chosen name for the map window.
%.lp
\item[\ib{font\_menu}]
NetHack should use a font by the chosen name for menu windows.
%.lp
\item[\ib{font\_message}]
NetHack should use a font by the chosen name for the message window.
%.lp
\item[\ib{font\_status}]
NetHack should use a font by the chosen name for the status window.
%.lp
\item[\ib{font\_text}]
NetHack should use a font by the chosen name for text windows.
%.lp
\item[\ib{font\_size\_map}]
NetHack should use this size font for the map window.
%.lp
\item[\ib{font\_size\_menu}]
NetHack should use this size font for menu windows.
%.lp
\item[\ib{font\_size\_message}]
NetHack should use this size font for the message window.
%.lp
\item[\ib{font\_size\_status}]
NetHack should use this size font for the status window.
%.lp
\item[\ib{font\_size\_text}]
NetHack should use this size font for text windows.
%.lp
\item[\ib{hilite\_pet}]
Visually distinguish pets from similar animals (default off).
The behavior of this option depends on the type of windowing you use.
In text windowing, text highlighting or inverse video is often used;
with tiles, generally displays a heart symbol near pets.
%.lp
\item[\ib{large\_font}]
NetHack should use a large font.
%.lp
\item[\ib{map\_mode}]
NetHack should display the map in the manner specified.
%.lp
\item[\ib{popup\_dialog}]
NetHack should pop up dialog boxes for input.
%.lp
\item[\ib{preload\_tiles}]
NetHack should preload tiles into memory.
For example, in the protected mode MSDOS version, control whether tiles
get pre-loaded into RAM at the start of the game. Doing so
enhances performance of the tile graphics, but uses more memory. (default on).
Cannot be set with the `{\tt O}' command.
%.lp
\item[\ib{scroll\_margin}]
NetHack should scroll the display when the hero or cursor
is this number of cells away from the edge of the window.
%.lp
\item[\ib{tiled\_map}]
NetHack should display a tiled map if it can.
%.lp
\item[\ib{tiles\_16x16}]
NetHack should display 16x16 tiles if it can.
%.lp
\item[\ib{tiles\_32x32}]
NetHack should display 32x32 tiles if it can.
%.lp
\item[\ib{tiles\_8x16}]
NetHack should display 8x16 tiles if it can.
%.lp
\item[\ib{use\_inverse}]
NetHack should display inverse when the game specifies it.
%.lp
\item[\ib{vary\_msgcount}]
NetHack should display this number of messages at a time in the message window.
\elist
%.hn 2
\subsection*{Configuring NetHack for Play by the Blind}

View File

@@ -5,17 +5,18 @@ NetHack. The support is through a standard interface, separating the
main NetHack code from window-system specific code. The implementation
supports multiple window systems in the same binary. Even if you only
wish to support one window-port on your port, you will need to follow
the instructions in Section VIII to get a compilable binary.
the instructions in Section IX to get a compilable binary.
Contents:
I. Window Types and Terminology
II. Interface Specification
III. Global variables
IV. New or respecified common, high level routines
V. Helper routines
VI. Game startup
VII. Conventions
VIII. Implementation and Multi-window support
IV. WINCAP preferences support
V. New or respecified common, high level routines
VI. Helper routines
VII. Game startup
VIII. Conventions
IX. Implementation and Multi-window support
I. Window Types and Terminology
@@ -351,6 +352,15 @@ outrip(winid, int)
-- The tombstone code. If you want the traditional code use
genl_outrip for the value and check the #if in rip.c.
preference_update(preference)
-- The player has just changed one of the wincap preference
settings, and the NetHack core is notifying your window
port of that change. If your window-port is capable of
dynamically adjusting to the change then it should do so.
Your window-port will only be notified of a particular
change if it indicated that it wants to be by setting the
corresponding bit in the wincap mask.
III. Global variables
The following global variables are defined in decl.c and must be used by
@@ -370,7 +380,101 @@ window-port should also declare this variable in one of your sys/*.c files.
short ospeed; Set and declared in sys/unix/unixtty.c (don't
know about other sys files).
IV. New or respecified common, high level routines
IV. WINCAP preferences support
Starting with NetHack 3.3.2, the window interface was enhanced to provide
a common way of setting window port user preferences from the config file,
and from the command line for some settings.
The wincap preference settings all have their underlying values stored
in iflags fields. The names of the wincap related fields are all pre-
fixed with wc_ to make it easy to identify them. Your window port can
access the fields directly.
Your window port identifies what options it will react to and support
by setting bits in the window_procs wincap mask. See section IX for
details of where the wincap mask resides. Any preference settings
marked as being supported by having its bit set in the wincap mask
will be available for the user of your window port to set via the 'O'
command, while those not marked as supported will not appear in the
menus of the 'O' command.
Setting of any wincap option is handled by the NetHack core option
code, you do not have to provide a parser in your window port.
Here are the wincap preference settings that your port can choose
to support:
+-------------------+--------------------+-------------------+--------+
| | | iflags field | data |
| player option | bit in wincap mask | for value | type |
|-------------------+--------------------+-------------------+--------+
| align_message | WC_ALIGN_MESSAGE | wc_align_message |int |
| align_status | WC_ALIGN_STATUS | wc_align_status |int |
| ascii_map | WC_ASCII_MAP | wc_ascii_map |boolean |
| color | WC_COLOR | wc_color |boolean |
| eight_bit_tty | WC_EIGHT_BIT_IN | wc_eight_bit_input|boolean |
| font_map | WC_FONT_MAP | wc_font_map |char * |
| font_menu | WC_FONT_MENU | wc_font_menu |char * |
| font_message | WC_FONT_MESSAGE | wc_font_message |char * |
| font_size_map | WC_FONTSIZ_MAP | wc_fontsiz_map |int |
| font_size_menu | WC_FONTSIZ_MENU | wc_fontsiz_menu |int |
| font_size_message| WC_FONTSIZ_MESSAGE | wc_fontsiz_message|int |
| font_size_status | WC_FONTSIZ_STATUS | wc_fontsiz_status |int |
| font_size_text | WC_FONTSIZ_TEXT | wc_fontsiz_text |int |
| font_status | WC_FONT_STATUS | wc_font_status |char * |
| font_text | WC_FONT_TEXT | wc_font_text |char * |
| hilite_pet | WC_HILITE_PET | wc_hilite_pet |boolean |
| large_font | WC_LARGE_FONT | wc_large_font |boolean |
| map_mode | WC_MAP_MODE | wc_map_mode |int |
| popup_dialog | WC_POPUP_DIALOG | wc_popup_dialog |boolean |
| preload_tiles | WC_PRELOAD_TILES | wc_preload_tiles |boolean |
| scroll_margin | WC_SCROLL_MARGIN | wc_scroll_margin |int |
| tiled_map | WC_TILED_MAP | wc_tiled_map |boolean |
| tiles_16x16 | WC_TILES_16x16 | wc_tiles_16x16 |boolean |
| tiles_32x32 | WC_TILES_32x32 | wc_tiles_32x32 |boolean |
| tiles_8x16 | WC_TILES_8x16 | wc_tiles_8x16 |boolean |
| use_inverse | WC_INVERSE | wc_inverse |boolean |
| vary_msgcount | WC_VARY_MSGCOUNT | wc_vary_msgcount |int |
+-------------------+--------------------+-------------------+--------+
align_message -- where to place message window (top, bottom, left, right)
align_status -- where to place status window (top, bottom, left, right).
ascii_map -- port should display an ascii map if it can.
color -- port should display color if it can.
eight_bit_tty -- port should allow eight bit input.
font_map -- port should use a font by this name for map window.
font_menu -- port should use a font by this name for menu windows.
font_message -- port should use a font by this name for message window.
font_size_map -- port should use this size font for the map window.
font_size_menu -- port should use this size font for menu windows.
font_size_message
-- port should use this size font for the message window.
font_size_status-- port should use this size font for the status window.
font_size_text -- port should use this size font for text windows.
font_status -- port should use a font by this name for status window.
font_text -- port should use a font by this name for text windows.
hilite_pet -- port should mark pets in some special way on the map.
large_font -- port should use a large font.
map_mode -- port should display the map in the manner specified.
popup_dialog -- port should pop up dialog boxes for input.
preload_tiles -- port should preload tiles into memory.
scroll_margin -- port should scroll the display when the hero or cursor
is this number of cells away from the edge of the window.
tiled_map -- port should display a tiled map if it can.
tiles_16x16 -- port should display 16x16 tiles if it can.
tiles_32x32 -- port should display 32x32 tiles if it can.
tiles_8x16 -- port should display 8x16 tiles if it can.
use_inverse -- port should display inverse when NetHack asks for it.
vary_msgcount -- port should display this number of messages at a time in
the message window.
Whenever one of these settings is adjusted (and if supported by the port
by marking it so in the wincap mask), the port is notified of a change
to a setting by calling the port's preference_update() routine. The port
can choose to adjust for the change or ignore it.
V. New or respecified common, high level routines
These are not part of the interface, but mentioned here for your information.
@@ -392,7 +496,7 @@ pline(str, ...)
by Norep() and pline(). If the window system is not active
(!iflags.window_inited) pline() uses raw_print().
V. Helper Routines
VI. Helper Routines
These are not part of the interface. They may be called by your
window port routines to perform the desired task, instead of duplicating
@@ -405,7 +509,7 @@ mapglyph(int glyph, int *ochar, int *ocolor, unsigned *special, int x, int y)
Usually called from the window port's print_glyph()
routine.
VI. Game startup
VII. Game startup
The following is the general order in which calls from main() should be made,
as they relate to the window system. The actual code may differ, but the
@@ -438,7 +542,7 @@ Process_options() is currently still unique to each port. There may be need
in the future to make it possible to replace this on a per window-port basis.
VII. Conventions
VIII. Conventions
init_nhwindows() is expected to display a gee-whiz banner window, including
the Copyright message. It is recommended that the COPYRIGHT_BANNER_A,
@@ -463,7 +567,7 @@ in win/X11. The files in these directories contain _only_ window port code,
and may be replaced completely by other window ports.
VIII. Implementation and Multi-window support
IX. Implementation and Multi-window support
NetHack 3.2 and higher support multiple window systems in the same binary.
When writing a new window-port, you need to follow the following guidelines:
@@ -494,7 +598,9 @@ When writing a new window-port, you need to follow the following guidelines:
3) Declare a structure, "struct window_procs prefix_procs", (with your
prefix instead of "prefix") and fill in names of all of your
interface functions. The first entry in this structure is the name
of your window-port, which should be the prefix. The other entries
of your window-port, which should be the prefix. The second entry
is the wincap mask that identifies what window port preference
settings your port will react to and support. The other entries
are the function addresses.
Assuming that you followed the convention in (2), you can safely copy
@@ -541,7 +647,7 @@ When writing a new window-port, you need to follow the following guidelines:
9) Look at your port's portmain.c (the file containing main()) and make
sure that all of the calls match the the requirements laid out in
Section VI.
Section VII.
Now, proceed with compilation and installation as usual. Don't forget
to edit Makefile.src (or its equivalent) and config.h to set the