]> granicus.if.org Git - nethack/commitdiff
headings in option menus
authornethack.allison <nethack.allison>
Sun, 5 Oct 2003 19:56:22 +0000 (19:56 +0000)
committernethack.allison <nethack.allison>
Sun, 5 Oct 2003 19:56:22 +0000 (19:56 +0000)
There was a great deal of inconsistency in
different menus on how headings were displayed.
This allows the user to select what they like best.
I was motivated to do this, because I wasn't satisfied
with the appearance of ATR_INVERSE in the menus
on win32tty, and several of them specified it.

12 files changed:
doc/Guidebook.mn
doc/Guidebook.tex
doc/fixes34.3
include/flag.h
src/artifact.c
src/cmd.c
src/dungeon.c
src/invent.c
src/o_init.c
src/options.c
src/pickup.c
src/weapon.c

index 36e729d460bb180bd71b17d1f8342d256a1cd139..4cdac9901f663d56fddf7840ce9c566b8724b946 100644 (file)
@@ -5,7 +5,7 @@
 .ds vr "NetHack 3.4
 .ds f0 "\*(vr
 .ds f1
-.ds f2 "August 14, 2003
+.ds f2 "October 5, 2003
 .mt
 A Guide to the Mazes of Menace
 (Guidebook for NetHack)
@@ -1855,6 +1855,10 @@ Default '\e'.
 Menu character accelerator to jump to the first page in a menu.
 Implemented by the Amiga, Gem and tty ports.
 Default '^'.
+.lp menu_headings
+Controls how the headings in a menu are highlighted.
+Values are 'bold', 'inverse', or 'underline'.
+Not all ports can actually display all three types.
 .lp menu_invert_all
 Menu character accelerator to invert all items in a menu.
 Implemented by the Amiga, Gem, X11 and tty ports.
index e5071efa72bf9849028878a41328f30141e6ff99..3fde661c4d1d8aa8354d96ecbe748726c98a4a3b 100644 (file)
@@ -27,7 +27,7 @@
 \begin{document}
 %
 % input file: guidebook.mn
-% $Revision: 1.70 $ $Date: 2003/09/27 15:55:35 $
+% $Revision: 1.71 $ $Date: 2003/09/28 03:42:24 $
 %
 %.ds h0 "
 %.ds h1 %.ds h2 \%
@@ -40,7 +40,7 @@
 %.au
 \author{Eric S. Raymond\\
 (Extensively edited and expanded for 3.4)}
-\date{August 14, 2003}
+\date{October 5, 2003}
 
 \maketitle
 
@@ -2294,6 +2294,10 @@ Default `\verb+\+'.
 Menu character accelerator to jump to the first page in a menu.
 Implemented by the Amiga, Gem and tty ports.
 Default `\verb+^+'.
+\item[\ib{menu\_headings}]
+Controls how the headings in a menu are highlighted.
+Values are ``{\tt bold}'', ``{\tt inverse}'', or ``{\tt underline}''.
+Not all ports can actually display all three types.
 \item[\ib{menu\_invert\_all}]
 Menu character accelerator to invert all items in a menu.
 Implemented by the Amiga, Gem, X11 and tty ports.
index 348779389ea0c26b5987d65a7fb392a264b8a436..d4af3976dc48daceb7e1ebe26ed1982b775834f5 100644 (file)
@@ -56,6 +56,7 @@ General New Features
 --------------------
 bones file compatibility info is now written into the dat/options file
 extend autodig to work downwards via '>'
+make attribute that is used to distinguish headings in a menu configurable
 
 
 Platform- and/or Interface-Specific New Features
