diff --git a/dat/optmenu b/dat/optmenu new file mode 100644 index 000000000..ac44de33f --- /dev/null +++ b/dat/optmenu @@ -0,0 +1,39 @@ + How dynamically setting options works: + + The options menu shows the current value for all options and lets + you pick ones that you'd like to change. Picking them doesn't make + any immediate changes though. That will take place once you close + the menu. For most of NetHack's interfaces, closing the menu is + done by pressing the key or key; others might + require clicking on [ok]. Pressing the key or clicking + on [cancel] will close the menu and discard any pending changes. + + The options menu is too long to fit on one screen. Some interfaces + paginate menus; use the '>' key to advance a page or '<' to back + up. They typically re-use selection letters (a-z) on each page. + Others use one long page and you need to use a scrollbar; once past + a-z and A-Z they'll have entries without selection letters. Those + can be selected by clicking on them. + + For toggling boolean (True/False or On/Off) options, selecting them + is all that is needed. For compound options (which take a number, + a choice of several particular values, or something more complex, + and are listed in a second section after the boolean ones), you will + be prompted to supply a new value. + + At the start of each of the two sections are the values of some + unselectable options which can only be set before the game starts. + After the compound section are some "other" options which take a set + of multiple values and tend to be more complicated to deal with. + + Some changes will only last until you save (or quit) the current + game. Usually those are for things that might not be appropriate + if you were to restore the saved game on another computer with + different capabilities. Other options will be included in this + game's save file and retain their settings after restore. None set + in the options menu will affect other games, either already saved or + new ones. For that, you need to update your run-time configuration + file and specify the desired options settings there. Even then, + restoring existing games that contain saved option values will use + those saved ones. + diff --git a/include/global.h b/include/global.h index 04fb9625d..12ae0c06c 100644 --- a/include/global.h +++ b/include/global.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 global.h $NHDT-Date: 1612127119 2021/01/31 21:05:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.120 $ */ +/* NetHack 3.7 global.h $NHDT-Date: 1642630918 2022/01/19 22:21:58 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.131 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -25,6 +25,7 @@ #define HISTORY "history" /* file giving nethack's history */ #define LICENSE "license" /* file with license information */ #define OPTIONFILE "opthelp" /* file explaining runtime options */ +#define OPTMENUHELP "optmenu" /* file explaining #options command */ #define OPTIONS_USED "options" /* compile-time options, for #version */ #define SYMBOLS "symbols" /* replacement symbol sets */ #define EPITAPHFILE "epitaph" /* random epitaphs on graves */ diff --git a/src/cmd.c b/src/cmd.c index fe90ea4d7..00e8f551a 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 cmd.c $NHDT-Date: 1629928192 2021/08/25 21:49:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.483 $ */ +/* NetHack 3.7 cmd.c $NHDT-Date: 1642630919 2022/01/19 22:21:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.500 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2856,8 +2856,10 @@ ecname_from_fn(int (*fn)(void)) /* return extended command name (without leading '#') for command (*fn)() */ const char * -cmdname_from_func(int (*fn)(void), char outbuf[], - boolean fullname) /* False: just enough to disambiguate */ +cmdname_from_func( + int (*fn)(void), /* function whose command name is wanted */ + char outbuf[], /* place to store the result */ + boolean fullname) /* False: just enough to disambiguate */ { const struct ext_func_tab *extcmd, *cmdptr = 0; const char *res = 0; diff --git a/src/options.c b/src/options.c index 83dc8b998..378087ffa 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 options.c $NHDT-Date: 1641673953 2022/01/08 20:32:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.525 $ */ +/* NetHack 3.7 options.c $NHDT-Date: 1642630919 2022/01/19 22:21:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.528 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2008. */ /* NetHack may be freely redistributed. See license for details. */ @@ -262,7 +262,6 @@ static int count_menucolors(void); static boolean parse_role_opts(int, boolean, const char *, char *, char **); static unsigned int longest_option_name(int, int); -static void explain_O_command(void); static void doset_add_menu(winid, const char *, int, int); static int handle_add_list_remove(const char *, int); static void remove_autopickup_exception(struct autopickup_exception *); @@ -7290,68 +7289,6 @@ longest_option_name(int startpass, int endpass) return longest_name_len; } -/* text to optionally insert at the beginning of #options command's menu, - briefly describing how it works; [brevity is in the eye of the beholder - or perhaps a pig; it was brief when this comment was first written...] */ -static const char *const optmenu[] = { - "How dynamically setting options works:", - "", - "The options menu shows the current value for all options and lets", - "you pick ones that you'd like to change. Picking them doesn't make", - "any immediate changes though. That will take place once you close", - "the menu. For most of NetHack's interfaces, closing the menu is", - "done by pressing the key or key; others might", - "require clicking on [ok]. Pressing the key or clicking", - "on [cancel] will close the menu and discard any pending changes.", - "", - "The options menu is too long to fit on one screen. Some interfaces", - "paginate menus; use the '>' key to advance a page or '<' to back", - "up. They typically re-use selection letters (a-z) on each page.", - "Others use one long page and you need to use a scrollbar; once", - "past a-z and A-Z they'll have entries without selection letters.", - "Those can be selected by clicking on them.", - "", - "For toggling boolean (True/False or On/Off) options, selecting", - "them is all that is needed. For compound options (below, after", - "the boolean ones), you will be prompted to supply a new value.", - "", - "At the start of each of the two sections are the values of some", - "unselectable options which can only be set before the game starts.", - "After the compound section are some \"other\" options which take a", - "set of multiple values and tend to be more complex to deal with.", - "", - "Some changes will only last until you save (or quit) the current", - "game. Usually those are for things that might not be appropriate", - "if you were to restore the saved game on another computer with", - "different capabilities. Other options will be included in this", - "game's save file and retain their settings after restore. None set", - "here will affect other games, either already saved or new ones.", - "For that, you need to update your run-time configuration file and", - "specify the desired options settings there. Even then, restoring", - "existing games that contain saved option values will use those.", - "", - NULL -}; - -/* display the optmenu[] explanatory text in a popup text window */ -static void -explain_O_command(void) -{ - anything any; - winid Ohlp; - char buf[BUFSZ]; - int i; - - Ohlp = create_nhwindow(NHW_TEXT); - any = cg.zeroany; - for (i = 0; optmenu[i]; ++i) { - Sprintf(buf, " %.75s ", optmenu[i]); - putstr(Ohlp, ATR_NONE, buf); - } - display_nhwindow(Ohlp, TRUE); - destroy_nhwindow(Ohlp); -} - /* the #options command */ int doset(void) /* changing options via menu by Per Liboriussen */ @@ -7518,7 +7455,7 @@ doset(void) /* changing options via menu by Per Liboriussen */ if ((pick_cnt = select_menu(tmpwin, PICK_ANY, &pick_list)) > 0) { if (pick_list[0].item.a_int - 1 == '?') { /* player chose the special '?' entry */ - explain_O_command(); + display_file(OPTMENUHELP, FALSE); /* if '?' was the only thing selected, go back and pick all over again without it as an available choice this time; however, if any other stuff was also chosen, just continue diff --git a/src/pager.c b/src/pager.c index d45bca767..55b8a2f8d 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 pager.c $NHDT-Date: 1622421100 2021/05/31 00:31:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.202 $ */ +/* NetHack 3.7 pager.c $NHDT-Date: 1642630920 2022/01/19 22:22:00 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.210 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -26,6 +26,7 @@ static void docontact(void); static void dispfile_help(void); static void dispfile_shelp(void); static void dispfile_optionfile(void); +static void dispfile_optmenu(void); static void dispfile_license(void); static void dispfile_debughelp(void); static void hmenu_doextversion(void); @@ -37,6 +38,7 @@ static void domenucontrols(void); #ifdef PORT_HELP extern void port_help(void); #endif +static char *setopt_cmd(char *); static const char invisexplain[] = "remembered, unseen, creature", altinvisexplain[] = "unseen creature"; /* for clairvoyance */ @@ -2140,6 +2142,12 @@ dispfile_optionfile(void) display_file(OPTIONFILE, TRUE); } +static void +dispfile_optmenu(void) +{ + display_file(OPTMENUHELP, TRUE); +} + static void dispfile_license(void) { @@ -2204,6 +2212,7 @@ static const struct { { hmenu_dowhatdoes, "Info on what a given key does." }, { option_help, "List of game options." }, { dispfile_optionfile, "Longer explanation of game options." }, + { dispfile_optmenu, "Using the %s command to set options." }, { dokeylist, "Full list of keyboard commands." }, { hmenu_doextlist, "List of extended commands." }, { domenucontrols, "List menu control keys." }, @@ -2223,7 +2232,7 @@ int dohelp(void) { winid tmpwin = create_nhwindow(NHW_MENU); - char helpbuf[QBUFSZ]; + char helpbuf[QBUFSZ], tmpbuf[QBUFSZ]; int i, n; menu_item *selected; anything any; @@ -2237,6 +2246,8 @@ dohelp(void) continue; if (help_menu_items[i].text[0] == '%') { Sprintf(helpbuf, help_menu_items[i].text, PORT_ID); + } else if (help_menu_items[i].f == dispfile_optmenu) { + Sprintf(helpbuf, help_menu_items[i].text, setopt_cmd(tmpbuf)); } else { Strcpy(helpbuf, help_menu_items[i].text); } @@ -2257,6 +2268,28 @@ dohelp(void) RESTORE_WARNING_FORMAT_NONLITERAL +/* format the key or extended command name of command used to set options; + normally 'O' but could be bound to something else, or not bound at all */ +static char * +setopt_cmd(char *outbuf) +{ + char cmdnambuf[QBUFSZ]; + const char *cmdname; + char key = cmd_from_func(doset); + + if (key) { + /* key value enclosed within single quotes */ + Sprintf(outbuf, "'%s'", visctrl(key)); + } else { + /* extended command name, with leading "#", also in single quotes */ + cmdname = cmdname_from_func(doset, cmdnambuf, TRUE); + if (!cmdname) /* paranoia */ + cmdname = "options"; + Sprintf(outbuf, "'%s%.31s'", (*cmdname != '#') ? "#" : "", cmdname); + } + return outbuf; +} + /* the 'V' command; also a choice for '?' */ int dohistory(void) diff --git a/sys/unix/Makefile.top b/sys/unix/Makefile.top index 1c8bdf54a..32d051e0c 100644 --- a/sys/unix/Makefile.top +++ b/sys/unix/Makefile.top @@ -1,5 +1,5 @@ # NetHack Top-level Makefile. -# NetHack 3.7 Makefile.top $NHDT-Date: 1609702004 2021/01/03 19:26:44 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.66 $ +# NetHack 3.7 Makefile.top $NHDT-Date: 1642630921 2022/01/19 22:22:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.72 $ # Copyright (c) 2015 by Kenneth Lorber, Kensington, Maryland # NetHack may be freely redistributed. See license for details. @@ -91,7 +91,7 @@ LUA_VERSION = 5.4.3 # end of configuration # -DATHELP = help hh cmdhelp keyhelp history opthelp wizhelp +DATHELP = help hh cmdhelp keyhelp history opthelp optmenu wizhelp SPEC_LEVS = asmodeus.lua baalz.lua bigrm-*.lua castle.lua fakewiz?.lua \ juiblex.lua knox.lua medusa-?.lua minend-?.lua minefill.lua \