From f35abea80b76abf6a98dbbf7e5a2617ebabfc29a Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 2 Mar 2023 05:33:16 -0800 Subject: [PATCH] change 'm #tip' behavior Using the 'm' prefix with #tip was putting up a menu to pick between one or more floor containers and 'choose from invent', but that interfered with choosing Tip as a context-sensitive item-action for carried container. Change 'm' to behave like it does with #eat and \#quaff and several other commands: skip possible candidates on the floor and go directly to picking something from inventory. That prevents using 'm' to force a menu of |a - |i - pick a container being carried for any menustyle when there is one floor container. For menustyles other than traditional, I think that's inconsequential; player needs to answer 'n' for floor container and then get the choose-from-invent prompt instead of 'i' and then choose. When there are two or more containers on hero's spot, 'm' prefix isn't needed to get that menu. Unfortuately using 'm' to override menustyle:Traditional is still a thing players might want to do. Keep the prior behavior for that style when multiple containers are present (dotip() already skipped that menu despite 'm' when there was just one container). Use the new behavior (skip floor containers) when one (or none) is present. That's inconsistent but seems more useful than alternatives. It is relatively unlikely that anyone who uses traditional non-menu item selection will also use newfangled inventory item-actions so the menu isn't likely to interfere with the latter. Update the Guidebook to describe how Traditional differs just in case. --- doc/Guidebook.mn | 18 ++++++++++++++---- doc/Guidebook.tex | 19 ++++++++++++++++--- doc/fixes3-7-0.txt | 3 +++ src/invent.c | 9 +++++++++ src/pickup.c | 24 ++++++++++++++++++------ 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index c934ced21..d582294e9 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -643,7 +643,7 @@ a monster there). .lp "" A few non-movement commands use the \(oq\f(CRm\fP\(cq prefix to request operating via menu (to temporarily override the -.op menustyle:Traditional +.op menustyle \f(CR:traditional\fP option). Primarily useful for \(oq\f(CR,\fP\(cq (pickup) when there is only one class of objects present (where there won't be any \(lqwhat kinds of objects?\(rq @@ -656,10 +656,10 @@ list of all discovered objects) and the \(oq\f(CR\`\fP\(cq (knownclass, show a list of discovered objects in a particular class) commands to offer a menu of several sorting alternatives (which sets a new value for the .op sortdiscoveries -option). +option); also for \(lq#vanquished\(rq command to offer a sorting menu. .lp "" A few other commands (eat food, offer sacrifice, apply tinning-kit, -drink/quaff, dip) use +drink/quaff, dip, tip container) use the \(oq\f(CRm\fP\(cq prefix to skip checking for applicable objects on the floor and go straight to checking inventory, or (for \(lq#loot\(rq to remove a saddle), @@ -1644,9 +1644,19 @@ Autocompletes. Debug mode only. .lp "#tip " Tip over a container (bag or box) to pour out its contents. +When there are containers on the floor, the game will prompt to pick one +of them or \(lqtip something being carried\(rq. +If the latter is chosen, there will be another prompt for which item +from inventory to tip. +.lp "" +The \(oq\f(CRm\fP\(cq prefix makes the command skip containers on the +floor and pick one from inventory, except for the special case of +.op menustyle \f(CR:traditional\fP +with two or more containers present; that situation will start with the +floor container menu. +.lp "" Autocompletes. Default key is \(oqM-T\(cq. -The \(oqm\(cq prefix makes the command use a menu. .lp "#travel " Travel to a specific location on the map. Default key is \(oq_\(cq. \" underscore diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 6c29cd0aa..6f036f586 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -747,11 +747,12 @@ It can also be used with the `{\tt $\backslash$}' (known, show a list of all discovered objects) and the `{\tt \`{}}' (knownclass, show a list of discovered objects in a particular class) commands to offer a menu of several sorting alternatives (which sets a new value for the -{\it sortdiscoveries\/} option). +{\it sortdiscoveries\/} +option); also for ``{\tt \#vanquished}'' command to offer a sorting menu. \\ %.lp "" A few other commands (eat food, offer sacrifice, apply tinning-kit, -drink/quaff, dip) use +drink/quaff, dip, tip container) use the `{\tt m}' prefix to skip checking for applicable objects on the floor and go straight to checking inventory, or (for ``{\tt \#loot}'' to remove a saddle), @@ -1773,8 +1774,20 @@ Debug mode only. %.lp \item[\tb{\#tip}] Tip over a container (bag or box) to pour out its contents. +When there are containers on the floor, the game will prompt to pick one +of them or ``tip something being carried''. +\\ +%.lp "" +If the latter is chosen, there will be another prompt for which item +from inventory to tip. +The `{\tt m}' prefix makes the command skip containers on the +floor and pick one from inventory, except for the special case of +{\it menustyle:Traditional\/} +with two or more containers present; that situation will start with the +floor container menu. +\\ +%.lp "" Autocompletes. Default key is `{\tt M-T}'. -The `{\tt m}' prefix makes the command use a menu. %.lp \item[\tb{\#travel}] Travel to a specific location on the map. diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 1e580e39c..6c03dbdc6 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1494,6 +1494,9 @@ hallucination of objects incorrectly included generic objects as candidates some actions that ask the user to pick a location allow typing '$' to show valid spots, accept typing a second '$' prior to moving the cursor to toggle the highlights off; ^R already did that; moving the cursor too +change 'm' prefix for #tip from 'use menu to pick among floor containers' + (since that's already the default) to 'skip floor containers' so that + context-sensitive item-action Tip directly operates on the item curses: 'msg_window' option wasn't functional for curses unless the binary also included tty support diff --git a/src/invent.c b/src/invent.c index c5bc1cbea..19d2aba29 100644 --- a/src/invent.c +++ b/src/invent.c @@ -2844,6 +2844,15 @@ itemactions_pushkeys(struct obj *otmp, int act) cmdq_add_key(CQ_CANNED, otmp->invlet); break; case IA_TIP_CONTAINER: + /* start with m-prefix to skip floor containers; + for menustyle:Traditional when more than one floor + container is present, player will get a #tip menu and + have to pick the "tip sometking being carried" choice, + then this item will be already chosen from inventory; + suboptimal but possibly an acceptable tradeoff since + combining item actions with use of traditional ggetobj() + is an unlikely scenario */ + cmdq_add_ec(CQ_CANNED, do_reqmenu); cmdq_add_ec(CQ_CANNED, dotip); cmdq_add_key(CQ_CANNED, otmp->invlet); break; diff --git a/src/pickup.c b/src/pickup.c index 183080b47..b44616318 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -3280,21 +3280,32 @@ dotip(void) const char *spillage = 0; /* - * doesn't require free hands; - * limbs are needed to tip floor containers + * Doesn't require free hands; + * limbs are needed to tip floor containers. + * + * Note: for menustyle:Traditional, using m prefix forces a menu + * of floor containers when more than one is present. For other + * menustyle settings or when fewer than two floor containers are + * present, using 'm' skips floor and goes straight to invent. + * This somewhat unintuitive behavior is driven by the way that + * context-sensitive inventory item actions use m prefix. */ /* at present, can only tip things at current spot, not adjacent ones */ cc.x = u.ux, cc.y = u.uy; /* check floor container(s) first; at most one will be accessed */ - if ((boxes = container_at(cc.x, cc.y, TRUE)) > 0) { + boxes = container_at(cc.x, cc.y, TRUE); + /* this is iffy for menustyle:traditional; 'm' prefix is ambiguous + for it: skip floor vs handle multiple containers via menu */ + if (boxes > 0 + && (!iflags.menu_requested + || (flags.menu_style == MENU_TRADITIONAL && boxes > 1))) { Sprintf(buf, "You can't tip %s while carrying so much.", !Verbose(2, dotip) ? "a container" : (boxes > 1) ? "one" : "it"); if (!check_capacity(buf) && able_to_loot(cc.x, cc.y, FALSE)) { - if (boxes > 1 && (flags.menu_style != MENU_TRADITIONAL - || iflags.menu_requested)) { + if (boxes > 1) { /* use menu to pick a container to tip */ int n, i; winid win; @@ -3369,7 +3380,8 @@ dotip(void) } } - /* either no floor container(s) or couldn't tip one or didn't tip any */ + /* either no floor container(s) or 'm' prefix was used to ignore such + or couldn't tip one or didn't tip any */ cobj = getobj("tip", tip_ok, GETOBJ_PROMPT); if (!cobj) return ECMD_CANCEL;