index 3af261f62eb53ccdf90431ee4df7f9ed1df6f678..ccada31700e2bd144fbfb2a7eed456066a837319 100644 (file)
@@ -155,6 +155,7 @@ struct instance_flags {
        boolean  menu_requested; /* Flag for overloaded use of 'm' prefix
                                  * on some non-move commands */
        uchar num_pad_mode;
+       int     menu_headings;  /* ATR for menu headings */
        int      purge_monsters;        /* # of dead monsters still on fmon list */
        int *opt_booldup;       /* for duplication of boolean opts in config file */
        int *opt_compdup;       /* for duplication of compound opts in config file */
index 407295f895929b6cf7ceb3aaeffbc47a9cc59497..ee18f5e547881c3068405dbf255f68110ef34747 100644 (file)
@@ -692,7 +692,7 @@ winid tmpwin;               /* supplied by dodiscover() */
 
     for (i = 0; i < NROFARTIFACTS; i++) {
        if (artidisco[i] == 0) break;   /* empty slot implies end of list */
-       if (i == 0) putstr(tmpwin, ATR_INVERSE, "Artifacts");
+       if (i == 0) putstr(tmpwin, iflags.menu_headings, "Artifacts");
        m = artidisco[i];
        otyp = artilist[m].otyp;
        Sprintf(buf, "  %s [%s %s]", artiname(m),
index 1109c92f97cfe729564510c98c0a40ff3a91b994..9a60d8f53b78cb7ea788b16c1958f149c9c5a07d 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1149,7 +1149,7 @@ minimal_enlightenment()
        buf[0] = buf2[0] = '\0';
        tmpwin = create_nhwindow(NHW_MENU);
        start_menu(tmpwin);
-       add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD, "Starting", FALSE);
+       add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, "Starting", FALSE);
 
        /* Starting name, race, role, gender */
        Sprintf(buf, fmtstr, "name", plname);
@@ -1168,7 +1168,7 @@ minimal_enlightenment()
 
        /* Current name, race, role, gender */
        add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", FALSE);
-       add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD, "Current", FALSE);
+       add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, "Current", FALSE);
        Sprintf(buf, fmtstr, "race", Upolyd ? youmonst.data->mname : urace.noun);
        add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
        if (Upolyd) {
@@ -1195,7 +1195,7 @@ minimal_enlightenment()
 
        /* Deity list */
        add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", FALSE);
-       add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD, "Deities", FALSE);
+       add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, "Deities", FALSE);
        Sprintf(buf2, deity_fmtstr, align_gname(A_CHAOTIC),
            (u.ualignbase[A_ORIGINAL] == u.ualign.type
                && u.ualign.type == A_CHAOTIC) ? " (s,c)" :
index 9bee483034db7ce4fc76c72d457139b5a9b93e77..1a5df39edb94afc1de0cd9b9485e36bdee594384 100644 (file)
@@ -1584,7 +1584,7 @@ boolean bymenu;
        }
        if (bymenu) {
            any.a_void = 0;
-           add_menu(win, NO_GLYPH, &any, 0, 0, ATR_BOLD, buf, MENU_UNSELECTED);
+           add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, buf, MENU_UNSELECTED);
        } else
            putstr(win, 0, buf);
 
