/** * Target command */ void textui_target(void) { if (target_set_interactive(TARGET_KILL, -1, -1)) msg("Target Selected."); else msg("Target Aborted."); }
/** * Hack -- Teleport to the target. Oangband asks for a target after * the command. */ static void do_cmd_wiz_bamf(void) { feature_type *f_ptr; /* target starts at player. */ s16b ny = 0; s16b nx = 0; /* Use the targeting function. */ if (!target_set_interactive(TARGET_LOOK, -1, -1)) return; /* grab the target coords. */ target_get(&nx, &ny); /* Test for passable terrain. */ f_ptr = &f_info[cave_feat[ny][nx]]; if (!tf_has(f_ptr->flags, TF_PASSABLE)) { msg("The square you are aiming for is impassable."); } /* The simple act of controlled teleport. */ else teleport_player_to(ny, nx, TRUE); }
/* * Look command */ void do_cmd_look(void) { /* Look around */ if (target_set_interactive(TARGET_LOOK)) { msg_print("Target Selected."); } }
/* * Look command */ void do_cmd_look(void) { if (!character_dungeon) return; /* Look around */ if (target_set_interactive(TARGET_LOOK, -1, -1)) { message("Target Selected."); p_ptr->redraw |= (PR_SIDEBAR_MON); redraw_stuff(); } }
/* * Target command */ void do_cmd_target(void) { /* Target set */ if (target_set_interactive(TARGET_KILL)) { msg_print("Target Selected."); } /* Target aborted */ else { msg_print("Target Aborted."); } }
/** * Hack -- Teleport to the target. Oangband asks for a target after * the command. */ static void do_cmd_wiz_bamf(void) { /* target starts at player. */ s16b ny = 0; s16b nx = 0; /* Use the targeting function. */ if (!target_set_interactive(TARGET_LOOK, -1, -1)) return; /* grab the target coords. */ target_get(&nx, &ny); /* Test for passable terrain. */ if (!cave_passable_bold(ny, nx)) { msg_print("The square you are aiming for is impassable."); } /* The simple act of controlled teleport. */ else teleport_player_to(ny, nx, TRUE); }
int context_menu_cave(int cy, int cx, int adjacent, int mx, int my) { menu_type *m; rect_region r; int selected; char *labels; cave_type *c_ptr = area(cx,cy); pcave_type *pc_ptr = parea(cx,cy); feature_type *feat; object_type *o_ptr; /* paranoia */ if (!in_boundsp(cx,cy)) return 0; m = menu_dynamic_new(); if (!m) { return 0; } labels = (char*)string_make(lower_case); m->selections = labels; feat = &(f_info[c_ptr->feat]); menu_dynamic_add_label(m, "Look At", 'l', 1, labels); if (c_ptr->m_idx) { menu_dynamic_add_label(m, "Recall Info", '/', 18, labels); } menu_dynamic_add_label(m, "Use Item On", 'u', 2, labels); if (player_can_cast()) { menu_dynamic_add_label(m, "Cast On", 'm', 3, labels); } if (adjacent) { if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml) { menu_dynamic_add_label(m, "Attack", '+', 4, labels); } else { menu_dynamic_add_label(m, "Alter", '+', 4, labels); } if (c_ptr->o_idx) { o_ptr = chest_check(cx,cy); if (o_ptr && o_ptr->pval) { //if (!squelch_item_ok(o_ptr)) { if (object_known_p(o_ptr)) { if (chest_traps[o_ptr->pval]) { menu_dynamic_add_label(m, "Disarm Chest", 'D', 5, labels); menu_dynamic_add_label(m, "Open Chest", 'o', 8, labels); } else { menu_dynamic_add_label(m, "Open Disarmed Chest", 'o', 8, labels); } } else { menu_dynamic_add_label(m, "Open Chest", 'o', 8, labels); } //} } } if (is_visible_trap(c_ptr)) { menu_dynamic_add_label(m, "Disarm", 'D', 5, labels); menu_dynamic_add_label(m, "Jump Onto", 'W', 6, labels); } if (pc_ptr->feat) { if ((feat->flags & FF_CLOSEABLE) || ((feat->flags & FF_BROKEN) && (feat->flags & FF_DOOR))) { menu_dynamic_add_label(m, "Close", 'c', 7, labels); } if (feat->flags & FF_CLOSED) { menu_dynamic_add_label(m, "Open", 'o', 8, labels); menu_dynamic_add_label(m, "Bash Open", 'B', 9, labels); menu_dynamic_add_label(m, "Lock", 'D', 5, labels); menu_dynamic_add_label(m, "Jam", 'j', 10, labels); } if (feat->flags & FF_DIG) { menu_dynamic_add_label(m, "Tunnel", 'T', 11, labels); } } menu_dynamic_add_label(m, "Search", 's', 12, labels); menu_dynamic_add_label(m, "Walk Towards", ';', 14, labels); } else { menu_dynamic_add_label(m, "Pathfind To", ',', 13, labels); menu_dynamic_add_label(m, "Walk Towards", ';', 14, labels); menu_dynamic_add_label(m, "Run Towards", '.', 15, labels); } if (player_can_fire()) { menu_dynamic_add_label(m, "Fire On", 'f', 16, labels); } if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml) { if (is_pet(&(m_list[c_ptr->m_idx]))) { menu_dynamic_add_label(m, "Pet Commands", 'p', 19, labels); } } menu_dynamic_add_label(m, "Throw To", 'v', 17, labels); /* work out display region */ r.width = menu_dynamic_longest_entry(m) + 3 + 2; /* +3 for tag, 2 for pad */ if (mx > Term->wid - r.width - 1) { r.col = Term->wid - r.width - 1; } else { r.col = mx + 1; } r.page_rows = m->count; if (my > Term->hgt - r.page_rows - 1) { if (my - r.page_rows - 1 <= 0) { /* menu has too many items, so put in upper right corner */ r.row = 1; r.col = Term->wid - r.width - 1; } else { r.row = Term->hgt - r.page_rows - 1; } } else { r.row = my + 1; } /* Hack -- no flush needed */ msg_flag = FALSE; screen_save(); button_backup_all(TRUE); /* if there is a monster, draw a target path, which will be erased by the * screen load below */ if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml) { sint path_n; coord path_g[2*MAX_RANGE+1]; /* Find the path. */ path_n = project_path(path_g, p_ptr->px, p_ptr->py, cx, cy, PROJECT_THRU); /* Draw the path. */ draw_path(path_n, path_g, NULL, NULL, p_ptr->px, p_ptr->py); } menu_layout(m, &r); rect_region_erase_bordered(&r); /* display the prompt for the context menu */ target_look_grid_prompt(0, 0, cx, cy, format("($UEnter to select command$Y\n$V, $UESC$ to cancel$Y%c$V) You see", ESCAPE)); /* Hack - redraw stuff to show the target health bar */ health_redraw(); /* show the menu and pick from it */ selected = menu_dynamic_select(m); menu_dynamic_free(m); string_free(labels); button_restore(); screen_load(); if (selected == 1) { /* look at the spot */ if (target_set_interactive(TARGET_LOOK, cx, cy)) { msgf("Target Selected."); } } else if (selected == 2) { /* use an item on the spot */ p_ptr->cmd.dir = 5; p_ptr->cmd.cmd = 'u'; repeat_check(); do_cmd_use(); /*cmd_insert(CMD_USE_AIMED); cmd_set_arg_target(cmd_get_top(), 1, DIR_TARGET);*/ } else if (selected == 3) { /* cast a spell on the spot */ p_ptr->cmd.dir = 5; p_ptr->cmd.cmd = 'm'; repeat_check(); do_cmd_cast_wrapper(); /*if (textui_obj_cast_ret() >= 0) { cmd_set_arg_target(cmd_get_top(), 1, DIR_TARGET); }*/ } else if (selected == 4) { /* attack a spot adjacent to the player */ p_ptr->cmd.dir = coords_to_dir(cx, cy); p_ptr->cmd.arg = 16; p_ptr->cmd.cmd = '+'; repeat_check(); do_cmd_alter(); /*cmd_insert(CMD_ALTER); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(cy,cx));*/ } else if (selected == 5) { /* disarm an adjacent trap or chest */ p_ptr->cmd.dir = coords_to_dir(cx, cy); p_ptr->cmd.arg = 1; p_ptr->cmd.cmd = 'D'; repeat_check(); do_cmd_disarm(); /*cmd_insert(CMD_DISARM); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(cy,cx));*/ } else if (selected == 6) { /* walk onto an adjacent spot even if there is a trap there */ bool orig_disarm = easy_disarm; easy_disarm = always_pickup; p_ptr->cmd.dir = coords_to_dir(cx, cy); p_ptr->cmd.arg = 1; p_ptr->cmd.cmd = 'W'; repeat_check(); do_cmd_walk(always_pickup); easy_disarm = orig_disarm; /*cmd_insert(CMD_JUMP); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(cy,cx));*/ } else if (selected == 7) { /* close a door */ p_ptr->cmd.dir = coords_to_dir(cx, cy); /*p_ptr->cmd.arg = 1;*/ p_ptr->cmd.cmd = 'c'; repeat_check(); do_cmd_close(); /*cmd_insert(CMD_CLOSE); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(cy,cx));*/ } else if (selected == 8) { /* open a door or chest */ p_ptr->cmd.dir = coords_to_dir(cx, cy); /*p_ptr->cmd.arg = 1;*/ p_ptr->cmd.cmd = 'o'; repeat_check(); do_cmd_open(); /*cmd_insert(CMD_OPEN); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(cy,cx));*/ } else if (selected == 9) { /* bash a door */ p_ptr->cmd.dir = coords_to_dir(cx, cy); /*p_ptr->cmd.arg = 1;*/ p_ptr->cmd.cmd = 'o'; repeat_check(); do_cmd_open(); /*p_ptr->cmd.cmd = 'B'; do_cmd_bash();*/ /*cmd_insert(CMD_BASH); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(cy,cx));*/ } else if (selected == 10) { /* jam a door */ p_ptr->cmd.dir = coords_to_dir(cx, cy); /*p_ptr->cmd.arg = 1;*/ p_ptr->cmd.cmd = 'j'; repeat_check(); do_cmd_spike(); /*cmd_insert(CMD_JAM); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(cy,cx));*/ } else if (selected == 11) { /* Tunnel in a direction */ p_ptr->cmd.dir = coords_to_dir(cx, cy); p_ptr->cmd.arg = 16; p_ptr->cmd.cmd = 'T'; repeat_check(); do_cmd_tunnel(); /*cmd_insert(CMD_TUNNEL); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(cy,cx));*/ } else if (selected == 12) { /* Search */ /*p_ptr->cmd.arg = 1;*/ p_ptr->cmd.cmd = 's'; repeat_check(); do_cmd_search(); /*cmd_insert(CMD_SEARCH);*/ } else if (selected == 13) { /* pathfind to the spot */ /*p_ptr->cmd.arg = 16;*/ p_ptr->cmd.cmd = ','; do_cmd_pathfind(cx,cy); /*cmd_insert(CMD_PATHFIND); cmd_set_arg_point(cmd_get_top(), 0, cx, cy);*/ } else if (selected == 14) { /* walk towards the spot */ p_ptr->cmd.dir = coords_to_dir(cx, cy); p_ptr->cmd.cmd = ';'; repeat_check(); do_cmd_walk(always_pickup); /*cmd_insert(CMD_WALK); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(cy,cx));*/ } else if (selected == 15) { /* run towards the spot */ p_ptr->cmd.dir = coords_to_dir(cx, cy); p_ptr->cmd.cmd = '.'; repeat_check(); do_cmd_run(); /*cmd_insert(CMD_RUN); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(cy,cx));*/ } else if (selected == 16) { /* Fire ammo towards the spot */ p_ptr->cmd.dir = 5; p_ptr->cmd.cmd = 'f'; repeat_check(); do_cmd_fire(); /*cmd_insert(CMD_FIRE); cmd_set_arg_target(cmd_get_top(), 1, DIR_TARGET);*/ } else if (selected == 17) { /* throw an item towards the spot */ p_ptr->cmd.dir = 5; p_ptr->cmd.cmd = 'v'; repeat_check(); do_cmd_throw(); /*cmd_insert(CMD_THROW); cmd_set_arg_target(cmd_get_top(), 1, DIR_TARGET);*/ } else if (selected == 18) { /* recall monster Info */ monster_type *m_ptr = &m_list[c_ptr->m_idx]; if (m_ptr) { /* Save screen */ screen_save(); button_backup_all(TRUE); /* Recall on screen */ screen_roff_mon(m_ptr->r_idx, 0); /* wait for a key or mouse press */ inkey(); /* Load screen */ button_restore(); screen_load(); } } else if (selected == 19) { /* issue a pet command */ p_ptr->cmd.cmd = 'p'; repeat_check(); do_cmd_pet(); } return 1; }
int context_menu_cave(struct cave *c, int y, int x, int adjacent, int mx, int my) { menu_type *m; region r; int selected; char *labels; bool allowed = TRUE; int mode = OPT(rogue_like_commands) ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG; unsigned char cmdkey; m = menu_dynamic_new(); if (!m) { return 0; } labels = string_make(lower_case); m->selections = labels; /* Looking has different keys, but we don't have a way to look them up (see cmd-process.c). */ cmdkey = (mode == KEYMAP_MODE_ORIG) ? 'l' : 'x'; menu_dynamic_add_label(m, "Look At", cmdkey, MENU_VALUE_LOOK, labels); if (c->m_idx[y][x]) { /* '/' is used for recall in both keymaps. */ menu_dynamic_add_label(m, "Recall Info", '/', MENU_VALUE_RECALL, labels); } ADD_LABEL("Use Item On", CMD_USE_ANY, MN_ROW_VALID); if (player_can_cast(p_ptr, FALSE)) { ADD_LABEL("Cast On", CMD_CAST, MN_ROW_VALID); } if (adjacent) { ADD_LABEL((c->m_idx[y][x]) ? "Attack" : "Alter", CMD_ALTER, MN_ROW_VALID); if (c->o_idx[y][x]) { s16b o_idx = chest_check(y,x, CHEST_ANY); if (o_idx) { object_type *o_ptr = object_byid(o_idx); if (!squelch_item_ok(o_ptr)) { if (object_is_known(o_ptr)) { if (is_locked_chest(o_ptr)) { ADD_LABEL("Disarm Chest", CMD_DISARM, MN_ROW_VALID); ADD_LABEL("Open Chest", CMD_OPEN, MN_ROW_VALID); } else { ADD_LABEL("Open Disarmed Chest", CMD_OPEN, MN_ROW_VALID); } } else { ADD_LABEL("Open Chest", CMD_OPEN, MN_ROW_VALID); } } } } if (cave_istrap(c, y, x)) { ADD_LABEL("Disarm", CMD_DISARM, MN_ROW_VALID); ADD_LABEL("Jump Onto", CMD_JUMP, MN_ROW_VALID); } if (cave_isopendoor(c, y, x)) { ADD_LABEL("Close", CMD_CLOSE, MN_ROW_VALID); } else if (cave_iscloseddoor(c, y, x)) { ADD_LABEL("Open", CMD_OPEN, MN_ROW_VALID); ADD_LABEL("Lock", CMD_DISARM, MN_ROW_VALID); } else if (cave_isdiggable(c, y, x)) { ADD_LABEL("Tunnel", CMD_TUNNEL, MN_ROW_VALID); } ADD_LABEL("Search", CMD_SEARCH, MN_ROW_VALID); ADD_LABEL("Walk Towards", CMD_WALK, MN_ROW_VALID); } else { /* ',' is used for squelch in rogue keymap, so we'll just swap letters. */ cmdkey = (mode == KEYMAP_MODE_ORIG) ? ',' : '.'; menu_dynamic_add_label(m, "Pathfind To", cmdkey, CMD_PATHFIND, labels); ADD_LABEL("Walk Towards", CMD_WALK, MN_ROW_VALID); ADD_LABEL("Run Towards", CMD_RUN, MN_ROW_VALID); } if (player_can_fire(p_ptr, FALSE)) { ADD_LABEL("Fire On", CMD_FIRE, MN_ROW_VALID); } ADD_LABEL("Throw To", CMD_THROW, MN_ROW_VALID); /* work out display region */ r.width = (int)menu_dynamic_longest_entry(m) + 3 + 2; /* +3 for tag, 2 for pad */ if (mx > Term->wid - r.width - 1) { r.col = Term->wid - r.width - 1; } else { r.col = mx + 1; } r.page_rows = m->count; if (my > Term->hgt - r.page_rows - 1) { if (my - r.page_rows - 1 <= 0) { /* menu has too many items, so put in upper right corner */ r.row = 1; r.col = Term->wid - r.width - 1; } else { r.row = Term->hgt - r.page_rows - 1; } } else { r.row = my + 1; } /* Hack -- no flush needed */ msg_flag = FALSE; screen_save(); menu_layout(m, &r); region_erase_bordered(&r); if (p_ptr->timed[TMD_IMAGE]) { prt("(Enter to select command, ESC to cancel) You see something strange:", 0, 0); } else if (c->m_idx[y][x]) { char m_name[80]; monster_type *m_ptr = cave_monster_at(c, y, x); /* Get the monster name ("a kobold") */ monster_desc(m_name, sizeof(m_name), m_ptr, MDESC_IND_VIS); prt(format("(Enter to select command, ESC to cancel) You see %s:", m_name), 0, 0); } else if (c->o_idx[y][x] && !squelch_item_ok(object_byid(c->o_idx[y][x]))) { char o_name[80]; /* Get the single object in the list */ object_type *o_ptr = object_byid(c->o_idx[y][x]); /* Obtain an object description */ object_desc(o_name, sizeof (o_name), o_ptr, ODESC_PREFIX | ODESC_FULL); prt(format("(Enter to select command, ESC to cancel) You see %s:", o_name), 0, 0); } else { /* Feature (apply mimic) */ const char *name = cave_apparent_name(c, p_ptr, y, x); /* Hack -- special introduction for store doors */ if (cave_isshop(cave, y, x)) { prt(format("(Enter to select command, ESC to cancel) You see the entrance to the %s:", name), 0, 0); } else { prt(format("(Enter to select command, ESC to cancel) You see %s %s:", (is_a_vowel(name[0])) ? "an" : "a", name), 0, 0); } } selected = menu_dynamic_select(m); menu_dynamic_free(m); string_free(labels); screen_load(); cmdkey = cmd_lookup_key(selected, mode); /* Check the command to see if it is allowed. */ switch (selected) { case -1: /* User cancelled the menu. */ return 3; case MENU_VALUE_LOOK: case MENU_VALUE_RECALL: case CMD_PATHFIND: allowed = TRUE; break; case CMD_SEARCH: case CMD_ALTER: case CMD_DISARM: case CMD_JUMP: case CMD_CLOSE: case CMD_OPEN: case CMD_TUNNEL: case CMD_WALK: case CMD_RUN: case CMD_CAST: case CMD_FIRE: case CMD_THROW: case CMD_USE_ANY: /* Only check for ^ inscriptions, since we don't have an object selected (if we need one). */ allowed = key_confirm_command(cmdkey); break; default: /* Invalid command; prevent anything from happening. */ bell("Invalid context menu command."); allowed = FALSE; break; } if (!allowed) return 1; /* Perform the command. */ switch (selected) { case MENU_VALUE_LOOK: /* look at the spot */ if (target_set_interactive(TARGET_LOOK, x, y)) { msg("Target Selected."); } break; case MENU_VALUE_RECALL: { /* recall monster Info */ monster_type *m_ptr = cave_monster_at(c, y, x); if (m_ptr) { monster_lore *lore = get_lore(m_ptr->race); lore_show_interactive(m_ptr->race, lore); } } break; case CMD_SEARCH: cmd_insert(selected); break; case CMD_PATHFIND: cmd_insert(selected); cmd_set_arg_point(cmd_get_top(), 0, x, y); break; case CMD_ALTER: case CMD_DISARM: case CMD_JUMP: case CMD_CLOSE: case CMD_OPEN: case CMD_TUNNEL: case CMD_WALK: case CMD_RUN: cmd_insert(selected); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(y,x)); break; case CMD_CAST: if (textui_obj_cast_ret() >= 0) { cmd_set_arg_target(cmd_get_top(), 1, DIR_TARGET); } break; case CMD_FIRE: case CMD_THROW: case CMD_USE_ANY: cmd_insert(selected); cmd_set_arg_target(cmd_get_top(), 1, DIR_TARGET); break; default: break; } return 1; }
int context_menu_player(int mx, int my) { menu_type *m; region r; int selected; char *labels; bool allowed = TRUE; int mode = OPT(rogue_like_commands) ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG; unsigned char cmdkey; m = menu_dynamic_new(); if (!m) { return 0; } labels = string_make(lower_case); m->selections = labels; ADD_LABEL("Use", CMD_USE_ANY, MN_ROW_VALID); /* if player can cast, add casting option */ if (player_can_cast(p_ptr, FALSE)) { ADD_LABEL("Cast", CMD_CAST, MN_ROW_VALID); } /* if player is on stairs add option to use them */ if (cave_isupstairs(cave, p_ptr->py, p_ptr->px)) { ADD_LABEL("Go Up", CMD_GO_UP, MN_ROW_VALID); } else if (cave_isdownstairs(cave, p_ptr->py, p_ptr->px)) { ADD_LABEL("Go Down", CMD_GO_DOWN, MN_ROW_VALID); } ADD_LABEL("Search", CMD_SEARCH, MN_ROW_VALID); /* Looking has different keys, but we don't have a way to look them up (see cmd-process.c). */ cmdkey = (mode == KEYMAP_MODE_ORIG) ? 'l' : 'x'; menu_dynamic_add_label(m, "Look", cmdkey, MENU_VALUE_LOOK, labels); /* 'R' is used for resting in both keymaps. */ menu_dynamic_add_label(m, "Rest", 'R', MENU_VALUE_REST, labels); /* 'i' is used for inventory in both keymaps. */ menu_dynamic_add_label(m, "Inventory", 'i', MENU_VALUE_INVENTORY, labels); /* if object under player add pickup option */ if (cave->o_idx[p_ptr->py][p_ptr->px]) { object_type *o_ptr = object_byid(cave->o_idx[p_ptr->py][p_ptr->px]); if (!squelch_item_ok(o_ptr)) { menu_row_validity_t valid; /* 'f' isn't in rogue keymap, so we can use it here. */ menu_dynamic_add_label(m, "Floor", 'f', MENU_VALUE_FLOOR, labels); valid = (inven_carry_okay(o_ptr)) ? MN_ROW_VALID : MN_ROW_INVALID; ADD_LABEL("Pick up", CMD_PICKUP, valid); } } /* 'C' is used for the character sheet in both keymaps. */ menu_dynamic_add_label(m, "Character", 'C', MENU_VALUE_CHARACTER, labels); /* XXX Don't show the keymap line until the keymap list is implemented, to * avoid confusion as to what should be there */ /*menu_dynamic_add(m, "Keymaps", 10);*/ if (!OPT(center_player)) { menu_dynamic_add_label(m, "^Center Map", 'L', MENU_VALUE_CENTER_MAP, labels); } menu_dynamic_add_label(m, "Other", ' ', MENU_VALUE_OTHER, labels); /* work out display region */ r.width = (int)menu_dynamic_longest_entry(m) + 3 + 2; /* +3 for tag, 2 for pad */ if (mx > Term->wid - r.width - 1) { r.col = Term->wid - r.width - 1; } else { r.col = mx + 1; } r.page_rows = m->count; if (my > Term->hgt - r.page_rows - 1) { if (my - r.page_rows - 1 <= 0) { /* menu has too many items, so put in upper right corner */ r.row = 1; r.col = Term->wid - r.width - 1; } else { r.row = Term->hgt - r.page_rows - 1; } } else { r.row = my + 1; } /* Hack -- no flush needed */ msg_flag = FALSE; screen_save(); menu_layout(m, &r); region_erase_bordered(&r); prt("(Enter to select, ESC) Command:", 0, 0); selected = menu_dynamic_select(m); menu_dynamic_free(m); string_free(labels); screen_load(); cmdkey = cmd_lookup_key(selected, mode); /* Check the command to see if it is allowed. */ switch(selected) { case -1: /* User cancelled the menu. */ return 3; case CMD_USE_ANY: case CMD_CAST: case CMD_SEARCH: case CMD_GO_UP: case CMD_GO_DOWN: case CMD_PICKUP: /* Only check for ^ inscriptions, since we don't have an object selected (if we need one). */ allowed = key_confirm_command(cmdkey); break; case MENU_VALUE_REST: allowed = key_confirm_command('R'); break; case MENU_VALUE_INVENTORY: case MENU_VALUE_LOOK: case MENU_VALUE_CHARACTER: case MENU_VALUE_OTHER: case MENU_VALUE_FLOOR: case MENU_VALUE_CENTER_MAP: allowed = TRUE; break; default: /* Invalid command; prevent anything from happening. */ bell("Invalid context menu command."); allowed = FALSE; break; } if (!allowed) return 1; /* Perform the command. */ switch(selected) { case CMD_USE_ANY: case CMD_CAST: cmdkey = cmd_lookup_key(selected, mode); Term_keypress(cmdkey, 0); break; case CMD_SEARCH: case CMD_GO_UP: case CMD_GO_DOWN: case CMD_PICKUP: cmd_insert(selected); break; case MENU_VALUE_REST: Term_keypress('R', 0); break; case MENU_VALUE_INVENTORY: Term_keypress('i', 0); break; case MENU_VALUE_LOOK: if (target_set_interactive(TARGET_LOOK, p_ptr->px, p_ptr->py)) { msg("Target Selected."); } break; case MENU_VALUE_CHARACTER: Term_keypress('C', 0); break; case MENU_VALUE_OTHER: context_menu_player_2(mx, my); break; case MENU_VALUE_FLOOR: context_menu_player_display_floor(); break; case MENU_VALUE_CENTER_MAP: do_cmd_center_map(); break; default: break; } return 1; }
/* * Get an "aiming direction" (1,2,3,4,6,7,8,9 or 5) from the user. * * Return TRUE if a direction was chosen, otherwise return FALSE. * * The direction "5" is special, and means "use current target". * * This function tracks and uses the "global direction", and uses * that as the "desired direction", if it is set. * * Note that "Force Target", if set, will pre-empt user interaction, * if there is a usable target already set. * * Currently this function applies confusion directly. */ bool get_aim_dir(int *dp) { /* Global direction */ int dir = 0; ui_event_data ke; cptr p; /* Initialize */ (*dp) = 0; /* Hack -- auto-target if requested */ if (OPT(use_old_target) && target_okay() && !dir) dir = 5; /* Ask until satisfied */ while (!dir) { /* Choose a prompt */ if (!target_okay()) p = "Direction ('*' or <click> to target, \"'\" for closest, Escape to cancel)? "; else p = "Direction ('5' for target, '*' or <click> to re-target, Escape to cancel)? "; /* Get a command (or Cancel) */ if (!get_com_ex(p, &ke)) break; if (ke.type == EVT_MOUSE) { if (target_set_interactive (TARGET_KILL, KEY_GRID_X(ke), KEY_GRID_Y(ke))) dir = 5; } else if (ke.type == EVT_KBRD) { if (ke.key == '*') { /* Set new target, use target if legal */ if (target_set_interactive(TARGET_KILL, -1, -1)) dir = 5; } else if (ke.key == '\'') { /* Set to closest target */ if (target_set_closest(TARGET_KILL)) dir = 5; } else if (ke.key == 't' || ke.key == '5' || ke.key == '0' || ke.key == '.') { if (target_okay()) dir = 5; } else { /* Possible direction */ int keypresses_handled = 0; while (ke.key != 0) { int this_dir; /* XXX Ideally show and move the cursor here to indicate * the currently "Pending" direction. XXX */ this_dir = target_dir(ke.key); if (this_dir) dir = dir_transitions[dir][this_dir]; else break; if (lazymove_delay == 0 || ++keypresses_handled > 1) break; /* See if there's a second keypress within the defined * period of time. */ inkey_scan = lazymove_delay; ke = inkey_ex(); } } } /* Error */ if (!dir) bell("Illegal aim direction!"); } /* No direction */ if (!dir) return (FALSE); /* Save direction */ (*dp) = dir; /* Check for confusion */ if (p_ptr->timed[TMD_CONFUSED]) { /* Random direction */ dir = ddd[randint0(8)]; } /* Notice confusion */ if ((*dp) != dir) { /* Warn the user */ msg_print("You are confused."); } /* Save direction */ (*dp) = dir; /* A "valid" direction was entered */ return (TRUE); }
/** * Handle a textui mouseclick. */ static void textui_process_click(ui_event e) { int x, y; if (!OPT(mouse_movement)) return; y = KEY_GRID_Y(e); x = KEY_GRID_X(e); /* Check for a valid location */ if (!cave_in_bounds_fully(cave, y, x)) return; /* XXX show context menu here */ if ((p_ptr->py == y) && (p_ptr->px == x)) { if (e.mouse.mods & KC_MOD_SHIFT) { /* shift-click - cast magic */ if (e.mouse.button == 1) { textui_obj_cast(); } else if (e.mouse.button == 2) { Term_keypress('i',0); } } else if (e.mouse.mods & KC_MOD_CONTROL) { /* ctrl-click - use feature / use inventory item */ /* switch with default */ if (e.mouse.button == 1) { if (cave_isupstairs(cave, p_ptr->py, p_ptr->px)) cmd_insert(CMD_GO_UP); else if (cave_isdownstairs(cave, p_ptr->py, p_ptr->px)) cmd_insert(CMD_GO_DOWN); } else if (e.mouse.button == 2) { cmd_insert(CMD_USE_UNAIMED); } } else if (e.mouse.mods & KC_MOD_ALT) { /* alt-click - Search or show char screen */ /* XXX call a platform specific hook */ if (e.mouse.button == 1) { cmd_insert(CMD_SEARCH); } else if (e.mouse.button == 2) { Term_keypress('C',0); } } else { if (e.mouse.button == 1) { if (cave->o_idx[y][x]) { cmd_insert(CMD_PICKUP); } else { cmd_insert(CMD_HOLD); } } else if (e.mouse.button == 2) { // show a context menu context_menu_player(e.mouse.x, e.mouse.y); } } } else if (e.mouse.button == 1) { if (p_ptr->timed[TMD_CONFUSED]) { cmd_insert(CMD_WALK); } else { if (e.mouse.mods & KC_MOD_SHIFT) { /* shift-click - run */ cmd_insert(CMD_RUN); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(y,x)); /*if ((y-p_ptr->py >= -1) && (y-p_ptr->py <= 1) && (x-p_ptr->px >= -1) && (x-p_ptr->px <= 1)) { cmd_insert(CMD_JUMP); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(y,x)); } else { cmd_insert(CMD_RUN); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(y,x)); }*/ } else if (e.mouse.mods & KC_MOD_CONTROL) { /* control-click - alter */ cmd_insert(CMD_ALTER); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(y,x)); } else if (e.mouse.mods & KC_MOD_ALT) { /* alt-click - look */ if (target_set_interactive(TARGET_LOOK, x, y)) { msg("Target Selected."); } //cmd_insert(CMD_LOOK); //cmd_set_arg_point(cmd_get_top(), 0, y, x); } else { /* pathfind does not work well on trap detection borders, * so if the click is next to the player, force a walk step */ if ((y-p_ptr->py >= -1) && (y-p_ptr->py <= 1) && (x-p_ptr->px >= -1) && (x-p_ptr->px <= 1)) { cmd_insert(CMD_WALK); cmd_set_arg_direction(cmd_get_top(), 0, coords_to_dir(y,x)); } else { cmd_insert(CMD_PATHFIND); cmd_set_arg_point(cmd_get_top(), 0, y, x); } } } } else if (e.mouse.button == 2) { struct monster *m = cave_monster_at(cave, y, x); if (m && target_able(m)) { /* Set up target information */ monster_race_track(m->race); health_track(p_ptr, m); target_set_monster(m); } else { target_set_location(y,x); } if (e.mouse.mods & KC_MOD_SHIFT) { /* shift-click - cast spell at target */ if (textui_obj_cast_ret() >= 0) { cmd_set_arg_target(cmd_get_top(), 1, DIR_TARGET); } } else if (e.mouse.mods & KC_MOD_CONTROL) { /* control-click - fire at target */ cmd_insert(CMD_USE_AIMED); cmd_set_arg_target(cmd_get_top(), 1, DIR_TARGET); } else if (e.mouse.mods & KC_MOD_ALT) { /* alt-click - throw at target */ cmd_insert(CMD_THROW); cmd_set_arg_target(cmd_get_top(), 1, DIR_TARGET); } else { //msg("Target set."); /* see if the click was adjacent to the player */ if ((y-p_ptr->py >= -1) && (y-p_ptr->py <= 1) && (x-p_ptr->px >= -1) && (x-p_ptr->px <= 1)) { context_menu_cave(cave,y,x,1,e.mouse.x, e.mouse.y); } else { context_menu_cave(cave,y,x,0,e.mouse.x, e.mouse.y); } } } }
/* * Modify the dungeon */ void do_cmd_wiz_look(void) { /* Look around and modify things */ target_set_interactive(TARGET_WIZ, 0); }
/* * Get an "aiming direction" (1,2,3,4,6,7,8,9 or 5) from the user. * * Return TRUE if a direction was chosen, otherwise return FALSE. * * The direction "5" is special, and means "use current target". Also DIR_TARGET * * This function tracks and uses the "global direction", and uses * that as the "desired direction", if it is set. * * Note that "Force Target", if set, will pre-empt user interaction, * if there is a usable target already set. * * Currently this function applies confusion directly. */ bool get_aim_dir(int *dp, bool target_trap) { /* Global direction */ int dir = 0; int old_dir; bool done = FALSE; int mode = TARGET_QUIET; if (target_trap) mode |= TARGET_TRAP; else mode |= TARGET_KILL; if (*dp == DIR_CLOSEST) { if (target_set_closest(mode)) { return(TRUE); } } /* Initialize */ (*dp) = 0; /* Hack -- auto-target if requested */ if (use_old_target && target_okay() && !dir) dir = DIR_TARGET; else ui_update_message_label(color_string("Please select a target.", TERM_L_RED)); ui_targeting_show(MODE_TARGETING_AIMING); /* Ask until satisfied */ while (!dir && !done) { ui_show_cursor(p_ptr->py, p_ptr->px); /* Get a command (or Cancel) */ UserInput input = ui_get_input(); // Paranoia if (input.mode == INPUT_MODE_NONE) break; if ((input.key == Qt::Key_Escape) || (input.key == Qt::Key_X)) { break; } // Do nothing if (input.mode == INPUT_MODE_MOUSE_WHEEL) { continue; } // Skip interactive mode and directly choose target. if (input.mode == INPUT_MODE_MOUSE_DOUBLE_CLICK) { if (set_selected_target(mode, input.y, input.x)) dir = DIR_TARGET; else if (set_selected_target(TARGET_GRID, input.y, input.x)) dir = DIR_TARGET; continue; } if (input.mode == INPUT_MODE_MOUSE_SINGLE_CLICK) { /* Calculate approximate angle */ if (target_set_interactive(mode, input.x, input.y)) dir = DIR_TARGET; else done = TRUE; continue; } /* Analyze */ switch (input.key) { case Qt::Key_M: case Qt::Key_Asterisk: { /* Set new target, use target if legal */ int mode = TARGET_KILL; if (target_trap) mode |= TARGET_TRAP; if (target_set_interactive(mode, -1, -1)) dir = DIR_TARGET; else done = TRUE; continue; } case Qt::Key_C: case Qt::Key_Comma: { /* Set to closest target */ if (target_set_closest(TARGET_KILL)) { dir = DIR_CLOSEST; continue; } break; } case Qt::Key_Question: { do_cmd_list_targeting_commands(); continue; } case Qt::Key_H: case Qt::Key_5: case Qt::Key_Period: case Qt::Key_Clear: { /* Use current target, if set and legal */ if (target_okay()) dir = DIR_TARGET; break; } default: { /* Possible direction */ dir = target_dir(input); break; } } /* Error */ if (!dir) color_message("Illegal aim direction!", TERM_ORANGE); } ui_targeting_hide(); ui_show_cursor(-1, -1); ui_clear_message_label(); /* No direction */ if (!dir) return (FALSE); /* Save the direction */ old_dir = dir; /* Check for confusion */ if (p_ptr->timed[TMD_CONFUSED]) { /* Random direction */ dir = ddd[randint0(8)]; } /* Notice confusion */ if (old_dir != dir) { /* Warn the user */ message(QString("You are confused.")); } /* Save direction */ (*dp) = dir; /* A "valid" direction was entered */ return (TRUE); }
/** * Get an "aiming direction" (1,2,3,4,6,7,8,9 or 5) from the user. * * Return true if a direction was chosen, otherwise return false. * * The direction "5" is special, and means "use current target". * * This function tracks and uses the "global direction", and uses * that as the "desired direction", if it is set. * * Note that "Force Target", if set, will pre-empt user interaction, * if there is a usable target already set. */ bool textui_get_aim_dir(int *dp) { /* Global direction */ int dir = 0; ui_event ke; const char *p; /* Initialize */ (*dp) = 0; /* Hack -- auto-target if requested */ if (OPT(use_old_target) && target_okay() && !dir) dir = 5; /* Ask until satisfied */ while (!dir) { /* Choose a prompt */ if (!target_okay()) p = "Direction ('*' or <click> to target, \"'\" for closest, Escape to cancel)? "; else p = "Direction ('5' for target, '*' or <click> to re-target, Escape to cancel)? "; /* Get a command (or Cancel) */ if (!get_com_ex(p, &ke)) break; if (ke.type == EVT_MOUSE) { if (ke.mouse.button == 1) { if (target_set_interactive(TARGET_KILL, KEY_GRID_X(ke), KEY_GRID_Y(ke))) dir = 5; } else if (ke.mouse.button == 2) { break; } } else if (ke.type == EVT_KBRD) { if (ke.key.code == '*') { /* Set new target, use target if legal */ if (target_set_interactive(TARGET_KILL, -1, -1)) dir = 5; } else if (ke.key.code == '\'') { /* Set to closest target */ if (target_set_closest(TARGET_KILL)) dir = 5; } else if (ke.key.code == 't' || ke.key.code == '5' || ke.key.code == '0' || ke.key.code == '.') { if (target_okay()) dir = 5; } else { /* Possible direction */ int keypresses_handled = 0; while (ke.key.code != 0) { int this_dir; /* XXX Ideally show and move the cursor here to indicate * the currently "Pending" direction. XXX */ this_dir = target_dir(ke.key); if (this_dir) dir = dir_transitions[dir][this_dir]; else break; if (op_ptr->lazymove_delay == 0 || ++keypresses_handled > 1) break; /* See if there's a second keypress within the defined * period of time. */ inkey_scan = op_ptr->lazymove_delay; ke = inkey_ex(); } } } /* Error */ if (!dir) bell("Illegal aim direction!"); } /* No direction */ if (!dir) return (false); /* Save direction */ (*dp) = dir; /* A "valid" direction was entered */ return (true); }
// Select a monster from a list and place it in the dungeon. MakeFeatureDialog::MakeFeatureDialog(void) { int i; QPointer<QVBoxLayout> vlay = new QVBoxLayout; feat_choice = new QComboBox; QPointer<QLabel> feat_label = new QLabel(QString("<b><big>Please select a feature:</big></b>")); feat_label->setAlignment(Qt::AlignCenter); vlay->addWidget(feat_label); vlay->addStretch(); connect(feat_choice, SIGNAL(currentIndexChanged(int)), this, SLOT(update_feat_choice(int))); QPointer<QPushButton> close_button = new QPushButton(tr("&Close")); connect(close_button, SIGNAL(clicked()), this, SLOT(close())); int count = 0; feat_num = 0; for (i = 1; i < z_info->f_max; i++) { /* Get the feature */ feature_type *f_ptr = &f_info[i]; if (f_ptr->f_name.isEmpty()) continue; feat_choice->addItem(QString("%1") .arg(i)); feat_choice->setItemText(count++, get_feat_display_name(i)); } vlay->addWidget(feat_choice); vlay->addStretch(); vlay->addWidget(close_button); setLayout(vlay); setWindowTitle(tr("Make Feature")); this->exec(); // find the feature count = 0; for (i = 1; i < z_info->f_max; i++) { /* Get the feature */ feature_type *f_ptr = &f_info[i]; if (f_ptr->f_name.isEmpty()) continue; // Found the match if (count == feat_num) break; count++; } /* Pick a location */ if (!target_set_interactive(TARGET_GRID, -1, -1)) return; /* Paranoia */ if (!p_ptr->target_set) return; int y = p_ptr->target_row; int x = p_ptr->target_col; /* Paranoia */ if (dungeon_info[y][x].has_object()) { pop_up_message_box("Must be an empty grid"); return; } if (feat_ff2_match(i, FF2_EFFECT)) { feature_type *f_ptr = &f_info[i]; int gf_type = f_ptr->x_gf_type; if (feat_ff2_match(i, FF2_TRAP_SMART)) { QString dummy_string; u16b flags = fire_trap_smart(i, y, x, MODE_FLAGS, &dummy_string); set_effect_trap_smart(i, y, x, flags); } else if (feat_ff2_match(i, FF2_TRAP_PASSIVE)) set_effect_trap_passive(i, y, x); else if (feat_ff2_match(i, FF2_TRAP_MON)) set_effect_trap_player(i, y, x); else if (i == FEAT_GLYPH_WARDING) set_effect_glyph(y, x); else if (i == FEAT_WALL_GLACIER) set_effect_glacier(i, y, x, SOURCE_EFFECT, 0); else if (i == FEAT_WALL_INSCRIPTION) set_effect_inscription(i, y, x, SOURCE_EFFECT, 0); else if ((i == FEAT_RUBBLE) || (i == FEAT_RUBBLE_HIDDEN_OBJECT) || (i == FEAT_LOOSE_ROCK)) set_effect_rocks(i, y, x); else if (i == FEAT_EFFECT_SMOKE) set_effect_lingering_cloud(FEAT_EFFECT_SMOKE, y, x, 100, SOURCE_OTHER, 0); else if (i == FEAT_EFFECT_FOG) set_effect_permanent_cloud(i, y, x, 0, 0); // This list should be kept current with the function project_x else switch (gf_type) { case GF_COLD: case GF_ACID: case GF_ELEC: case GF_POIS: case GF_BWATER: case GF_BMUD: case GF_FIRE: case GF_LAVA: case GF_SPORE: case GF_NETHER: case GF_CHAOS: case GF_DISENCHANT: case GF_NEXUS: case GF_TIME: case GF_CONFUSION: case GF_SHARD: { set_effect_lingering_cloud(i, y, x, 50, SOURCE_OTHER, 0); break; } case GF_GRAVITY: case GF_INERTIA_NPP: case GF_LIFE_DRAIN: case GF_LIGHT: case GF_DARK: case GF_ELEC_BURST: case GF_METEOR: { set_effect_shimmering_cloud(i, y, x, 50, 50, SOURCE_OTHER, 0); break; } default :break; } } /* Create the feature */ else cave_set_feat(y, x, i); }