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

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)options.c 3.3 2000/08/01 */
/* SCCS Id: @(#)options.c 3.3 2002/02/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -24,175 +24,170 @@ NEARDATA struct instance_flags iflags; /* provide linkage */
* and also the Guidebooks.
*/
static struct Bool_Opt
{
const char *name;
boolean *addr, initvalue;
} boolopt[] = {
#ifdef AMIGA
{"altmeta", &flags.altmeta, TRUE},
#else
{"altmeta", (boolean *)0, TRUE},
#endif
#ifdef MFLOPPY
{"asksavedisk", &flags.asksavedisk, FALSE},
#else
{"asksavedisk", (boolean *)0, FALSE},
#endif
{"autodig", &flags.autodig, FALSE},
{"autopickup", &flags.pickup, TRUE},
{"autoquiver", &flags.autoquiver, FALSE},
#if defined(MICRO) && !defined(AMIGA)
{"BIOS", &iflags.BIOS, FALSE},
#else
{"BIOS", (boolean *)0, FALSE},
#endif
#ifdef INSURANCE
{"checkpoint", &flags.ins_chkpt, TRUE},
#else
{"checkpoint", (boolean *)0, FALSE},
#endif
#ifdef MFLOPPY
{"checkspace", &iflags.checkspace, TRUE},
#else
{"checkspace", (boolean *)0, FALSE},
#endif
#ifdef TEXTCOLOR
# ifdef MICRO
{"color", &iflags.use_color, TRUE},
# else /* systems that support multiple terminals, many monochrome */
{"color", &iflags.use_color, FALSE},
# endif
#else
{"color", (boolean *)0, FALSE},
#endif
{"confirm",&flags.confirm, TRUE},
#ifdef TERMLIB
{"DECgraphics", &iflags.DECgraphics, FALSE},
#else
{"DECgraphics", (boolean *)0, FALSE},
#endif
#ifdef TTY_GRAPHICS
{"eight_bit_tty", &iflags.eight_bit_tty, FALSE},
{"extmenu", &iflags.extmenu, FALSE},
#else
{"eight_bit_tty", (boolean *)0, FALSE},
{"extmenu", (boolean *)0, FALSE},
#endif
#ifdef OPT_DISPMAP
{"fast_map", &flags.fast_map, TRUE},
#else
{"fast_map", (boolean *)0, TRUE},
#endif
{"female", &flags.female, FALSE},
{"fixinv", &flags.invlet_constant, TRUE},
#ifdef AMIFLUSH
{"flush", &flags.amiflush, FALSE},
#else
{"flush", (boolean *)0, FALSE},
#endif
{"help", &flags.help, TRUE},
{"hilite_pet", &iflags.hilite_pet, FALSE},
#ifdef ASCIIGRAPH
{"IBMgraphics", &iflags.IBMgraphics, FALSE},
#else
{"IBMgraphics", (boolean *)0, FALSE},
#endif
{"ignintr", &flags.ignintr, FALSE},
#ifdef MAC_GRAPHICS_ENV
{"large_font", &iflags.large_font, FALSE},
#else
{"large_font", (boolean *)0, FALSE},
#endif
{"legacy", &flags.legacy, TRUE},
{"lit_corridor", &flags.lit_corridor, FALSE},
#ifdef MAC_GRAPHICS_ENV
{"Macgraphics", &iflags.MACgraphics, TRUE},
#else
{"Macgraphics", (boolean *)0, FALSE},
#endif
#ifdef MAIL
{"mail", &flags.biff, TRUE},
#else
{"mail", (boolean *)0, TRUE},
#endif
#ifdef TTY_GRAPHICS
{"msg_window", &iflags.prevmsg_window, FALSE},
#else
{"msg_window", (boolean *)0, FALSE},
#endif
#ifdef NEWS
{"news", &iflags.news, TRUE},
#else
{"news", (boolean *)0, FALSE},
#endif
{"null", &flags.null, TRUE},
{"number_pad", &iflags.num_pad, FALSE},
#ifdef MAC
{"page_wait", &flags.page_wait, TRUE},
#else
{"page_wait", (boolean *)0, FALSE},
#endif
{"perm_invent", &flags.perm_invent, FALSE},
#ifdef MAC
{"popup_dialog", &iflags.popup_dialog, FALSE},
#else
{"popup_dialog", (boolean *)0, FALSE},
#endif
{"prayconfirm", &flags.prayconfirm, TRUE},
#if defined(MSDOS) && defined(USE_TILES)
{"preload_tiles", &iflags.preload_tiles, TRUE},
#else
{"preload_tiles", (boolean *)0, FALSE},
#endif
{"pushweapon", &flags.pushweapon, FALSE},
#if defined(MICRO) && !defined(AMIGA)
{"rawio", &iflags.rawio, FALSE},
#else
{"rawio", (boolean *)0, FALSE},
#endif
{"rest_on_space", &flags.rest_on_space, FALSE},
{"safe_pet", &flags.safe_dog, TRUE},
#ifdef WIZARD
{"sanity_check", &iflags.sanity_check, FALSE},
#else
{"sanity_check", (boolean *)0, FALSE},
#endif
#ifdef EXP_ON_BOTL
{"showexp", &flags.showexp, FALSE},
#else
{"showexp", (boolean *)0, FALSE},
#endif
#ifdef SCORE_ON_BOTL
{"showscore", &flags.showscore, FALSE},
#else
{"showscore", (boolean *)0, FALSE},
#endif
{"silent", &flags.silent, TRUE},
{"sortpack", &flags.sortpack, TRUE},
{"sound", &flags.soundok, TRUE},
{"sparkle", &flags.sparkle, TRUE},
{"standout", &flags.standout, FALSE},
{"time", &flags.time, FALSE},
#ifdef TIMED_DELAY
{"timed_delay", &flags.nap, TRUE},
#else
{"timed_delay", (boolean *)0, FALSE},
#endif
{"tombstone",&flags.tombstone, TRUE},
{"toptenwin",&flags.toptenwin, FALSE},
{"use_inverse", &iflags.use_inverse, FALSE},
{"verbose", &flags.verbose, TRUE},
{(char *)0, (boolean *)0, FALSE}
};
/* compound options, for option_help() and external programs like Amiga
* frontend */
/*
* Option flags
* Each higher number includes the characteristics of the numbers
* below it.
*/
#define SET_IN_FILE 0 /* config file option only, not visible in game
* or via program */
#define SET_VIA_PROG 1 /* may be set via extern program, not seen in game */
#define DISP_IN_GAME 2 /* may be set via extern program, displayed in game */
#define SET_IN_GAME 3 /* may be set via extern program or set in the game */
static struct Bool_Opt
{
const char *name;
boolean *addr, initvalue;
int optflags;
} boolopt[] = {
#ifdef AMIGA
{"altmeta", &flags.altmeta, TRUE, DISP_IN_GAME},
#else
{"altmeta", (boolean *)0, TRUE, DISP_IN_GAME},
#endif
{"ascii_map", &iflags.wc_ascii_map, TRUE, SET_IN_GAME}, /*WC*/
#ifdef MFLOPPY
{"asksavedisk", &flags.asksavedisk, FALSE, SET_IN_GAME},
#else
{"asksavedisk", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"autodig", &flags.autodig, FALSE, SET_IN_GAME},
{"autopickup", &flags.pickup, TRUE, SET_IN_GAME},
{"autoquiver", &flags.autoquiver, FALSE, SET_IN_GAME},
#if defined(MICRO) && !defined(AMIGA)
{"BIOS", &iflags.BIOS, FALSE, SET_IN_FILE},
#else
{"BIOS", (boolean *)0, FALSE, SET_IN_FILE},
#endif
#ifdef INSURANCE
{"checkpoint", &flags.ins_chkpt, TRUE, DISP_IN_GAME},
#else
{"checkpoint", (boolean *)0, FALSE, SET_IN_FILE},
#endif
#ifdef MFLOPPY
{"checkspace", &iflags.checkspace, TRUE, SET_IN_GAME},
#else
{"checkspace", (boolean *)0, FALSE, SET_IN_FILE},
#endif
# ifdef MICRO
{"color", &iflags.wc_color,TRUE, SET_IN_GAME}, /*WC*/
# else /* systems that support multiple terminals, many monochrome */
{"color", &iflags.wc_color, FALSE, SET_IN_GAME}, /*WC*/
# endif
{"confirm",&flags.confirm, TRUE, SET_IN_GAME},
#ifdef TERMLIB
{"DECgraphics", &iflags.DECgraphics, FALSE, DISP_IN_GAME},
#else
{"DECgraphics", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"eight_bit_tty", &iflags.wc_eight_bit_input, FALSE, DISP_IN_GAME}, /*WC*/
#ifdef TTY_GRAPHICS
{"extmenu", &iflags.extmenu, FALSE, SET_IN_GAME},
#else
{"extmenu", (boolean *)0, FALSE, SET_IN_FILE},
#endif
#ifdef OPT_DISPMAP
{"fast_map", &flags.fast_map, TRUE, SET_IN_GAME},
#else
{"fast_map", (boolean *)0, TRUE, SET_IN_FILE},
#endif
{"female", &flags.female, FALSE, DISP_IN_GAME},
{"fixinv", &flags.invlet_constant, TRUE, DISP_IN_GAME},
#ifdef AMIFLUSH
{"flush", &flags.amiflush, FALSE, SET_IN_GAME},
#else
{"flush", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"help", &flags.help, TRUE, SET_IN_GAME},
{"hilite_pet", &iflags.wc_hilite_pet, FALSE, SET_IN_GAME}, /*WC*/
#ifdef ASCIIGRAPH
{"IBMgraphics", &iflags.IBMgraphics, FALSE, DISP_IN_GAME},
#else
{"IBMgraphics", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"ignintr", &flags.ignintr, FALSE, SET_IN_GAME},
{"large_font", &iflags.wc_large_font, FALSE, SET_IN_GAME}, /*WC*/
{"legacy", &flags.legacy, TRUE, DISP_IN_GAME},
{"lit_corridor", &flags.lit_corridor, FALSE, SET_IN_GAME},
#ifdef MAC_GRAPHICS_ENV
{"Macgraphics", &iflags.MACgraphics, TRUE, DISP_IN_GAME},
#else
{"Macgraphics", (boolean *)0, FALSE, SET_IN_FILE},
#endif
#ifdef MAIL
{"mail", &flags.biff, TRUE, SET_IN_GAME},
#else
{"mail", (boolean *)0, TRUE, SET_IN_FILE},
#endif
#ifdef TTY_GRAPHICS
{"msg_window", &iflags.prevmsg_window, FALSE, SET_IN_GAME},
#else
{"msg_window", (boolean *)0, FALSE, SET_IN_FILE},
#endif
#ifdef NEWS
{"news", &iflags.news, TRUE, DISP_IN_GAME},
#else
{"news", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"null", &flags.null, TRUE, SET_IN_GAME},
{"number_pad", &iflags.num_pad, FALSE, SET_IN_GAME},
#ifdef MAC
{"page_wait", &flags.page_wait, TRUE, SET_IN_GAME},
#else
{"page_wait", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"perm_invent", &flags.perm_invent, FALSE, SET_IN_GAME},
{"popup_dialog", &iflags.wc_popup_dialog, FALSE, SET_IN_GAME}, /*WC*/
{"prayconfirm", &flags.prayconfirm, TRUE, SET_IN_GAME},
{"preload_tiles", &iflags.wc_preload_tiles, TRUE, DISP_IN_GAME}, /*WC*/
{"pushweapon", &flags.pushweapon, FALSE, SET_IN_GAME},
#if defined(MICRO) && !defined(AMIGA)
{"rawio", &iflags.rawio, FALSE, DISP_IN_GAME},
#else
{"rawio", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"rest_on_space", &flags.rest_on_space, FALSE, SET_IN_GAME},
{"safe_pet", &flags.safe_dog, TRUE, SET_IN_GAME},
#ifdef WIZARD
{"sanity_check", &iflags.sanity_check, FALSE, SET_IN_GAME},
#else
{"sanity_check", (boolean *)0, FALSE, SET_IN_FILE},
#endif
#ifdef EXP_ON_BOTL
{"showexp", &flags.showexp, FALSE, SET_IN_GAME},
#else
{"showexp", (boolean *)0, FALSE, SET_IN_FILE},
#endif
#ifdef SCORE_ON_BOTL
{"showscore", &flags.showscore, FALSE, SET_IN_GAME},
#else
{"showscore", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"silent", &flags.silent, TRUE, SET_IN_GAME},
{"sortpack", &flags.sortpack, TRUE, SET_IN_GAME},
{"sound", &flags.soundok, TRUE, SET_IN_GAME},
{"sparkle", &flags.sparkle, TRUE, SET_IN_GAME},
{"standout", &flags.standout, FALSE, SET_IN_GAME},
{"time", &flags.time, FALSE, SET_IN_GAME},
{"tiled_map", &iflags.wc_tiled_map, FALSE, DISP_IN_GAME}, /*WC*/
{"tiles_8x16", &iflags.wc_tiles_8x16, FALSE, DISP_IN_GAME}, /*WC*/
{"tiles_16x16", &iflags.wc_tiles_16x16, FALSE, DISP_IN_GAME}, /*WC*/
{"tiles_32x32", &iflags.wc_tiles_32x32, FALSE, DISP_IN_GAME}, /*WC*/
#ifdef TIMED_DELAY
{"timed_delay", &flags.nap, TRUE, SET_IN_GAME},
#else
{"timed_delay", (boolean *)0, FALSE, SET_IN_GAME},
#endif
{"tombstone",&flags.tombstone, TRUE, SET_IN_GAME},
{"toptenwin",&flags.toptenwin, FALSE, SET_IN_GAME},
{"use_inverse", &iflags.wc_inverse, FALSE, SET_IN_GAME}, /*WC*/
{"verbose", &flags.verbose, TRUE, SET_IN_GAME},
{(char *)0, (boolean *)0, FALSE, 0}
};
/* compound options, for option_help() and external programs like Amiga
* frontend */
static struct Comp_Opt
{
const char *name, *descr;
@@ -205,6 +200,8 @@ static struct Comp_Opt
} compopt[] = {
{ "align", "your starting alignment (lawful, neutral, or chaotic)",
8, DISP_IN_GAME },
{ "align_message", "message window alignment", 20, DISP_IN_GAME }, /*WC*/
{ "align_status", "status window alignment", 20, DISP_IN_GAME }, /*WC*/
#ifdef MAC
{ "background", "the color of the background (black or white)",
6, SET_IN_FILE },
@@ -222,18 +219,24 @@ static struct Comp_Opt
MAXDCHARS+1, SET_IN_FILE },
{ "effects", "the symbols to use in drawing special effects",
MAXECHARS+1, SET_IN_FILE },
#ifdef MAC
{ "fontmap", "the font to use in the map window", 40, SET_IN_FILE },
{ "fontmessage", "the font to use in the message window",
40, SET_IN_FILE },
{ "fonttext", "the font to use in text windows", 40, SET_IN_FILE },
#endif
{ "font_map", "the font to use in the map window", 40, DISP_IN_GAME }, /*WC*/
{ "font_menu", "the font to use in menus", 40, DISP_IN_GAME }, /*WC*/
{ "font_message", "the font to use in the message window",
40, DISP_IN_GAME }, /*WC*/
{ "font_size_map", "the size of the map font", 20, DISP_IN_GAME }, /*WC*/
{ "font_size_menu", "the size of the map font", 20, DISP_IN_GAME }, /*WC*/
{ "font_size_message", "the size of the map font", 20, DISP_IN_GAME }, /*WC*/
{ "font_size_status", "the size of the map font", 20, DISP_IN_GAME }, /*WC*/
{ "font_size_text", "the size of the map font", 20, DISP_IN_GAME }, /*WC*/
{ "font_status", "the font to use in status window", 40, DISP_IN_GAME }, /*WC*/
{ "font_text", "the font to use in text windows", 40, DISP_IN_GAME }, /*WC*/
{ "fruit", "the name of a fruit you enjoy eating",
PL_FSIZ, SET_IN_GAME },
{ "gender", "your starting gender (male or female)",
8, DISP_IN_GAME },
{ "horsename", "the name of your (first) horse (e.g., horsename:Silver)",
PL_PSIZ, DISP_IN_GAME },
{ "map_mode", "map display mode under Windows", 20, DISP_IN_GAME }, /*WC*/
{ "menustyle", "user interface for object selection",
MENUTYPELEN, SET_IN_GAME },
{ "menu_deselect_all", "deselect all items in a menu", 4, SET_IN_FILE },
@@ -280,6 +283,7 @@ static struct Comp_Opt
PL_CSIZ, DISP_IN_GAME },
{ "scores", "the parts of the score list you wish to see",
32, SET_IN_GAME },
{ "scroll_margin", "scroll map when this far from the edge", 20, DISP_IN_GAME }, /*WC*/
#ifdef MSDOS
{ "soundcard", "type of sound card to use", 20, SET_IN_FILE },
#endif
@@ -290,6 +294,7 @@ static struct Comp_Opt
#ifdef MAC
{"use_stone", "use stone background patterns", 8, SET_IN_FILE },
#endif
{ "vary_msgcount", "show more old messages at a time", 20, DISP_IN_GAME }, /*WC*/
#ifdef MSDOS
{ "video", "method of video updating", 20, SET_IN_FILE },
#endif
@@ -298,14 +303,6 @@ static struct Comp_Opt
40, DISP_IN_GAME },
{ "videoshades", "gray shades to map to black/gray/white",
32, DISP_IN_GAME },
#endif
#if 0
{ "warnlevel", "minimum monster level to trigger warning", 4, SET_IN_GAME },
#endif
#ifdef MSWIN_GRAPHICS
{ "win32_map_mode", "map display mode under Windows", 20, SET_IN_FILE },
{ "win32_align_status", "status window alignment", 20, SET_IN_FILE },
{ "win32_align_message", "message window alignment", 20, SET_IN_FILE },
#endif
{ "windowtype", "windowing system to use", WINTYPELEN, DISP_IN_GAME },
{ (char *)0, (char *)0, 0, 0 }
@@ -412,6 +409,10 @@ STATIC_DCL int FDECL(warnlevel_opts, (char *, const char *));
#endif
STATIC_DCL void FDECL(duplicate_opt_detection, (const char *, int));
STATIC_OVL void FDECL(wc_set_font_name, (int, char *));
STATIC_OVL boolean FDECL(is_wc_option, (const char *));
STATIC_OVL boolean FDECL(wc_supported, (const char *));
/* check whether a user-supplied option string is a proper leading
substring of a particular option name; option string might have
a colon or equals sign and arbitrary value appended to it */
@@ -644,6 +645,7 @@ char *tp;
*tp = '\0';
}
#if 0
/* some boolean options can only be set on start-up */
STATIC_OVL int
boolopt_only_initial(i)
@@ -660,6 +662,7 @@ int i;
#endif
);
}
#endif
STATIC_OVL void
rejectoption(optname)
@@ -1110,6 +1113,70 @@ boolean tinitial, tfrom_file;
return;
}
/* WINCAP
* setting font options */
fullname = "font";
if (!strncmpi(opts, fullname, 4))
{ int wintype = -1;
opts += 4;
if (!strncmpi(opts, "map", 3) ||
!strncmpi(opts, "_map", 4))
wintype = NHW_MAP;
else if (!strncmpi(opts, "message", 7) ||
!strncmpi(opts, "_message", 8))
wintype = NHW_MESSAGE;
else if (!strncmpi(opts, "text", 4) ||
!strncmpi(opts, "_text", 5))
wintype = NHW_TEXT;
else if (!strncmpi(opts, "menu", 4) ||
!strncmpi(opts, "_menu", 5))
wintype = NHW_MENU;
else if (!strncmpi(opts, "status", 6) ||
!strncmpi(opts, "_status", 7))
wintype = NHW_STATUS;
if (wintype > 0 &&
(op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
wc_set_font_name(wintype, op);
#ifdef MAC
set_font_name (wintype, op);
#endif
return;
}
if (!strncmpi(opts, "_size_map", 8))
wintype = NHW_MAP;
else if (!strncmpi(opts, "_size_message", 12))
wintype = NHW_MESSAGE;
else if (!strncmpi(opts, "_size_text", 9))
wintype = NHW_TEXT;
else if (!strncmpi(opts, "_size_menu", 9))
wintype = NHW_MENU;
else if (!strncmpi(opts, "_size_status", 11))
wintype = NHW_STATUS;
if (wintype > 0 && !negated &&
(op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
switch(wintype) {
case NHW_MAP:
iflags.wc_fontsiz_map = atoi(op);
break;
case NHW_MESSAGE:
iflags.wc_fontsiz_message = atoi(op);
break;
case NHW_TEXT:
iflags.wc_fontsiz_text = atoi(op);
break;
case NHW_MENU:
iflags.wc_fontsiz_menu = atoi(op);
break;
case NHW_STATUS:
iflags.wc_fontsiz_status = atoi(op);
break;
}
} else if (negated) bad_negation(fullname, TRUE);
return;
}
#ifdef CHANGE_COLOR
#ifdef MAC
fullname = "use_stone";
@@ -1133,25 +1200,8 @@ boolean tinitial, tfrom_file;
}
return;
}
fullname = "font";
if (!strncmpi(opts, fullname, 4))
{ int wintype = -1;
opts += 4;
if (!strncmpi (opts, "map", 3))
wintype = NHW_MAP;
else if (!strncmpi (opts, "message", 7))
wintype = NHW_MESSAGE;
else if (!strncmpi (opts, "text", 4))
wintype = NHW_TEXT;
if (wintype > 0 && (op = string_for_env_opt(fullname, opts, FALSE)) != 0)
{ set_font_name (wintype, op);
}
return;
}
#endif
#endif
if (match_optname(opts, "palette", 3, TRUE)
# ifdef MAC
|| match_optname(opts, "hicolor", 3, TRUE)
@@ -1224,7 +1274,7 @@ boolean tinitial, tfrom_file;
}
return;
}
#endif
#endif /* CHANGE_COLOR */
if (match_optname(opts, "fruit", 2, TRUE)) {
char empty_str = '\0';
@@ -1352,7 +1402,7 @@ goodfruit:
else warning_opts(opts, fullname);
return;
}
#if 0
#if 0 /* do not enable post 3.3.0 */
fullname = "warnlevel";
if (match_optname(opts, fullname, 5, TRUE)) {
op = string_for_opt(opts, negated);
@@ -1430,9 +1480,47 @@ goodfruit:
return;
}
/* WINCAP
* align_status:[left|top|right|bottom] */
fullname = "align_status";
if (match_optname(opts, fullname, sizeof("align_status")-1, TRUE)) {
op = string_for_env_opt(fullname, opts, negated);
if (!negated) {
if (!strncmpi (op, "left", sizeof("left")-1))
iflags.wc_align_status = ALIGN_LEFT;
else if (!strncmpi (op, "top", sizeof("top")-1))
iflags.wc_align_status = ALIGN_TOP;
else if (!strncmpi (op, "right", sizeof("right")-1))
iflags.wc_align_status = ALIGN_RIGHT;
else if (!strncmpi (op, "bottom", sizeof("bottom")-1))
iflags.wc_align_status = ALIGN_BOTTOM;
else
badoption(opts);
} else if (negated) bad_negation(fullname, TRUE);
return;
}
/* WINCAP
* align_message:[left|top|right|bottom] */
fullname = "align_message";
if (match_optname(opts, fullname, sizeof("align_message")-1, TRUE)) {
op = string_for_env_opt(fullname, opts, negated);
if (!negated) {
if (!strncmpi (op, "left", sizeof("left")-1))
iflags.wc_align_message = ALIGN_LEFT;
else if (!strncmpi (op, "top", sizeof("top")-1))
iflags.wc_align_message = ALIGN_TOP;
else if (!strncmpi (op, "right", sizeof("right")-1))
iflags.wc_align_message = ALIGN_RIGHT;
else if (!strncmpi (op, "bottom", sizeof("bottom")-1))
iflags.wc_align_message = ALIGN_BOTTOM;
else
badoption(opts);
} else if (negated) bad_negation(fullname, TRUE);
return;
}
/* align:string */
fullname = "align";
if (match_optname(opts, fullname, 4, TRUE)) {
if (match_optname(opts, fullname, sizeof("align")-1, TRUE)) {
if (negated) bad_negation(fullname, FALSE);
else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0)
if ((flags.initalign = str2align(op)) == ROLE_NONE)
@@ -1745,80 +1833,60 @@ goodfruit:
}
#endif /* MSDOS */
#ifdef MSWIN_GRAPHICS
/* win32_map_mode:[tiles|ascii4x6|ascii6x8|ascii8x8|ascii16x8|ascii7x12|ascii8x12|ascii15x12
|ascii12x16|ascii10x18|fit_to_screen] */
fullname = "win32_map_mode";
if (match_optname(opts, fullname, sizeof("win32_map_mode")-1, TRUE)) {
if (negated) {
bad_negation(fullname, FALSE);
return;
}
else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
return;
}
if (!set_win32_option(fullname, opts))
badoption(opts);
/* WINCAP
* map_mode:[tiles|ascii4x6|ascii6x8|ascii8x8|ascii16x8|ascii7x12|ascii8x12|
ascii15x12|ascii12x16|ascii10x18|fit_to_screen] */
fullname = "map_mode";
if (match_optname(opts, fullname, sizeof("map_mode")-1, TRUE)) {
op = string_for_env_opt(fullname, opts, negated);
if (!negated) {
if (!strncmpi (op, "tiles", sizeof("tiles")-1))
iflags.wc_map_mode = MAP_MODE_TILES;
else if (!strncmpi (op, "ascii4x6", sizeof("ascii4x6")-1))
iflags.wc_map_mode = MAP_MODE_ASCII4x6;
else if (!strncmpi (op, "ascii6x8", sizeof("ascii6x8")-1))
iflags.wc_map_mode = MAP_MODE_ASCII6x8;
else if (!strncmpi (op, "ascii8x8", sizeof("ascii8x8")-1))
iflags.wc_map_mode = MAP_MODE_ASCII8x8;
else if (!strncmpi (op, "ascii16x8", sizeof("ascii16x8")-1))
iflags.wc_map_mode = MAP_MODE_ASCII16x8;
else if (!strncmpi (op, "ascii7x12", sizeof("ascii7x12")-1))
iflags.wc_map_mode = MAP_MODE_ASCII7x12;
else if (!strncmpi (op, "ascii8x12", sizeof("ascii8x12")-1))
iflags.wc_map_mode = MAP_MODE_ASCII8x12;
else if (!strncmpi (op, "ascii15x12", sizeof("ascii15x12")-1))
iflags.wc_map_mode = MAP_MODE_ASCII16x12;
else if (!strncmpi (op, "ascii12x16", sizeof("ascii12x16")-1))
iflags.wc_map_mode = MAP_MODE_ASCII12x16;
else if (!strncmpi (op, "ascii10x18", sizeof("ascii10x18")-1))
iflags.wc_map_mode = MAP_MODE_ASCII10x18;
else if (!strncmpi (op, "fit_to_screen", sizeof("fit_to_screen")-1))
iflags.wc_map_mode = MAP_MODE_ASCII_FIT_TO_SCREEN;
else
badoption(opts);
} else if (negated) bad_negation(fullname, TRUE);
return;
}
/* win32_align_status:[left|top|right|bottom] */
fullname = "win32_align_status";
if (match_optname(opts, fullname, sizeof("win32_align_status")-1, TRUE)) {
if (negated) {
bad_negation(fullname, FALSE);
return;
}
else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
return;
}
if (!set_win32_option(fullname, opts))
badoption(opts);
/* WINCAP
* scroll_margin:nn */
fullname = "scroll_margin";
if (match_optname(opts, fullname, sizeof("scroll_margin")-1, TRUE)) {
op = string_for_env_opt(fullname, opts, negated);
if ((negated && !op) || (!negated && op)) {
iflags.wc_scroll_margin = negated ? 5 : atoi(op);
} else if (negated) bad_negation(fullname, TRUE);
return;
}
/* win32_align_message:[left|top|right|bottom] */
fullname = "win32_align_message";
if (match_optname(opts, fullname, sizeof("win32_align_message")-1, TRUE)) {
if (negated) {
bad_negation(fullname, FALSE);
return;
}
else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
return;
}
if (!set_win32_option(fullname, opts))
badoption(opts);
/* WINCAP
* vary_msgcount:nn */
fullname = "vary_msgcount";
if (match_optname(opts, fullname, sizeof("vary_msgcount")-1, TRUE)) {
op = string_for_env_opt(fullname, opts, negated);
if ((negated && !op) || (!negated && op)) {
iflags.wc_vary_msgcount = negated ? 0 : atoi(op);
} else if (negated) bad_negation(fullname, TRUE);
return;
}
/* win32_map_cliparound_margin:nn */
fullname = "win32_map_cliparound_margin";
if (match_optname(opts, fullname, sizeof("win32_map_cliparound_margin")-1, TRUE)) {
if (negated) {
bad_negation(fullname, FALSE);
return;
}
else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
return;
}
if (!set_win32_option(fullname, opts))
badoption(opts);
return;
}
#endif /* MSWIN_GRAPHICS */
#ifdef WIN32CON
/* ignore the graphical win32 graphical options silently,
* so defaults.nh can be easily used by both tty and win32
*/
if (match_optname(opts, "win32_map_mode",
sizeof("win32_map_mode")-1, TRUE) ||
match_optname(opts, "win32_align_status",
sizeof("win32_align_status")-1, TRUE) ||
match_optname(opts, "win32_align_message",
sizeof("win32_align_message")-1, TRUE) ||
match_optname(opts, "win32_map_cliparound_margin",
sizeof("win32_map_cliparound_margin")-1, TRUE))
return;
#endif
fullname = "windowtype";
if (match_optname(opts, fullname, 3, TRUE)) {
@@ -1910,7 +1978,11 @@ goodfruit:
return;
}
/* options that must come from config file */
#if 0
if (!initial && boolopt_only_initial(i)) {
#else
if (!initial && (boolopt[i].optflags == SET_IN_FILE)) {
#endif
rejectoption(boolopt[i].name);
return;
}
@@ -2157,11 +2229,14 @@ doset()
for (pass = 0; pass <= 1; pass++)
for (i = 0; boolopt[i].name; i++)
if ((bool_p = boolopt[i].addr) != 0 &&
(boolopt_only_initial(i) ^ pass)) {
((boolopt[i].optflags == DISP_IN_GAME && pass == 0) ||
(boolopt[i].optflags == SET_IN_GAME && pass == 1))) {
if (bool_p == &flags.female) continue; /* obsolete */
#ifdef WIZARD
if (bool_p == &iflags.sanity_check && !wizard) continue;
#endif
if (is_wc_option(boolopt[i].name) &&
!wc_supported(boolopt[i].name)) continue;
any.a_int = (pass == 0) ? 0 : i + 1;
Sprintf(buf, "%s%-13s [%s]",
pass == 0 ? " " : "",
@@ -2205,6 +2280,9 @@ doset()
!strcmp(compopt[i].name, "race") ||
!strcmp(compopt[i].name, "gender"))
continue;
else if (is_wc_option(compopt[i].name) &&
!wc_supported(compopt[i].name))
continue;
else
doset_add_menu(tmpwin, compopt[i].name,
(pass == DISP_IN_GAME) ? 0 : indexoffset);
@@ -2232,6 +2310,8 @@ doset()
Sprintf(buf, "%s%s", *boolopt[opt_indx].addr ? "!" : "",
boolopt[opt_indx].name);
parseoptions(buf, setinitial, fromfile);
if (wc_supported(boolopt[opt_indx].name))
preference_update(boolopt[opt_indx].name);
} else {
/* compound option */
opt_indx -= boolcount;
@@ -2244,6 +2324,8 @@ doset()
/* pass the buck */
parseoptions(buf, setinitial, fromfile);
}
if (wc_supported(compopt[opt_indx].name))
preference_update(boolopt[opt_indx].name);
}
}
free((genericptr_t)pick_list);
@@ -2395,7 +2477,19 @@ char *buf;
int i;
buf[0] = '\0';
if (!strcmp(optname,"align"))
if (!strcmp(optname,"align_message"))
Sprintf(buf, "%s", iflags.wc_align_message == ALIGN_TOP ? "top" :
iflags.wc_align_message == ALIGN_LEFT ? "left" :
iflags.wc_align_message == ALIGN_BOTTOM ? "bottom" :
iflags.wc_align_message == ALIGN_RIGHT ? "right" :
"unknown");
else if (!strcmp(optname,"align_status"))
Sprintf(buf, "%s", iflags.wc_align_message == ALIGN_TOP ? "top" :
iflags.wc_align_message == ALIGN_LEFT ? "left" :
iflags.wc_align_message == ALIGN_BOTTOM ? "bottom" :
iflags.wc_align_message == ALIGN_RIGHT ? "right" :
"unknown");
else if (!strcmp(optname,"align"))
Sprintf(buf, "%s", rolestring(flags.initalign, aligns, adj));
else if (!strcmp(optname, "boulder"))
Sprintf(buf, "%c", iflags.bouldersym ?
@@ -2419,12 +2513,46 @@ char *buf;
Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "effects"))
Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "font_map"))
Sprintf(buf, "%s", iflags.wc_font_map ? iflags.wc_font_map : none);
else if (!strcmp(optname, "font_message"))
Sprintf(buf, "%s", iflags.wc_font_message ? iflags.wc_font_message : none);
else if (!strcmp(optname, "font_status"))
Sprintf(buf, "%s", iflags.wc_font_status ? iflags.wc_font_status : none);
else if (!strcmp(optname, "font_menu"))
Sprintf(buf, "%s", iflags.wc_font_menu ? iflags.wc_font_menu : none);
else if (!strcmp(optname, "font_text"))
Sprintf(buf, "%s", iflags.wc_font_text ? iflags.wc_font_text : none);
else if (!strcmp(optname, "font_size_map"))
Sprintf(buf, "%d", iflags.wc_fontsiz_map);
else if (!strcmp(optname, "font_size_message"))
Sprintf(buf, "%d", iflags.wc_fontsiz_message);
else if (!strcmp(optname, "font_size_status"))
Sprintf(buf, "%d", iflags.wc_fontsiz_status);
else if (!strcmp(optname, "font_size_menu"))
Sprintf(buf, "%d", iflags.wc_fontsiz_menu);
else if (!strcmp(optname, "font_size_text"))
Sprintf(buf, "%d", iflags.wc_fontsiz_text);
else if (!strcmp(optname, "fruit"))
Sprintf(buf, "%s", pl_fruit);
else if (!strcmp(optname, "gender"))
Sprintf(buf, "%s", rolestring(flags.initgend, genders, adj));
else if (!strcmp(optname, "horsename"))
Sprintf(buf, "%s", horsename[0] ? horsename : none);
else if (!strcmp(optname, "map_mode"))
Sprintf(buf, "%s",
iflags.wc_map_mode == MAP_MODE_TILES ? "tiles" :
iflags.wc_map_mode == MAP_MODE_ASCII4x6 ? "ascii4x6" :
iflags.wc_map_mode == MAP_MODE_ASCII6x8 ? "ascii6x8" :
iflags.wc_map_mode == MAP_MODE_ASCII8x8 ? "ascii8x8" :
iflags.wc_map_mode == MAP_MODE_ASCII16x8 ? "ascii16x8" :
iflags.wc_map_mode == MAP_MODE_ASCII7x12 ? "ascii7x12" :
iflags.wc_map_mode == MAP_MODE_ASCII8x12 ? "ascii8x12" :
iflags.wc_map_mode == MAP_MODE_ASCII16x12 ? "ascii16x12" :
iflags.wc_map_mode == MAP_MODE_ASCII12x16 ? "ascii12x16" :
iflags.wc_map_mode == MAP_MODE_ASCII10x18 ? "ascii10x18" :
iflags.wc_map_mode == MAP_MODE_ASCII_FIT_TO_SCREEN ?
"fit_to_screen" : "unknown");
else if (!strcmp(optname, "menustyle"))
Sprintf(buf, "%s", menutype[(int)flags.menu_style] );
else if (!strcmp(optname, "menu_deselect_all"))
@@ -2482,7 +2610,9 @@ char *buf;
else if (!strcmp(optname, "scores")) {
Sprintf(buf, "%d top/%d around%s", flags.end_top,
flags.end_around, flags.end_own ? "/own" : "");
}
}
else if (!strcmp(optname, "scroll_margin"))
Sprintf(buf, "%d", iflags.wc_scroll_margin);
#ifdef MSDOS
else if (!strcmp(optname, "soundcard"))
Sprintf(buf, "%s", to_be_done);
@@ -2497,6 +2627,8 @@ char *buf;
FEATURE_NOTICE_VER_PATCH);
} else if (!strcmp(optname, "traps"))
Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "vary_msgcount"))
Sprintf(buf, "%d", iflags.wc_vary_msgcount);
#ifdef MSDOS
else if (!strcmp(optname, "video"))
Sprintf(buf, "%s", to_be_done);
@@ -2836,6 +2968,98 @@ char *class_select;
return ret;
}
struct wc_Opt wc_options[] = {
{"ascii_map", WC_ASCII_MAP},
{"color", WC_COLOR},
{"eight_bit_tty", WC_EIGHT_BIT_IN},
{"hilite_pet", WC_HILITE_PET},
{"large_font", WC_LARGE_FONT},
{"popup_dialog", WC_POPUP_DIALOG},
{"preload_tiles", WC_PRELOAD_TILES},
{"tiled_map", WC_TILED_MAP},
{"tiles_16x16", WC_TILES_16x16},
{"tiles_32x32", WC_TILES_32x32},
{"tiles_8x16", WC_TILES_8x16},
{"use_inverse", WC_INVERSE},
{"align_message", WC_ALIGN_MESSAGE},
{"align_status", WC_ALIGN_STATUS},
{"font_map", WC_FONT_MAP},
{"font_menu", WC_FONT_MENU},
{"font_message",WC_FONT_MESSAGE},
#if 0
{"perm_invent",WC_PERM_INVENT},
#endif
{"font_size_map", WC_FONTSIZ_MAP},
{"font_size_menu", WC_FONTSIZ_MENU},
{"font_size_message", WC_FONTSIZ_MESSAGE},
{"font_size_status", WC_FONTSIZ_STATUS},
{"font_size_text", WC_FONTSIZ_TEXT},
{"font_status", WC_FONT_STATUS},
{"font_text", WC_FONT_TEXT},
{"map_mode", WC_MAP_MODE},
{"scroll_margin", WC_SCROLL_MARGIN},
{"vary_msgcount",WC_VARY_MSGCOUNT},
{(char *)0, 0L}
};
STATIC_OVL boolean
is_wc_option(optnam)
const char *optnam;
{
int k = 0;
while (wc_options[k].wc_name) {
if (strcmp(wc_options[k].wc_name, optnam) == 0)
return TRUE;
k++;
}
return FALSE;
}
STATIC_OVL boolean
wc_supported(optnam)
const char *optnam;
{
int k = 0;
while (wc_options[k].wc_name) {
if (!strcmp(wc_options[k].wc_name, optnam) &&
(windowprocs.wincap & wc_options[k].wc_bit))
return TRUE;
k++;
}
return FALSE;
}
STATIC_OVL void
wc_set_font_name(wtype, fontname)
int wtype;
char *fontname;
{
char **fn = (char **)0;
switch(wtype) {
case NHW_MAP:
fn = &iflags.wc_font_map;
break;
case NHW_MESSAGE:
fn = &iflags.wc_font_message;
break;
case NHW_TEXT:
fn = &iflags.wc_font_text;
break;
case NHW_MENU:
fn = &iflags.wc_font_menu;
break;
case NHW_STATUS:
fn = &iflags.wc_font_status;
break;
}
if (fn) {
if (*fn) free(*fn);
*fn = (char *)alloc(strlen(fontname) + 1);
Strcpy(*fn, fontname);
}
return;
}
#endif /* OPTION_LISTS_ONLY */
/*options.c*/

View File

@@ -991,6 +991,13 @@ freedynamicdata()
free_waterlevel();
free_dungeons();
/* some pointers in iflags */
if (iflags.wc_font_map) free(iflags.wc_font_map);
if (iflags.wc_font_message) free(iflags.wc_font_message);
if (iflags.wc_font_text) free(iflags.wc_font_text);
if (iflags.wc_font_menu) free(iflags.wc_font_menu);
if (iflags.wc_font_status) free(iflags.wc_font_status);
#endif /* FREE_ALL_MEMORY */
return;
}

View File

@@ -133,4 +133,16 @@ const char *mesg;
return 0;
}
void
genl_preference_update(pref)
const char *pref;
{
extern struct wc_Opt wc_options[]; /* in options.c */
/* window ports are expected to provide
their own preference update routine
for the preference capabilities that
they support.
Just return in this genl one. */
return;
}
/*windows.c*/