int test_drop_eat(void *state) { int num = 0; /* Load the saved game */ eq(savefile_load("Test1", FALSE), TRUE); num = player->upkeep->inven[0]->number; cmdq_push(CMD_WALK); cmd_set_arg_direction(cmdq_peek(), "direction", 4); run_game_loop(); cmdq_push(CMD_DROP); cmd_set_arg_item(cmdq_peek(), "item", player->upkeep->inven[0]); cmd_set_arg_number(cmdq_peek(), "quantity", player->upkeep->inven[0]->number); run_game_loop(); eq(square_object(cave, player->py, player->px)->number, num); cmdq_push(CMD_EAT); cmd_set_arg_item(cmdq_peek(), "item", square_object(cave, player->py, player->px)); run_game_loop(); if (num > 1) { eq(square_object(cave, player->py, player->px)->number, num - 1); } else { eq(square_object(cave, player->py, player->px), NULL); } ok; }
/** * Front-end command which fires at the nearest target with default ammo. */ void textui_cmd_fire_at_nearest(void) { /* the direction '5' means 'use the target' */ int i, dir = 5, item = -1; /* Require a usable launcher */ if (!p_ptr->inventory[INVEN_BOW].tval || !p_ptr->state.ammo_tval) { msg("You have nothing to fire with."); return; } /* Find first eligible ammo in the quiver */ for (i = QUIVER_START; i < QUIVER_END; i++) { if (p_ptr->inventory[i].tval != p_ptr->state.ammo_tval) continue; item = i; break; } /* Require usable ammo */ if (item < 0) { msg("You have no ammunition in the quiver to fire"); return; } /* Require foe */ if (!target_set_closest(TARGET_KILL | TARGET_QUIET)) return; /* Fire! */ cmd_insert(CMD_FIRE); cmd_set_arg_item(cmd_get_top(), 0, item); cmd_set_arg_target(cmd_get_top(), 1, dir); }
/** * Study a book to gain a new spell */ void textui_obj_study(void) { int item; char q[80]; char s[80]; if (mp_ptr->spell_realm == REALM_NONE) { msg("You cannot read books!"); return; } strnfmt(q, sizeof(q), "Study which %s?", magic_desc[mp_ptr->spell_realm][BOOK_NOUN]); strnfmt(s, sizeof(s), " You have no %ss that you can study.", magic_desc[mp_ptr->spell_realm][BOOK_LACK]); item_tester_hook = obj_can_study; if (!get_item(&item, q, s, CMD_STUDY_BOOK, (USE_INVEN | USE_FLOOR))) return; track_object(item); handle_stuff(p_ptr); if (mp_ptr->spell_book != TV_PRAYER_BOOK) { int spell = get_spell(object_from_item_idx(item), "study", spell_okay_to_study); if (spell >= 0) { cmd_insert(CMD_STUDY_SPELL); cmd_set_arg_choice(cmd_get_top(), 0, spell); } } else { cmd_insert(CMD_STUDY_BOOK); cmd_set_arg_item(cmd_get_top(), 0, item); } }
void textui_obj_wield(object_type *o_ptr, int item) { int slot = wield_slot(o_ptr); /* Usually if the slot is taken we'll just replace the item in the slot, * but in some cases we need to ask the user which slot they actually * want to replace */ if (p_ptr->inventory[slot].k_idx) { if (o_ptr->tval == TV_RING) { cptr q = "Replace which ring? "; cptr s = "Error in obj_wield, please report"; item_tester_hook = obj_is_ring; if (!get_item(&slot, q, s, CMD_WIELD, USE_EQUIP)) return; } if (obj_is_ammo(o_ptr) && !object_similar(&p_ptr->inventory[slot], o_ptr, OSTACK_QUIVER)) { cptr q = "Replace which ammunition? "; cptr s = "Error in obj_wield, please report"; item_tester_hook = obj_is_ammo; if (!get_item(&slot, q, s, CMD_WIELD, USE_EQUIP)) return; } } cmd_insert(CMD_WIELD); cmd_set_arg_item(cmd_get_top(), 0, item); cmd_set_arg_number(cmd_get_top(), 1, slot); }
/** * Front-end command which fires at the nearest target with default ammo. */ void do_cmd_fire_at_nearest(void) { int i, dir = DIR_TARGET; struct object *ammo = NULL; struct object *bow = equipped_item_by_slot_name(player, "shooting"); /* Require a usable launcher */ if (!bow || !player->state.ammo_tval) { msg("You have nothing to fire with."); return; } /* Find first eligible ammo in the quiver */ for (i = 0; i < z_info->quiver_size; i++) { if (!player->upkeep->quiver[i]) continue; if (player->upkeep->quiver[i]->tval != player->state.ammo_tval) continue; ammo = player->upkeep->quiver[i]; break; } /* Require usable ammo */ if (!ammo) { msg("You have no ammunition in the quiver to fire."); return; } /* Require foe */ if (!target_set_closest(TARGET_KILL | TARGET_QUIET)) return; /* Fire! */ cmdq_push(CMD_FIRE); cmd_set_arg_item(cmdq_peek(), "item", ammo); cmd_set_arg_target(cmdq_peek(), "target", dir); }
/** * Handle user input from a command menu */ static bool show_action(menu_type * menu, const ui_event * e, int oid) { /* Handle enter and mouse */ if (e->type == EVT_SELECT) { cmd_insert(comm_code[oid]); if (comm_code[oid] == CMD_NULL) Term_keypress(comm[oid],0); cmd_set_arg_item(cmd_get_top(), 0, item); } return FALSE; }
/** * Drop all {ignore}able items. */ void ignore_drop(void) { struct object *obj; /* Scan through the slots backwards */ for (obj = gear_last_item(); obj; obj = obj->prev) { /* Skip non-objects and unignoreable objects */ assert(obj->kind); if (!ignore_item_ok(obj)) continue; /* Check for !d (no drop) inscription */ if (!check_for_inscrip(obj, "!d") && !check_for_inscrip(obj, "!*")) { /* Confirm the drop if the item is equipped. */ if (object_is_equipped(player->body, obj)) { if (!verify_object("Really take off and drop", obj)) { /* Hack - inscribe the item with !d to prevent repeated * confirmations. */ const char *inscription = quark_str(obj->note); if (inscription == NULL) { obj->note = quark_add("!d"); } else { char buffer[1024]; my_strcpy(buffer, inscription, sizeof(buffer)); my_strcat(buffer, "!d", sizeof(buffer)); obj->note = quark_add(buffer); } continue; } } /* We're allowed to drop it. */ if (!square_isshop(cave, player->py, player->px)) { player->upkeep->dropping = true; cmdq_push(CMD_DROP); cmd_set_arg_item(cmdq_peek(), "item", obj); cmd_set_arg_number(cmdq_peek(), "quantity", obj->number); } } } /* Update the gear */ player->upkeep->update |= (PU_INVEN); /* Combine/reorder the pack */ player->upkeep->notice |= (PN_COMBINE); }
/** * Front-end 'throw' command. */ void textui_cmd_throw(void) { int item, dir; const char *q, *s; /* Get an item */ q = "Throw which item? "; s = "You have nothing to throw."; if (!get_item(&item, q, s, CMD_THROW, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return; if (item >= INVEN_WIELD && item < QUIVER_START) { msg("You cannot throw wielded items."); return; } /* Get a direction (or cancel) */ if (!get_aim_dir(&dir)) return; cmd_insert(CMD_THROW); cmd_set_arg_item(cmd_get_top(), 0, item); cmd_set_arg_target(cmd_get_top(), 1, dir); }
void textui_obj_inscribe(object_type *o_ptr, int item) { char o_name[80]; char tmp[80] = ""; object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL); msg_format("Inscribing %s.", o_name); message_flush(); /* Use old inscription */ if (o_ptr->note) strnfmt(tmp, sizeof(tmp), "%s", quark_str(o_ptr->note)); /* Get a new inscription (possibly empty) */ if (get_string("Inscription: ", tmp, sizeof(tmp))) { cmd_insert(CMD_INSCRIBE); cmd_set_arg_item(cmd_get_top(), 0, item); cmd_set_arg_string(cmd_get_top(), 1, tmp); } }
int test_drop_pickup(void *state) { /* Load the saved game */ eq(savefile_load("Test1", FALSE), TRUE); cmdq_push(CMD_WALK); cmd_set_arg_direction(cmdq_peek(), "direction", 4); run_game_loop(); if (player->upkeep->inven[0]->number > 1) { cmdq_push(CMD_DROP); cmd_set_arg_item(cmdq_peek(), "item", player->upkeep->inven[0]); cmd_set_arg_number(cmdq_peek(), "quantity", 1); run_game_loop(); eq(square_object(cave, player->py, player->px)->number, 1); cmdq_push(CMD_AUTOPICKUP); run_game_loop(); } eq(square_object(cave, player->py, player->px), NULL); ok; }
/** * Bring up objects to act on */ void do_cmd_show_obj(void) { cptr q, s; int j, item; object_type *o_ptr; char o_name[120]; byte out_color; bool accepted = FALSE; /* No restrictions */ item_tester_tval = 0; item_tester_hook = NULL; /* See what's available */ q = "Pick an item to use:"; s = "You have no items to hand."; if (!get_item(&item, q, s, CMD_NULL, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return; /* Got it */ if (item >= 0) { o_ptr = &p_ptr->inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Is it really an item? */ if (!o_ptr->k_idx) return; /* No commands yet */ poss = 0; /* Describe the object */ object_desc(o_name, sizeof(o_name), o_ptr, ODESC_FULL); /* Hack -- enforce max length */ o_name[Term->wid - 3] = '\0'; /* Acquire inventory color. Apply spellbook hack. */ out_color = proc_list_color_hack(o_ptr); /* Wear/wield */ if ((wield_slot(o_ptr) >= INVEN_WIELD) && (!SCHANGE) && (item < INVEN_WIELD)) { comm[poss] = 'w'; comm_code[poss] = CMD_WIELD; comm_descr[poss++] = "Wield"; } /* Take off equipment */ if ((item >= INVEN_WIELD) && (item < INVEN_TOTAL) && (!SCHANGE)) { comm[poss] = 't'; comm_code[poss] = CMD_TAKEOFF; comm_descr[poss++] = "Take off"; } /* Drop an item */ if ((item >= 0) && ((item < INVEN_WIELD) || (!SCHANGE))) { comm[poss] = 'd'; comm_code[poss] = CMD_DROP; comm_descr[poss++] = "Drop"; } /* Destroy an item */ if (item < INVEN_WIELD) { comm[poss] = 'k'; comm_code[poss] = CMD_DESTROY; comm_descr[poss++] = "Destroy"; } /* Identify an object */ comm[poss] = 'I'; comm_code[poss] = CMD_NULL; comm_descr[poss++] = "Inspect"; /* Pick up an object */ if ((item < 0) && inven_carry_okay(o_ptr)) { comm[poss] = 'g'; comm_code[poss] = CMD_PICKUP; comm_descr[poss++] = "Pick up"; } /* Book learnin' */ if (mp_ptr->spell_book == o_ptr->tval) { if (p_ptr->new_spells) { comm[poss] = 'G'; comm_code[poss] = CMD_STUDY_SPELL; comm_descr[poss++] = "Gain a spell"; } comm[poss] = 'b'; comm_code[poss] = CMD_BROWSE_SPELL; comm_descr[poss++] = "Browse"; comm[poss] = 'm'; comm_code[poss] = CMD_CAST; comm_descr[poss++] = "Cast a spell"; } /* Inscribe an object */ comm[poss] = '{'; comm_code[poss] = CMD_INSCRIBE; comm_descr[poss++] = "Inscribe"; /* Uninscribe an object */ if (o_ptr->note) { comm[poss] = '}'; comm_code[poss] = CMD_UNINSCRIBE; comm_descr[poss++] = "Uninscribe"; } /* Activate equipment */ if ((o_ptr->effect) && (item >= INVEN_WIELD)) { comm[poss] = 'A'; comm_code[poss] = CMD_ACTIVATE; comm_descr[poss++] = "Activate"; } /* Eat some food */ if (o_ptr->tval == TV_FOOD) { comm[poss] = 'E'; comm_code[poss] = CMD_EAT; comm_descr[poss++] = "Eat"; } if ((item < INVEN_WIELD) && ((o_ptr->tval == TV_LIGHT) || (o_ptr->tval == TV_FLASK))) { object_type *o1_ptr = &p_ptr->inventory[INVEN_LIGHT]; if (((o1_ptr->sval == SV_LIGHT_LANTERN) && ((o_ptr->tval == TV_FLASK) || ((o_ptr->tval == TV_LIGHT) && (o_ptr->sval == SV_LIGHT_LANTERN)))) || ((o1_ptr->sval == SV_LIGHT_TORCH) && (o_ptr->tval == TV_LIGHT) && (o_ptr->sval == SV_LIGHT_TORCH))) { comm[poss] = 'F'; comm_code[poss] = CMD_REFILL; comm_descr[poss++] = "Refuel"; } } /* Fire an item */ if (p_ptr->state.ammo_tval == o_ptr->tval) { comm[poss] = 'f'; comm_code[poss] = CMD_FIRE; comm_descr[poss++] = "Fire"; } /* Throw an item */ if ((item < INVEN_WIELD) || (!SCHANGE)) { comm[poss] = 'v'; comm_code[poss] = CMD_THROW; comm_descr[poss++] = "Throw"; } /* Aim a wand */ if (o_ptr->tval == TV_WAND) { comm[poss] = 'a'; comm_code[poss] = CMD_USE_WAND; comm_descr[poss++] = "Aim"; } /* Zap a rod */ if (o_ptr->tval == TV_ROD) { comm[poss] = 'z'; comm_code[poss] = CMD_USE_ROD; comm_descr[poss++] = "Zap"; } /* Quaff a potion */ if (o_ptr->tval == TV_POTION) { comm[poss] = 'q'; comm_code[poss] = CMD_QUAFF; comm_descr[poss++] = "Quaff"; } /* Read a scroll */ if (o_ptr->tval == TV_SCROLL) { comm[poss] = 'r'; comm_code[poss] = CMD_READ_SCROLL; comm_descr[poss++] = "Read"; } /* Use a staff */ if (o_ptr->tval == TV_STAFF) { comm[poss] = 'u'; comm_code[poss] = CMD_USE_STAFF; comm_descr[poss++] = "Use"; } /* Set up the screen */ screen_save(); /* Prompt */ put_str("Choose a command, or ESC:", 0, 0); /* Clear the line */ prt("", 1, 0); /* Display the item */ c_put_str(out_color, o_name, 1, 0); /* Hack - delete exact graphics rows */ if (tile_height > 1) { j = poss + 2; while ((j % tile_height) && (j <= SCREEN_ROWS)) prt("", ++j, 0); } /* Get a choice */ accepted = show_cmd_menu(TRUE); /* Load de screen */ screen_load(); /* Now set the item if valid */ if (accepted) cmd_set_arg_item(cmd_get_top(), 0, item); }
/* pick the context menu options appropiate for the item */ int context_menu_object(const object_type *o_ptr, const int slot) { menu_type *m; region r; int selected; char *labels; char header[120]; textblock *tb; region area = { 0, 0, 0, 0 }; bool allowed = TRUE; int mode = OPT(rogue_like_commands) ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG; unsigned char cmdkey; m = menu_dynamic_new(); if (!m || !o_ptr) { return 0; } object_desc(header, sizeof(header), o_ptr, ODESC_PREFIX | ODESC_BASE); labels = string_make(lower_case); m->selections = labels; /* 'I' is used for inspect in both keymaps. */ menu_dynamic_add_label(m, "Inspect", 'I', MENU_VALUE_INSPECT, labels); if (obj_can_browse(o_ptr)) { if (obj_can_cast_from(o_ptr) && player_can_cast(p_ptr, FALSE)) { ADD_LABEL("Cast", CMD_CAST, MN_ROW_VALID); } if (obj_can_study(o_ptr) && player_can_study(p_ptr, FALSE)) { cmd_code study_cmd = player_has(PF_CHOOSE_SPELLS) ? CMD_STUDY_SPELL : CMD_STUDY_BOOK; /* Hack - Use the STUDY_BOOK command key so that we get the correct command key. */ cmdkey = cmd_lookup_key_unktrl(CMD_STUDY_BOOK, mode); menu_dynamic_add_label(m, "Study", cmdkey, study_cmd, labels); } if (player_can_read(p_ptr, FALSE)) { ADD_LABEL("Browse", CMD_BROWSE_SPELL, MN_ROW_VALID); } } else if (obj_is_useable(o_ptr)) { if (obj_is_wand(o_ptr)) { menu_row_validity_t valid = (obj_has_charges(o_ptr)) ? MN_ROW_VALID : MN_ROW_INVALID; ADD_LABEL("Aim", CMD_USE_WAND, valid); } else if (obj_is_rod(o_ptr)) { menu_row_validity_t valid = (obj_can_zap(o_ptr)) ? MN_ROW_VALID : MN_ROW_INVALID; ADD_LABEL("Zap", CMD_USE_ROD, valid); } else if (obj_is_staff(o_ptr)) { menu_row_validity_t valid = (obj_has_charges(o_ptr)) ? MN_ROW_VALID : MN_ROW_INVALID; ADD_LABEL("Use", CMD_USE_STAFF, valid); } else if (obj_is_scroll(o_ptr)) { menu_row_validity_t valid = (player_can_read(p_ptr, FALSE)) ? MN_ROW_VALID : MN_ROW_INVALID; ADD_LABEL("Read", CMD_READ_SCROLL, valid); } else if (obj_is_potion(o_ptr)) { ADD_LABEL("Quaff", CMD_QUAFF, MN_ROW_VALID); } else if (obj_is_food(o_ptr)) { ADD_LABEL("Eat", CMD_EAT, MN_ROW_VALID); } else if (obj_is_activatable(o_ptr)) { menu_row_validity_t valid = (slot >= INVEN_WIELD && obj_can_activate(o_ptr)) ? MN_ROW_VALID : MN_ROW_INVALID; ADD_LABEL("Activate", CMD_ACTIVATE, valid); } else if (obj_can_fire(o_ptr)) { ADD_LABEL("Fire", CMD_FIRE, MN_ROW_VALID); } else { ADD_LABEL("Use", CMD_USE_ANY, MN_ROW_VALID); } } if (obj_can_refill(o_ptr)) { ADD_LABEL("Refill", CMD_REFILL, MN_ROW_VALID); } if (slot >= INVEN_WIELD && obj_can_takeoff(o_ptr)) { ADD_LABEL("Take off", CMD_TAKEOFF, MN_ROW_VALID); } else if (slot < INVEN_WIELD && obj_can_wear(o_ptr)) { //if (obj_is_armor(o_ptr)) { // menu_dynamic_add(m, "Wear", 2); //} else { // menu_dynamic_add(m, "Wield", 2); //} ADD_LABEL("Equip", CMD_WIELD, MN_ROW_VALID); } if (slot >= 0) { if (!store_in_store || cave_shopnum(cave, p_ptr->py, p_ptr->px) == STORE_HOME) { ADD_LABEL("Drop", CMD_DROP, MN_ROW_VALID); if (o_ptr->number > 1) { /* 'D' is used for squelch in rogue keymap, so we'll just swap letters. */ cmdkey = (mode == KEYMAP_MODE_ORIG) ? 'D' : 'k'; menu_dynamic_add_label(m, "Drop All", cmdkey, MENU_VALUE_DROP_ALL, labels); } } } else { menu_row_validity_t valid = (inven_carry_okay(o_ptr)) ? MN_ROW_VALID : MN_ROW_INVALID; ADD_LABEL("Pick up", CMD_PICKUP, valid); } ADD_LABEL("Throw", CMD_THROW, MN_ROW_VALID); ADD_LABEL("Inscribe", CMD_INSCRIBE, MN_ROW_VALID); if (obj_has_inscrip(o_ptr)) { ADD_LABEL("Uninscribe", CMD_UNINSCRIBE, MN_ROW_VALID); } ADD_LABEL( (object_is_squelched(o_ptr) ? "Unignore" : "Ignore"), CMD_DESTROY, MN_ROW_VALID); /* work out display region */ r.width = (int)menu_dynamic_longest_entry(m) + 3 + 2; /* +3 for tag, 2 for pad */ r.col = Term->wid - r.width - 1; r.row = 1; r.page_rows = m->count; area.width = -(r.width + 2); /* Hack -- no flush needed */ msg_flag = FALSE; screen_save(); /* Display info */ tb = object_info(o_ptr, OINFO_NONE); object_desc(header, sizeof(header), o_ptr, ODESC_PREFIX | ODESC_FULL); textui_textblock_place(tb, area, format("%s", header)); textblock_free(tb); menu_layout(m, &r); region_erase_bordered(&r); prt(format("(Enter to select, ESC) Command for %s:", header), 0, 0); selected = menu_dynamic_select(m); menu_dynamic_free(m); string_free(labels); screen_load(); cmdkey = cmd_lookup_key(selected, mode); switch (selected) { case -1: /* User cancelled the menu. */ return 3; case MENU_VALUE_INSPECT: /* copied from textui_obj_examine */ /* Display info */ tb = object_info(o_ptr, OINFO_NONE); object_desc(header, sizeof(header), o_ptr, ODESC_PREFIX | ODESC_FULL); textui_textblock_show(tb, area, format("%s", header)); textblock_free(tb); return 2; case MENU_VALUE_DROP_ALL: /* Drop entire stack with confirmation. */ if (get_check(format("Drop %s? ", header))) { cmd_insert(store_in_store ? CMD_STASH : CMD_DROP); cmd_set_arg_item(cmd_get_top(), 0, slot); cmd_set_arg_number(cmd_get_top(), 1, o_ptr->number); } return 1; case CMD_STUDY_SPELL: /* Hack - Use the STUDY_BOOK command key so that get_item_allow() works properly. */ cmdkey = cmd_lookup_key(CMD_STUDY_BOOK, mode); /* Fall through. */ case CMD_BROWSE_SPELL: case CMD_STUDY_BOOK: case CMD_CAST: case CMD_DESTROY: case CMD_WIELD: case CMD_TAKEOFF: case CMD_INSCRIBE: case CMD_UNINSCRIBE: case CMD_PICKUP: case CMD_DROP: case CMD_REFILL: case CMD_THROW: case CMD_USE_WAND: case CMD_USE_ROD: case CMD_USE_STAFF: case CMD_READ_SCROLL: case CMD_QUAFF: case CMD_EAT: case CMD_ACTIVATE: case CMD_FIRE: case CMD_USE_ANY: /* Check for inscriptions that trigger confirmation. */ allowed = key_confirm_command(cmdkey) && get_item_allow(slot, cmdkey, selected, FALSE); break; default: /* Invalid command; prevent anything from happening. */ bell("Invalid context menu command."); allowed = FALSE; break; } if (!allowed) return 1; if (selected == CMD_DESTROY) { /* squelch or unsquelch the item */ textui_cmd_destroy_menu(slot); } else if (selected == CMD_BROWSE_SPELL) { /* browse a spellbook */ /* copied from textui_spell_browse */ textui_book_browse(o_ptr); return 2; } else if (selected == CMD_STUDY_SPELL) { /* study a spell book */ /* copied from textui_obj_study */ int spell = get_spell(o_ptr, "study", spell_okay_to_study); if (spell >= 0) { cmd_insert(CMD_STUDY_SPELL); cmd_set_arg_choice(cmd_get_top(), 0, spell); } } else if (selected == CMD_CAST) { if (obj_can_browse(o_ptr)) { /* copied from textui_obj_cast */ const char *verb = ((p_ptr->class->spell_book == TV_MAGIC_BOOK) ? "cast" : "recite"); int spell = get_spell(o_ptr, verb, spell_okay_to_cast); if (spell >= 0) { cmd_insert(CMD_CAST); cmd_set_arg_choice(cmd_get_top(), 0, spell); } } } else {
void textui_cmd_destroy(void) { int item; object_type *o_ptr; char out_val[160]; menu_type *m; region r; int selected; /* Get an item */ const char *q = "Ignore which item? "; const char *s = "You have nothing to ignore."; if (!get_item(&item, q, s, CMD_DESTROY, USE_INVEN | USE_EQUIP | USE_FLOOR)) return; o_ptr = object_from_item_idx(item); m = menu_dynamic_new(); m->selections = lower_case; /* Basic ignore option */ if (!o_ptr->ignore) { menu_dynamic_add(m, "This item only", IGNORE_THIS_ITEM); } else { menu_dynamic_add(m, "Unignore this item", UNIGNORE_THIS_ITEM); } /* Flavour-aware squelch */ if (squelch_tval(o_ptr->tval) && (!o_ptr->artifact || !object_flavor_is_aware(o_ptr))) { bool squelched = kind_is_squelched_aware(o_ptr->kind) || kind_is_squelched_unaware(o_ptr->kind); char tmp[70]; object_desc(tmp, sizeof(tmp), o_ptr, ODESC_BASE | ODESC_PLURAL); if (!squelched) { strnfmt(out_val, sizeof out_val, "All %s", tmp); menu_dynamic_add(m, out_val, IGNORE_THIS_FLAVOR); } else { strnfmt(out_val, sizeof out_val, "Unignore all %s", tmp); menu_dynamic_add(m, out_val, UNIGNORE_THIS_FLAVOR); } } /* Quality squelching */ if (object_was_sensed(o_ptr) || object_was_worn(o_ptr) || object_is_known_not_artifact(o_ptr)) { byte value = squelch_level_of(o_ptr); int type = squelch_type_of(o_ptr); if (object_is_jewelry(o_ptr) && squelch_level_of(o_ptr) != SQUELCH_BAD) value = SQUELCH_MAX; if (value != SQUELCH_MAX && type != TYPE_MAX) { strnfmt(out_val, sizeof out_val, "All %s %s", quality_values[value].name, quality_choices[type].name); menu_dynamic_add(m, out_val, IGNORE_THIS_QUALITY); } } /* work out display region */ r.width = menu_dynamic_longest_entry(m) + 3 + 2; /* +3 for tag, 2 for pad */ r.col = 80 - r.width; r.row = 1; r.page_rows = m->count; screen_save(); menu_layout(m, &r); region_erase_bordered(&r); prt("(Enter to select, ESC) Ignore:", 0, 0); selected = menu_dynamic_select(m); screen_load(); if (selected == IGNORE_THIS_ITEM) { cmd_insert(CMD_DESTROY); cmd_set_arg_item(cmd_get_top(), 0, item); } else if (selected == UNIGNORE_THIS_ITEM) { o_ptr->ignore = FALSE; } else if (selected == IGNORE_THIS_FLAVOR) { object_squelch_flavor_of(o_ptr); } else if (selected == UNIGNORE_THIS_FLAVOR) { kind_squelch_clear(o_ptr->kind); } else if (selected == IGNORE_THIS_QUALITY) { byte value = squelch_level_of(o_ptr); int type = squelch_type_of(o_ptr); squelch_level[type] = value; } p_ptr->notice |= PN_SQUELCH; menu_dynamic_free(m); }