]> granicus.if.org Git - nethack/commitdiff
fix buglist entry: menu upon request
authornethack.allison <nethack.allison>
Sat, 11 Jan 2003 17:22:58 +0000 (17:22 +0000)
committernethack.allison <nethack.allison>
Sat, 11 Jan 2003 17:22:58 +0000 (17:22 +0000)
For "traditional" menu style, pickup and #loot/apply can't accept an 'm'
response to bring up a menu upon request when all items involved are of
the same class, because the prompt where that response is allowed only
gets issued when multiple classes are present.

doc/Guidebook.mn
doc/Guidebook.tex
include/extern.h
include/flag.h
src/cmd.c
src/invent.c
src/pickup.c

index dbbfa859ff295f7a0f8ac143f6b3861be7f49ccf..a525fddc910d785103a206c6aaa9288486d48555 100644 (file)
@@ -5,7 +5,7 @@
 .ds vr "NetHack 3.4
 .ds f0 "\*(vr
 .ds f1
-.ds f2 "December 17, 2002
+.ds f2 "January 11, 2003
 .mt
 A Guide to the Mazes of Menace
 (Guidebook for NetHack)
@@ -630,7 +630,7 @@ Look at what is here.
 .lp ;
 Show what type of thing a visible symbol corresponds to.
 .lp ,
-Pick up some things.
+Pick up some things. May be preceded by `m' to force a selection menu.
 .lp @
 Toggle the
 .op autopickup
index 4003d5358e4498f3e40349988a11a91fe006d74a..5bb50e1736a0a9343fedceef77d279bb54c6159b 100644 (file)
@@ -27,7 +27,7 @@
 \begin{document}
 %
 % input file: guidebook.mn
-% $Revision: 1.58 $ $Date: 2002/10/31 08:39:11 $
+% $Revision: 1.59 $ $Date: 2002/12/17 11:19:45 $
 %
 %.ds h0 "
 %.ds h1 %.ds h2 \%
@@ -40,7 +40,7 @@
 %.au
 \author{Eric S. Raymond\\
 (Extensively edited and expanded for 3.4)}
-\date{December 17, 2002}
+\date{January 11, 2003}
 
 \maketitle
 
@@ -835,7 +835,7 @@ Look at what is here.
 Show what type of thing a visible symbol corresponds to.
 %.lp
 \item[\tb{,}]
-Pick up some things.
+Pick up some things. May be preceded by `{\tt m}' to force a selection menu.
 %.lp
 \item[\tb{@}]
 Toggle the {\it autopickup\/} option on and off.
index 9385f41d41faaeef1ec9b07222bca10b14c04b37..c5dcad1d77ebac9b760d0661e0ccac2f8d46486f 100644 (file)
@@ -1444,10 +1444,10 @@ E void NDECL(getlock);
 
 #ifdef GOLDOBJ
 E int FDECL(collect_obj_classes,
-       (char *,struct obj *,BOOLEAN_P,boolean FDECL((*),(OBJ_P))));
+       (char *,struct obj *,BOOLEAN_P,boolean FDECL((*),(OBJ_P)), int *));
 #else
 E int FDECL(collect_obj_classes,
-       (char *,struct obj *,BOOLEAN_P,BOOLEAN_P,boolean FDECL((*),(OBJ_P))));
+       (char *,struct obj *,BOOLEAN_P,BOOLEAN_P,boolean FDECL((*),(OBJ_P)), int *));
 #endif
 E void FDECL(add_valid_menu_class, (int));
 E boolean FDECL(allow_all, (struct obj *));
