From: Pasi Kallinen Date: Tue, 10 Oct 2017 13:49:07 +0000 (+0300) Subject: Add context menu for the location next to you X-Git-Tag: NetHack-3.6.1_RC01~291 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f495a1ee3dd4fad7e9615e374f197ed43e20c1d;p=nethack Add context menu for the location next to you --- diff --git a/src/cmd.c b/src/cmd.c index 4c8372115..195f492a9 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -184,6 +184,7 @@ static coord clicklook_cc; STATIC_DCL void FDECL(add_herecmd_menuitem, (winid, int NDECL((*)), const char *)); STATIC_DCL char FDECL(here_cmd_menu, (BOOLEAN_P)); +STATIC_DCL char FDECL(there_cmd_menu, (int, int)); STATIC_DCL char *NDECL(parse); STATIC_DCL void FDECL(show_direction_keys, (winid, CHAR_P, BOOLEAN_P)); STATIC_DCL boolean FDECL(help_dir, (CHAR_P, int, const char *)); @@ -4688,6 +4689,46 @@ const char *text; } } +STATIC_OVL char +there_cmd_menu(x, y) +int x, y; +{ + winid win; + anything any; + char ch; + char buf[BUFSZ]; + schar typ = levl[x][y].typ; + int npick; + menu_item *picks = (menu_item *) 0; + struct trap *ttmp; + + win = create_nhwindow(NHW_MENU); + start_menu(win); + + if (IS_DOOR(typ)) { + int dm = levl[x][y].doormask; + if ((dm & (D_CLOSED|D_LOCKED))) { + add_herecmd_menuitem(win, dokick, "Kick the door"); + add_herecmd_menuitem(win, doopen, "Open the door"); + } else if ((dm & D_ISOPEN)) { + add_herecmd_menuitem(win, doclose, "Close the door"); + } + } + + if (typ <= SCORR) + add_herecmd_menuitem(win, dosearch, "Search for secret doors"); + + end_menu(win, "What do you want to do?"); + npick = select_menu(win, PICK_ONE, &picks); + destroy_nhwindow(win); + if (npick > 0) { + ch = cmd_from_func(picks->item.a_void); + free((genericptr_t)picks); + return ch; + } + return '\0'; +} + STATIC_OVL char here_cmd_menu(doit) boolean doit; @@ -4857,6 +4898,13 @@ int x, y, mod; && !test_move(u.ux, u.uy, x, y, TEST_MOVE)) { cmd[1] = Cmd.dirchars[dir]; cmd[2] = '\0'; + if (iflags.herecmd_menu) { + cmd[0] = there_cmd_menu(u.ux + x, u.uy + y); + if (cmd[0] == '\0') + cmd[1] = '\0'; + return cmd; + } + if (IS_DOOR(levl[u.ux + x][u.uy + y].typ)) { /* slight assistance to the player: choose kick/open for them */