@@ -1624,7 +1624,7 @@ boolean bymenu;
            if (first) {
                if (bymenu) {
                    any.a_void = 0;
-                   add_menu(win, NO_GLYPH, &any, 0, 0, ATR_BOLD,
+                   add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
                                "Floating branches", MENU_UNSELECTED);
                } else {
                    putstr(win, 0, "");
index 07981ff34da67f5ff2f753134c3cf075696b6775..f0578167fed386b54313fe7261f02cd4c7d31844 100644 (file)
@@ -1718,7 +1718,7 @@ nextclass:
                        if (!flags.sortpack || otmp->oclass == *invlet) {
                            if (flags.sortpack && !classcount) {
                                any.a_void = 0;         /* zero */
-                               add_menu(win, NO_GLYPH, &any, 0, 0, ATR_INVERSE,
+                               add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
                                    let_to_name(*invlet, FALSE), MENU_UNSELECTED);
                                classcount++;
                            }
@@ -2678,7 +2678,7 @@ const char *hdr, *txt;
        any.a_void = 0;
        win = create_nhwindow(NHW_MENU);
        start_menu(win);
-       add_menu(win, NO_GLYPH, &any, 0, 0, ATR_INVERSE, hdr, MENU_UNSELECTED);
+       add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, hdr, MENU_UNSELECTED);
        add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
        add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, txt, MENU_UNSELECTED);
        end_menu(win, (char *)0);
index bb93754fd40457222a09b47881ba44245b0a0879..7816fb2a0184b1ad668b9898ab09be6c2d8a6deb 100644 (file)
@@ -382,7 +382,7 @@ dodiscovered()                              /* free after Robert Viduya */
     for (i = dis = 0; i < SIZE(uniq_objs); i++)
        if (objects[uniq_objs[i]].oc_name_known) {
            if (!dis++)
-               putstr(tmpwin, ATR_INVERSE, "Unique Items");
+               putstr(tmpwin, iflags.menu_headings, "Unique Items");
                Sprintf(buf, "  %s", OBJ_NAME(objects[uniq_objs[i]]));
            putstr(tmpwin, 0, buf);
            ++ct;
@@ -406,7 +406,7 @@ dodiscovered()                              /* free after Robert Viduya */
            if ((dis = disco[i]) && interesting_to_discover(dis)) {
                ct++;
                if (oclass != prev_class) {
-                   putstr(tmpwin, ATR_INVERSE, let_to_name(oclass, FALSE));
+                   putstr(tmpwin, iflags.menu_headings, let_to_name(oclass, FALSE));
                    prev_class = oclass;
                }
                Sprintf(buf, "%s %s",(objects[dis].oc_pre_discovered ? "*" : " "),
index 1a52d7c3d194eaa33996a5102ea74c2e2b7de7a6..b1ab8811173c72eb02921905340a36aa26106683 100644 (file)
@@ -254,6 +254,7 @@ static struct Comp_Opt
                                                4, SET_IN_FILE },
        { "menu_first_page", "jump to the first page in a menu",
                                                4, SET_IN_FILE },
+       { "menu_headings", "bold, inverse, or underline headings", 9, SET_IN_GAME },
        { "menu_invert_all", "invert all items in a menu", 4, SET_IN_FILE },
        { "menu_invert_page", "invert all items on this page of a menu",
                                                4, SET_IN_FILE },
@@ -507,6 +508,7 @@ initoptions()
 #ifdef TTY_GRAPHICS
        iflags.prevmsg_window = 's';
 #endif
+       iflags.menu_headings = ATR_INVERSE;
 
        /* Use negative indices to indicate not yet selected */
        flags.initrole = -1;
@@ -2055,6 +2057,26 @@ goodfruit:
                return;
        }
 
+       fullname = "menu_headings";
+       if (match_optname(opts, fullname, 12, TRUE)) {
+               if (negated) {
+                       bad_negation(fullname, FALSE);
+                       return;
+               }
+               else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
+                       return;
+               }
+               if (!strcmpi(opts,"bold"))
+                       iflags.menu_headings = ATR_BOLD;
+               else if (!strcmpi(opts,"inverse"))
+                       iflags.menu_headings = ATR_INVERSE;
+               else if (!strcmpi(opts,"underline"))
+                       iflags.menu_headings = ATR_ULINE;
+               else
+                       badoption(opts);
+               return;
+       }
+
        /* check for menu command mapping */
        for (i = 0; i < NUM_MENU_CMDS; i++) {
            fullname = default_menu_cmd_info[i].name;
@@ -2344,7 +2366,7 @@ doset()
        start_menu(tmpwin);
 
        any.a_void = 0;
- add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD,
+ add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
                 "Booleans (selecting will toggle value):", MENU_UNSELECTED);
        any.a_int = 0;
        /* first list any other non-modifiable booleans, then modifiable ones */
@@ -2378,7 +2400,7 @@ doset()
        indexoffset = boolcount;
        any.a_void = 0;
        add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
- add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD,
+ add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
                 "Compounds (selecting will prompt for new value):",
                 MENU_UNSELECTED);
 
@@ -2422,7 +2444,7 @@ doset()
                }
 #ifdef PREFIXES_IN_USE
        add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
