Make #tip at a location which has multiple containers honor menustyle
rather than always use a menu. Only affects menustyle:traditional and can be overridden at the time by using the 'm' prefix before the #tip command. When using the menu, add an explicit pick-from-inventory choice. The behavior there stays the same: ask about inventory if no floor container is chosen.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 cmd.c $NHDT-Date: 1434071945 2015/06/12 01:19:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.195 $ */
|
/* NetHack 3.6 cmd.c $NHDT-Date: 1434507810 2015/06/17 02:23:30 $ $NHDT-Branch: master $:$NHDT-Revision: 1.196 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -3201,7 +3201,8 @@ STATIC_OVL boolean
|
|||||||
accept_menu_prefix(cmd_func)
|
accept_menu_prefix(cmd_func)
|
||||||
int NDECL((*cmd_func));
|
int NDECL((*cmd_func));
|
||||||
{
|
{
|
||||||
if (cmd_func == dopickup || cmd_func == doextcmd || cmd_func == doextlist)
|
if (cmd_func == dopickup || cmd_func == dotip
|
||||||
|
|| cmd_func == doextcmd || cmd_func == doextlist)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-15
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 pickup.c $NHDT-Date: 1432804962 2015/05/28 09:22:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.157 $ */
|
/* NetHack 3.6 pickup.c $NHDT-Date: 1434507811 2015/06/17 02:23:31 $ $NHDT-Branch: master $:$NHDT-Revision: 1.159 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -2691,53 +2691,74 @@ dotip()
|
|||||||
Sprintf(buf, "You can't tip %s while carrying so much.",
|
Sprintf(buf, "You can't tip %s while carrying so much.",
|
||||||
!flags.verbose ? "a container" : (boxes > 1) ? "one" : "it");
|
!flags.verbose ? "a container" : (boxes > 1) ? "one" : "it");
|
||||||
if (!check_capacity(buf) && able_to_loot(cc.x, cc.y, FALSE)) {
|
if (!check_capacity(buf) && able_to_loot(cc.x, cc.y, FALSE)) {
|
||||||
|
if (boxes > 1 && (flags.menu_style != MENU_TRADITIONAL
|
||||||
if (boxes > 1) {
|
|| iflags.menu_requested)) {
|
||||||
/* use menu to pick a container to tip */
|
/* use menu to pick a container to tip */
|
||||||
int n, i;
|
int n, i;
|
||||||
winid win;
|
winid win;
|
||||||
anything any;
|
anything any;
|
||||||
menu_item *pick_list = NULL;
|
menu_item *pick_list = NULL;
|
||||||
|
struct obj dummyobj, *otmp;
|
||||||
|
|
||||||
any = zeroany;
|
any = zeroany;
|
||||||
win = create_nhwindow(NHW_MENU);
|
win = create_nhwindow(NHW_MENU);
|
||||||
start_menu(win);
|
start_menu(win);
|
||||||
|
|
||||||
for (cobj = level.objects[cc.x][cc.y]; cobj;
|
for (cobj = level.objects[cc.x][cc.y], i = 0; cobj;
|
||||||
cobj = cobj->nexthere)
|
cobj = cobj->nexthere)
|
||||||
if (Is_container(cobj)) {
|
if (Is_container(cobj)) {
|
||||||
|
++i;
|
||||||
any.a_obj = cobj;
|
any.a_obj = cobj;
|
||||||
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
|
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
|
||||||
doname(cobj), MENU_UNSELECTED);
|
doname(cobj), MENU_UNSELECTED);
|
||||||
}
|
}
|
||||||
|
if (invent) {
|
||||||
|
any = zeroany;
|
||||||
|
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
|
||||||
|
"", MENU_UNSELECTED);
|
||||||
|
any.a_obj = &dummyobj;
|
||||||
|
/* use 'i' for inventory unless there are so many
|
||||||
|
containers that it's already being used */
|
||||||
|
i = (i <= 'i' - 'a' && !flags.lootabc) ? 'i' : 0;
|
||||||
|
add_menu(win, NO_GLYPH, &any, i, 0, ATR_NONE,
|
||||||
|
"tip something being carried", MENU_SELECTED);
|
||||||
|
}
|
||||||
end_menu(win, "Tip which container?");
|
end_menu(win, "Tip which container?");
|
||||||
n = select_menu(win, PICK_ONE, &pick_list);
|
n = select_menu(win, PICK_ONE, &pick_list);
|
||||||
destroy_nhwindow(win);
|
destroy_nhwindow(win);
|
||||||
|
/*
|
||||||
if (n > 0) {
|
* Deal with quirk of preselected item in pick-one menu:
|
||||||
for (i = 0; i < n; i++) {
|
* n == 0 => picked preselected entry, toggling it off;
|
||||||
tipcontainer(pick_list[i].item.a_obj);
|
* n == 1 => accepted preselected choice via SPACE or RETURN;
|
||||||
free((genericptr_t) pick_list);
|
* n == 2 => picked something other than preselected entry;
|
||||||
return 1;
|
* n == -1 => cancelled via ESC;
|
||||||
}
|
*/
|
||||||
}
|
otmp = (n <= 0) ? (struct obj *) 0 : pick_list[0].item.a_obj;
|
||||||
|
if (n > 1 && otmp == &dummyobj)
|
||||||
|
otmp = pick_list[1].item.a_obj;
|
||||||
if (pick_list)
|
if (pick_list)
|
||||||
free((genericptr_t) pick_list);
|
free((genericptr_t) pick_list);
|
||||||
|
if (otmp && otmp != &dummyobj) {
|
||||||
|
tipcontainer(otmp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (n == -1)
|
if (n == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
/* else pick-from-invent below */
|
||||||
} else {
|
} else {
|
||||||
for (cobj = level.objects[cc.x][cc.y]; cobj; cobj = nobj) {
|
for (cobj = level.objects[cc.x][cc.y]; cobj; cobj = nobj) {
|
||||||
nobj = cobj->nexthere;
|
nobj = cobj->nexthere;
|
||||||
if (!Is_container(cobj))
|
if (!Is_container(cobj))
|
||||||
continue;
|
continue;
|
||||||
|
c = ynq(safe_qbuf(qbuf, "There is ", " here, tip it?",
|
||||||
c = ynq(safe_qbuf(qbuf, "There is ", " here, tip it?", cobj,
|
cobj,
|
||||||
doname, ansimpleoname, "container"));
|
doname, ansimpleoname, "container"));
|
||||||
if (c == 'q')
|
if (c == 'q')
|
||||||
return 0;
|
return 0;
|
||||||
if (c == 'n')
|
if (c == 'n')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tipcontainer(cobj);
|
tipcontainer(cobj);
|
||||||
|
/* can only tip one container at a time */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user