offer choice of actions to perform at adjacent location ; a few choices can be farther away */
| 4840 | /* offer choice of actions to perform at adjacent location <x,y>; |
| 4841 | a few choices can be farther away */ |
| 4842 | staticfn char |
| 4843 | there_cmd_menu(coordxy x, coordxy y, int mod) |
| 4844 | { |
| 4845 | winid win; |
| 4846 | char ch = '\0'; |
| 4847 | int npick = 0, K = 0; |
| 4848 | menu_item *picks = (menu_item *) 0; |
| 4849 | /*int dx = sgn(x - u.ux), dy = sgn(y - u.uy);*/ |
| 4850 | coordxy dx = x - u.ux, dy = y - u.uy; |
| 4851 | int act = MCMD_NOTHING; |
| 4852 | |
| 4853 | win = create_nhwindow(NHW_MENU); |
| 4854 | start_menu(win, MENU_BEHAVE_STANDARD); |
| 4855 | |
| 4856 | if (u_at(x, y)) |
| 4857 | K += there_cmd_menu_self(win, x, y, &act); |
| 4858 | else if (next2u(x, y)) |
| 4859 | K += there_cmd_menu_next2u(win, x, y, mod, &act); |
| 4860 | else |
| 4861 | K += there_cmd_menu_far(win, x, y, mod); |
| 4862 | K += there_cmd_menu_common(win, x, y, mod, &act); |
| 4863 | |
| 4864 | if (!K) { |
| 4865 | /* no menu options, try to move */ |
| 4866 | if (next2u(x, y) && test_move(u.ux, u.uy, dx, dy, TEST_MOVE)) { |
| 4867 | int dir = xytodir(dx, dy); |
| 4868 | |
| 4869 | cmdq_add_ec(CQ_CANNED, move_funcs[dir][MV_WALK]); |
| 4870 | } else if (flags.travelcmd) { |
| 4871 | iflags.travelcc.x = u.tx = x; |
| 4872 | iflags.travelcc.y = u.ty = y; |
| 4873 | cmdq_add_ec(CQ_CANNED, dotravel_target); |
| 4874 | } |
| 4875 | npick = 0; |
| 4876 | ch = '\0'; |
| 4877 | } else if (K == 1 && act != MCMD_NOTHING && act != MCMD_TRAVEL) { |
| 4878 | destroy_nhwindow(win); |
| 4879 | |
| 4880 | act_on_act(act, dx, dy); |
| 4881 | return '\0'; |
| 4882 | } else { |
| 4883 | end_menu(win, "What do you want to do?"); |
| 4884 | npick = select_menu(win, PICK_ONE, &picks); |
| 4885 | ch = '\033'; |
| 4886 | } |
| 4887 | destroy_nhwindow(win); |
| 4888 | if (npick > 0) { |
| 4889 | act = picks->item.a_int; |
| 4890 | free((genericptr_t) picks); |
| 4891 | |
| 4892 | act_on_act(act, dx, dy); |
| 4893 | return '\0'; |
| 4894 | } |
| 4895 | return ch; |
| 4896 | } |
| 4897 | |
| 4898 | staticfn char |
| 4899 | here_cmd_menu(void) |
no test coverage detected