index 11b746d1deafaed3dab34c2cd37331d22190ddd5..badbd7df2ada2ce1ffddb01dd78de45550c147c5 100644 (file)
@@ -165,6 +165,8 @@ struct instance_flags {
        boolean  window_inited; /* true if init_nhwindows() completed */
        boolean  vision_inited; /* true if vision is ready */
        boolean  menu_tab_sep;  /* Use tabs to separate option menu fields */
+       boolean  menu_requested; /* Flag for overloaded use of 'm' prefix
+                                 * on some non-move commands */
        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 4ec4090011543823fc0609f357d069302f4e8990..c84d92d8da16b3529b15614a83a945742612a645 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1753,6 +1753,7 @@ register char *cmd;
        boolean do_walk, do_rush, prefix_seen, bad_command,
                firsttime = (cmd == 0);
 
+       iflags.menu_requested = FALSE;
        if (firsttime) {
                flags.nopick = 0;
                cmd = parse();
@@ -1850,6 +1851,14 @@ register char *cmd;
                    }
                    break;
        }
+
+       /* some special prefix handling */
+       /* overload 'm' prefix for ',' to mean "request a menu" */
+       if (prefix_seen && cmd[1] == ',') {
+               iflags.menu_requested = TRUE;
+               ++cmd;
+       }
+
        if (do_walk) {
            if (multi) flags.mv = TRUE;
            domove();
index a762d1da786baa54119c8dcf98beecf9fb79cdbf..e1e965b0ef5c0c8a8118a6d428fc16b76c4a5c73 100644 (file)
@@ -1136,6 +1136,7 @@ unsigned *resultflags;
        int FDECL((*ckfn),(OBJ_P)) = (int FDECL((*),(OBJ_P))) 0;
        boolean FDECL((*filter),(OBJ_P)) = (boolean FDECL((*),(OBJ_P))) 0;
        boolean takeoff, ident, allflag, m_seen;
+       int itemcount;
 #ifndef GOLDOBJ
        int oletct, iletct, allowgold, unpaid, oc_of_sym;
 #else
@@ -1172,7 +1173,7 @@ unsigned *resultflags;
 #ifndef GOLDOBJ
                                        (allowgold != 0),
 #endif
-                                       filter);
+                                       filter, &itemcount);
        unpaid = count_unpaid(invent);
 
        if (ident && !iletct) {
@@ -1928,7 +1929,7 @@ dotypeinv()
        char c = '\0';
        int n, i = 0;
        char *extra_types, types[BUFSZ];
-       int class_count, oclass, unpaid_count;
+       int class_count, oclass, unpaid_count, itemcount;
        boolean billx = *u.ushops && doinvbill(0);
        menu_item *pick_list;
        boolean traditional = TRUE;
@@ -1963,7 +1964,7 @@ dotypeinv()
 #ifndef GOLDOBJ
                                              (u.ugold != 0),
 #endif
-                                             (boolean FDECL((*),(OBJ_P))) 0);
+                                             (boolean FDECL((*),(OBJ_P))) 0, &itemcount);
            if (unpaid_count) {
                Strcat(types, "u");
                class_count++;
index 22648343c228feb51986967c2905cac728f4de19..b90a4853d721eca5b071e32b9d144d21912e0e83 100644 (file)
@@ -87,23 +87,26 @@ boolean here;               /* flag for type of obj list linkage */
 
 #ifndef GOLDOBJ
 int
-collect_obj_classes(ilets, otmp, here, incl_gold, filter)
+collect_obj_classes(ilets, otmp, here, incl_gold, filter, itemcount)
 char ilets[];
 register struct obj *otmp;
 boolean here, incl_gold;
 boolean FDECL((*filter),(OBJ_P));
+int *itemcount;
 #else
 int
-collect_obj_classes(ilets, otmp, here, filter)
+collect_obj_classes(ilets, otmp, here, filter, itemcount)
 char ilets[];
 register struct obj *otmp;
 boolean here;
 boolean FDECL((*filter),(OBJ_P));
+int *itemcount;
 #endif
 {
        register int iletct = 0;
        register char c;
 
+       *itemcount = 0;
 #ifndef GOLDOBJ
        if (incl_gold)
            ilets[iletct++] = def_oc_syms[COIN_CLASS];
@@ -113,6 +116,7 @@ boolean FDECL((*filter),(OBJ_P));
            c = def_oc_syms[(int)otmp->oclass];
            if (!index(ilets, c) && (!filter || (*filter)(otmp)))
                ilets[iletct++] = c,  ilets[iletct] = '\0';
+           *itemcount += 1;
            otmp = here ? otmp->nexthere : otmp->nobj;
        }
 
@@ -158,6 +162,7 @@ int *menu_on_demand;
        boolean not_everything;
        char qbuf[QBUFSZ];
        boolean m_seen;
+       int itemcount;
 
        oclasses[oclassct = 0] = '\0';
        *one_at_a_time = *everything = m_seen = FALSE;
@@ -165,12 +170,17 @@ int *menu_on_demand;
 #ifndef GOLDOBJ
                                     incl_gold,
 #endif
-                                    (boolean FDECL((*),(OBJ_P))) 0);
+                                    (boolean FDECL((*),(OBJ_P))) 0, &itemcount);
        if (iletct == 0) {
                return FALSE;
        } else if (iletct == 1) {
                oclasses[0] = def_char_to_objclass(ilets[0]);
                oclasses[1] = '\0';
+               if (itemcount && menu_on_demand) {
+                       ilets[iletct++] = 'm';
+                       *menu_on_demand = 0;
+                       ilets[iletct] = '\0';
+               }
        } else  {       /* more than one choice available */
                const char *where = 0;
                register char sym, oc_of_sym, *p;
@@ -438,9 +448,9 @@ int what;           /* should be a long */
            goto menu_pickup;
        }
 
