Merge branch 'fix-cmd-3' of https://github.com/argrath/NetHack into argrath-20220609
This commit is contained in:
@@ -151,6 +151,7 @@ static void reset_cmd_vars(boolean);
|
|||||||
static void mcmd_addmenu(winid, int, const char *);
|
static void mcmd_addmenu(winid, int, const char *);
|
||||||
static char here_cmd_menu(void);
|
static char here_cmd_menu(void);
|
||||||
static char there_cmd_menu(int, int, int);
|
static char there_cmd_menu(int, int, int);
|
||||||
|
static void act_on_act(int, int, int, int, int, int);
|
||||||
static char readchar_core(int *, int *, int *);
|
static char readchar_core(int *, int *, int *);
|
||||||
static char *parse(void);
|
static char *parse(void);
|
||||||
static void show_direction_keys(winid, char, boolean);
|
static void show_direction_keys(winid, char, boolean);
|
||||||
@@ -4902,56 +4903,11 @@ there_cmd_menu_common(
|
|||||||
return K;
|
return K;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* offer choice of actions to perform at adjacent location <x,y> */
|
static void
|
||||||
static char
|
act_on_act(int act, int x, int y, int dx, int dy, int dir)
|
||||||
there_cmd_menu(int x, int y, int mod)
|
|
||||||
{
|
{
|
||||||
winid win;
|
|
||||||
struct obj *otmp;
|
struct obj *otmp;
|
||||||
char ch = '\0';
|
|
||||||
int npick = 0, K = 0;
|
|
||||||
menu_item *picks = (menu_item *) 0;
|
|
||||||
int dx = sgn(x - u.ux), dy = sgn(y - u.uy);
|
|
||||||
int dir = xytod(dx, dy);
|
|
||||||
int act = MCMD_NOTHING;
|
|
||||||
|
|
||||||
win = create_nhwindow(NHW_MENU);
|
|
||||||
start_menu(win, MENU_BEHAVE_STANDARD);
|
|
||||||
|
|
||||||
if (u_at(x, y))
|
|
||||||
K += there_cmd_menu_self(win, x, y, &act);
|
|
||||||
else if (next2u(x, y))
|
|
||||||
K += there_cmd_menu_next2u(win, x, y, mod, &act);
|
|
||||||
else
|
|
||||||
K += there_cmd_menu_far(win, x, y, mod);
|
|
||||||
K += there_cmd_menu_common(win, x, y, mod, &act);
|
|
||||||
|
|
||||||
if (!K) {
|
|
||||||
/* no menu options, try to move */
|
|
||||||
if (next2u(x, y) && !test_move(u.ux, u.uy, dx, dy, TEST_MOVE))
|
|
||||||
cmdq_add_ec(move_funcs[dir][MV_WALK]);
|
|
||||||
else if (flags.travelcmd) {
|
|
||||||
iflags.travelcc.x = u.tx = x;
|
|
||||||
iflags.travelcc.y = u.ty = y;
|
|
||||||
cmdq_add_ec(dotravel_target);
|
|
||||||
}
|
|
||||||
npick = 0;
|
|
||||||
ch = '\0';
|
|
||||||
} else if ((K == 1) && (act != MCMD_NOTHING)) {
|
|
||||||
destroy_nhwindow(win);
|
|
||||||
goto act_on_act;
|
|
||||||
} else {
|
|
||||||
end_menu(win, "What do you want to do?");
|
|
||||||
npick = select_menu(win, PICK_ONE, &picks);
|
|
||||||
ch = '\033';
|
|
||||||
}
|
|
||||||
destroy_nhwindow(win);
|
|
||||||
if (npick > 0) {
|
|
||||||
act = picks->item.a_int;
|
|
||||||
|
|
||||||
free((genericptr_t) picks);
|
|
||||||
|
|
||||||
act_on_act:
|
|
||||||
switch (act) {
|
switch (act) {
|
||||||
case MCMD_TRAVEL:
|
case MCMD_TRAVEL:
|
||||||
iflags.travelcc.x = u.tx = x;
|
iflags.travelcc.x = u.tx = x;
|
||||||
@@ -5100,6 +5056,58 @@ there_cmd_menu(int x, int y, int mod)
|
|||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* offer choice of actions to perform at adjacent location <x,y> */
|
||||||
|
static char
|
||||||
|
there_cmd_menu(int x, int y, int mod)
|
||||||
|
{
|
||||||
|
winid win;
|
||||||
|
char ch = '\0';
|
||||||
|
int npick = 0, K = 0;
|
||||||
|
menu_item *picks = (menu_item *) 0;
|
||||||
|
int dx = sgn(x - u.ux), dy = sgn(y - u.uy);
|
||||||
|
int dir = xytod(dx, dy);
|
||||||
|
int act = MCMD_NOTHING;
|
||||||
|
|
||||||
|
win = create_nhwindow(NHW_MENU);
|
||||||
|
start_menu(win, MENU_BEHAVE_STANDARD);
|
||||||
|
|
||||||
|
if (u_at(x, y))
|
||||||
|
K += there_cmd_menu_self(win, x, y, &act);
|
||||||
|
else if (next2u(x, y))
|
||||||
|
K += there_cmd_menu_next2u(win, x, y, mod, &act);
|
||||||
|
else
|
||||||
|
K += there_cmd_menu_far(win, x, y, mod);
|
||||||
|
K += there_cmd_menu_common(win, x, y, mod, &act);
|
||||||
|
|
||||||
|
if (!K) {
|
||||||
|
/* no menu options, try to move */
|
||||||
|
if (next2u(x, y) && !test_move(u.ux, u.uy, dx, dy, TEST_MOVE))
|
||||||
|
cmdq_add_ec(move_funcs[dir][MV_WALK]);
|
||||||
|
else if (flags.travelcmd) {
|
||||||
|
iflags.travelcc.x = u.tx = x;
|
||||||
|
iflags.travelcc.y = u.ty = y;
|
||||||
|
cmdq_add_ec(dotravel_target);
|
||||||
|
}
|
||||||
|
npick = 0;
|
||||||
|
ch = '\0';
|
||||||
|
} else if ((K == 1) && (act != MCMD_NOTHING)) {
|
||||||
|
destroy_nhwindow(win);
|
||||||
|
act_on_act(act, x, y, dx, dy, dir);
|
||||||
|
return '\0';
|
||||||
|
} else {
|
||||||
|
end_menu(win, "What do you want to do?");
|
||||||
|
npick = select_menu(win, PICK_ONE, &picks);
|
||||||
|
ch = '\033';
|
||||||
|
}
|
||||||
|
destroy_nhwindow(win);
|
||||||
|
if (npick > 0) {
|
||||||
|
act = picks->item.a_int;
|
||||||
|
|
||||||
|
free((genericptr_t) picks);
|
||||||
|
|
||||||
|
act_on_act(act, x, y, dx, dy, dir);
|
||||||
return '\0';
|
return '\0';
|
||||||
}
|
}
|
||||||
return ch;
|
return ch;
|
||||||
|
|||||||
Reference in New Issue
Block a user