- add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD,
+ add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
                 "Variable playground locations:", MENU_UNSELECTED);
        for (i = 0; i < PREFIX_COUNT; i++)
                doset_add_menu(tmpwin, fqn_prefix_names[i], 0);
@@ -2487,7 +2509,7 @@ boolean setinitial,setfromfile;
     boolean retval = FALSE;
     
     /* Special handling of menustyle, pickup_burden, pickup_types,
-       disclose, runmode, msg_window, and number_pad options. */
+       disclose, runmode, msg_window, menu_headings, and number_pad options. */
     if (!strcmp("menustyle", optname)) {
        const char *style_name;
        menu_item *style_pick = (menu_item *)0;
@@ -2705,6 +2727,36 @@ boolean setinitial,setfromfile;
        destroy_nhwindow(tmpwin);
         retval = TRUE;
     }
+    else if (!strcmp("menu_headings", optname)) {
+       static const char *mhchoices[3] = {"bold", "inverse", "underline"};
+       char *npletters = "biu";
+       menu_item *mode_pick = (menu_item *)0;
+        tmpwin = create_nhwindow(NHW_MENU);
+       start_menu(tmpwin);
+       for (i = 0; i < SIZE(mhchoices); i++) {
+               any.a_int = i + 1;
+               add_menu(tmpwin, NO_GLYPH, &any, npletters[i], 0,
+                        ATR_NONE, mhchoices[i], MENU_UNSELECTED);
+        }
+       end_menu(tmpwin, "How to highlight menu headings:");
+       if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) {
+               int mode = mode_pick->item.a_int - 1;
+               switch(mode) {
+                       case 2:
+                               iflags.menu_headings = ATR_ULINE;
+                               break;
+                       case 0:
+                               iflags.menu_headings = ATR_BOLD;
+                               break;
+                       case 1:
+                       default:
+                               iflags.menu_headings = ATR_INVERSE;
+               }
+               free((genericptr_t)mode_pick);
+        }
+       destroy_nhwindow(tmpwin);
+        retval = TRUE;
+    }
     return retval;
 }
 
@@ -2828,6 +2880,12 @@ char *buf;
                Sprintf(buf, "%s", to_be_done);
        else if (!strcmp(optname, "menu_invert_all"))
                Sprintf(buf, "%s", to_be_done);
+       else if (!strcmp(optname, "menu_headings")) {
+               Sprintf(buf, "%s", (iflags.menu_headings == ATR_BOLD) ?
+                       "bold" :   (iflags.menu_headings == ATR_INVERSE) ?
+                       "inverse" :   (iflags.menu_headings == ATR_ULINE) ?
+                       "underline" : "unknown");
+       }
        else if (!strcmp(optname, "menu_invert_page"))
                Sprintf(buf, "%s", to_be_done);
        else if (!strcmp(optname, "menu_last_page"))
index 8192798e8e40aca94f1b7bcf7f88c2ea44162528..bbb9cbd9ee040f4ac48063982a64aac6e5fc7b92 100644 (file)
@@ -709,7 +709,7 @@ boolean FDECL((*allow), (OBJ_P));/* allow function */
                    /* if sorting, print type name (once only) */
                    if (qflags & INVORDER_SORT && !printed_type_name) {
                        any.a_obj = (struct obj *) 0;
-                       add_menu(win, NO_GLYPH, &any, 0, 0, ATR_INVERSE,
+                       add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
                                        let_to_name(*pack, FALSE), MENU_UNSELECTED);
                        printed_type_name = TRUE;
                    }
index 44c8c82f8e6e0e187d034f2e06751ae7aef0f588..e986d70870cc86ecb84534a6529ed8cddd561e73 100644 (file)
@@ -892,7 +892,7 @@ enhance_weapon_skill()
                /* Print headings for skill types */
                any.a_void = 0;
                if (i == skill_ranges[pass].first)
-                   add_menu(win, NO_GLYPH, &any, 0, 0, ATR_BOLD,
+                   add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
                             skill_ranges[pass].name, MENU_UNSELECTED);
 
                if (P_RESTRICTED(i)) continue;