-       if (flags.menu_style != MENU_TRADITIONAL) {
-           /* use menus exclusively */
+       if (flags.menu_style != MENU_TRADITIONAL || iflags.menu_requested) {
 
+           /* use menus exclusively */
            if (count) {        /* looking for N of something */
                char buf[QBUFSZ];
                Sprintf(buf, "Pick %d of what?", count);
@@ -1906,7 +1916,7 @@ register int held;
        struct monst *shkp;
        boolean one_by_one, allflag, loot_out = FALSE, loot_in = FALSE;
        char select[MAXOCLASSES+1];
-       char qbuf[BUFSZ], emptymsg[BUFSZ];
+       char qbuf[BUFSZ], emptymsg[BUFSZ], pbuf[QBUFSZ];
        long loss = 0L;
        int cnt = 0, used = 0, lcnt = 0,
            menu_on_request;
@@ -2040,7 +2050,9 @@ register int held;
 ask_again2:
                menu_on_request = 0;
                add_valid_menu_class(0);        /* reset */
-               switch (yn_function(qbuf, ":ynq", 'n')) {
+               Strcpy(pbuf, ":ynq");
+               if (cnt) Strcat(pbuf, "m");
+               switch (yn_function(qbuf, pbuf, 'n')) {
                case ':':
                    container_contents(current_container, FALSE, FALSE);
                    goto ask_again2;
@@ -2065,6 +2077,10 @@ ask_again2:
                    /*FALLTHRU*/
                case 'n':
                    break;
+               case 'm':
+                   menu_on_request = -2; /* triggers ALL_CLASSES */
+                   used |= menu_loot(menu_on_request, current_container, FALSE) > 0;
+                   break;
                case 'q':
                default:
                    return used;
@@ -2084,8 +2100,25 @@ ask_again2:
            return used;
        }
        if (flags.menu_style != MENU_FULL) {
-           loot_in = (yn_function("Do you wish to put something in?",
-                                  ynqchars, 'n') == 'y');
+           Sprintf(qbuf, "Do you wish to put %s in?", something);
+           Strcpy(pbuf, ynqchars);
+           if (flags.menu_style == MENU_TRADITIONAL && invent && inv_cnt() > 0)
+               Strcat(pbuf, "m");
+           switch (yn_function(qbuf, pbuf, 'n')) {
+               case 'y':
+                   loot_in = TRUE;
+                   break;
+               case 'n':
+                   break;
+               case 'm':
+                   add_valid_menu_class(0);      /* reset */
+                   menu_on_request = -2; /* triggers ALL_CLASSES */
+                   used |= menu_loot(menu_on_request, current_container, TRUE) > 0;
+                   break;
+               case 'q':
+               default:
+                   return used;
+           }
        }
        /*
         * Gone: being nice about only selecting food if we know we are