6 #include "objectkind.h"
7 #include "object-flavor.h"
9 #include "player-move.h"
11 #include "view-mainwindow.h"
13 bool select_ring_slot;
16 * @brief プレイヤーの所持/装備オブジェクトIDが指輪枠かを返す /
17 * @param i プレイヤーの所持/装備オブジェクトID
18 * @return 指輪枠ならばTRUEを返す。
20 bool is_ring_slot(int i)
22 return (i == INVEN_RIGHT) || (i == INVEN_LEFT);
27 * @brief 選択アルファベットラベルからプレイヤーの装備オブジェクトIDを返す /
28 * Convert a label into the index of a item in the "equip"
29 * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
31 INVENTORY_IDX label_to_equip(int c)
36 i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1) + INVEN_RARM;
38 /* Verify the index */
39 if ((i < INVEN_RARM) || (i >= INVEN_TOTAL)) return (-1);
41 if (select_ring_slot) return is_ring_slot(i) ? i : -1;
43 /* Empty slots can never be chosen */
44 if (!p_ptr->inventory_list[i].k_idx) return (-1);
46 /* Return the index */
54 * @brief 装備アイテム一覧を表示する /
55 * Choice window "shadow" of the "show_equip()" function
58 void display_equip(OBJECT_TYPE_VALUE tval)
62 TERM_COLOR attr = TERM_WHITE;
64 GAME_TEXT o_name[MAX_NLEN];
67 Term_get_size(&wid, &hgt);
69 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
71 o_ptr = &p_ptr->inventory_list[i];
72 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
73 if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr, tval))
75 tmp_val[0] = index_to_label(i);
79 Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
80 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
82 strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
87 object_desc(o_name, o_ptr, 0);
88 attr = tval_to_attr[o_ptr->tval % 128];
96 Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
98 Term_erase(3 + n, i - INVEN_RARM, 255);
102 int wgt = o_ptr->weight * o_ptr->number;
104 sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
106 sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
109 prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
114 Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
115 prt(mention_use(i), i - INVEN_RARM, wid - 15);
119 for (i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
121 Term_erase(0, i, 255);
126 * @brief サブウィンドウに所持品、装備品リストの表示を行う /
127 * Flip "inven" and "equip" in any sub-windows
130 void toggle_inven_equip(void)
135 for (j = 0; j < 8; j++)
138 if (!angband_term[j]) continue;
140 /* Flip inven to equip */
141 if (window_flag[j] & (PW_INVEN))
144 window_flag[j] &= ~(PW_INVEN);
145 window_flag[j] |= (PW_EQUIP);
147 p_ptr->window |= (PW_EQUIP);
150 /* Flip inven to equip */
151 else if (window_flag[j] & (PW_EQUIP))
154 window_flag[j] &= ~(PW_EQUIP);
155 window_flag[j] |= (PW_INVEN);
157 p_ptr->window |= (PW_INVEN);
164 * @brief プレイヤーの所持/装備オブジェクトが正規のものかを返す /
165 * Auxiliary function for "get_item()" -- test an index
167 * @return 正規のIDならばTRUEを返す。
169 bool get_item_okay(OBJECT_IDX i)
172 if ((i < 0) || (i >= INVEN_TOTAL)) return (FALSE);
174 if (select_ring_slot) return is_ring_slot(i);
176 /* Verify the item */
177 if (!item_tester_okay(&p_ptr->inventory_list[i], item_tester_tval)) return (FALSE);
184 * @brief プレイヤーがオブジェクトを拾うことができる状態かを返す /
185 * Determine whether get_item() can get some item or not
186 * @return アイテムを拾えるならばTRUEを返す。
187 * @details assuming mode = (USE_EQUIP | USE_INVEN | USE_FLOOR).
189 bool can_get_item(OBJECT_TYPE_VALUE tval)
192 OBJECT_IDX floor_list[23];
193 ITEM_NUMBER floor_num = 0;
195 for (j = 0; j < INVEN_TOTAL; j++)
196 if (item_tester_okay(&p_ptr->inventory_list[j], tval))
199 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
208 * @brief 床オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
209 * Find the "first" p_ptr->inventory_list object with the given "tag".
210 * @param cp 対応するタグIDを与える参照ポインタ
211 * @param tag 該当するオブジェクトがあるかを調べたいタグ
212 * @param floor_list 床上アイテムの配列
213 * @param floor_num 床上アイテムの配列ID
214 * @return タグに該当するオブジェクトがあるならTRUEを返す
216 * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
217 * inscription of an object. Alphabetical characters don't work as a\n
218 * tag in this form.\n
220 * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
221 * and "x" is the "current" command_cmd code.\n
223 static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
228 /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
230 /* Check every object in the grid */
231 for (i = 0; i < floor_num && i < 23; i++)
233 object_type *o_ptr = ¤t_floor_ptr->o_list[floor_list[i]];
235 /* Skip empty inscriptions */
236 if (!o_ptr->inscription) continue;
239 s = my_strchr(quark_str(o_ptr->inscription), '@');
241 /* Process all tags */
244 /* Check the special tags */
245 if ((s[1] == command_cmd) && (s[2] == tag))
247 /* Save the actual floor object ID */
254 /* Find another '@' */
255 s = my_strchr(s + 1, '@');
260 /**** Find a tag in the form of {@#} (allows only numerals) ***/
262 /* Don't allow {@#} with '#' being alphabet */
263 if (tag < '0' || '9' < tag)
269 /* Check every object in the grid */
270 for (i = 0; i < floor_num && i < 23; i++)
272 object_type *o_ptr = ¤t_floor_ptr->o_list[floor_list[i]];
274 /* Skip empty inscriptions */
275 if (!o_ptr->inscription) continue;
278 s = my_strchr(quark_str(o_ptr->inscription), '@');
280 /* Process all tags */
283 /* Check the normal tags */
286 /* Save the floor object ID */
293 /* Find another '@' */
294 s = my_strchr(s + 1, '@');
304 * @brief 所持/装備オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
305 * Find the "first" p_ptr->inventory_list object with the given "tag".
306 * @param cp 対応するタグIDを与える参照ポインタ
307 * @param tag 該当するオブジェクトがあるかを調べたいタグ
308 * @param mode 所持、装備の切り替え
309 * @return タグに該当するオブジェクトがあるならTRUEを返す
311 * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
312 * inscription of an object. Alphabetical characters don't work as a\n
313 * tag in this form.\n
315 * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
316 * and "x" is the "current" command_cmd code.\n
318 static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
321 COMMAND_CODE start, end;
324 /* Extract index from mode */
329 end = INVEN_TOTAL - 1;
334 end = INVEN_PACK - 1;
341 /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
343 /* Check every p_ptr->inventory_list object */
344 for (i = start; i <= end; i++)
346 object_type *o_ptr = &p_ptr->inventory_list[i];
347 if (!o_ptr->k_idx) continue;
349 /* Skip empty inscriptions */
350 if (!o_ptr->inscription) continue;
352 /* Skip non-choice */
353 if (!item_tester_okay(o_ptr, tval) && !(mode & USE_FULL)) continue;
356 s = my_strchr(quark_str(o_ptr->inscription), '@');
358 /* Process all tags */
361 /* Check the special tags */
362 if ((s[1] == command_cmd) && (s[2] == tag))
364 /* Save the actual p_ptr->inventory_list ID */
371 /* Find another '@' */
372 s = my_strchr(s + 1, '@');
377 /**** Find a tag in the form of {@#} (allows only numerals) ***/
379 /* Don't allow {@#} with '#' being alphabet */
380 if (tag < '0' || '9' < tag)
386 /* Check every object */
387 for (i = start; i <= end; i++)
389 object_type *o_ptr = &p_ptr->inventory_list[i];
390 if (!o_ptr->k_idx) continue;
392 /* Skip empty inscriptions */
393 if (!o_ptr->inscription) continue;
395 /* Skip non-choice */
396 if (!item_tester_okay(o_ptr, tval) && !(mode & USE_FULL)) continue;
399 s = my_strchr(quark_str(o_ptr->inscription), '@');
401 /* Process all tags */
404 /* Check the normal tags */
407 /* Save the actual p_ptr->inventory_list ID */
414 /* Find another '@' */
415 s = my_strchr(s + 1, '@');
424 * @brief タグIDにあわせてタグアルファベットのリストを返す /
425 * Move around label characters with correspond tags
426 * @param label ラベルリストを取得する文字列参照ポインタ
427 * @param mode 所持品リストか装備品リストかの切り替え
430 void prepare_label_string(char *label, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
432 concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
433 int offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
436 /* Prepare normal labels */
437 strcpy(label, alphabet_chars);
439 /* Move each label */
440 for (i = 0; i < 52; i++)
443 SYMBOL_CODE c = alphabet_chars[i];
445 /* Find a tag with this label */
446 if (get_tag(&index, c, mode, tval))
448 /* Delete the overwritten label */
449 if (label[i] == c) label[i] = ' ';
451 /* Move the label to the place of corresponding tag */
452 label[index - offset] = c;
459 * @brief タグIDにあわせてタグアルファベットのリストを返す(床上アイテム用) /
460 * Move around label characters with correspond tags (floor version)
461 * @param label ラベルリストを取得する文字列参照ポインタ
462 * @param floor_list 床上アイテムの配列
463 * @param floor_num 床上アイテムの配列ID
468 static void prepare_label_string_floor(char *label, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
470 concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
473 /* Prepare normal labels */
474 strcpy(label, alphabet_chars);
476 /* Move each label */
477 for (i = 0; i < 52; i++)
480 SYMBOL_CODE c = alphabet_chars[i];
482 /* Find a tag with this label */
483 if (get_tag_floor(&index, c, floor_list, floor_num))
485 /* Delete the overwritten label */
486 if (label[i] == c) label[i] = ' ';
488 /* Move the label to the place of corresponding tag */
495 * @brief 所持アイテムの表示を行う /
496 * Display the p_ptr->inventory_list.
497 * @param target_item アイテムの選択処理を行うか否か。
498 * @return 選択したアイテムのタグ
500 * Hack -- do not display "trailing" empty slots
502 COMMAND_CODE show_inven(int target_item, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
506 int col, cur_col, len;
508 GAME_TEXT o_name[MAX_NLEN];
510 COMMAND_CODE out_index[23];
511 TERM_COLOR out_color[23];
512 char out_desc[23][MAX_NLEN];
513 COMMAND_CODE target_item_label = 0;
515 char inven_label[52 + 1];
517 /* Starting column */
520 Term_get_size(&wid, &hgt);
522 /* Default "max-length" */
526 /* Find the "final" slot */
527 for (i = 0; i < INVEN_PACK; i++)
529 o_ptr = &p_ptr->inventory_list[i];
530 if (!o_ptr->k_idx) continue;
536 prepare_label_string(inven_label, USE_INVEN, tval);
538 /* Display the p_ptr->inventory_list */
539 for (k = 0, i = 0; i < z; i++)
541 o_ptr = &p_ptr->inventory_list[i];
543 /* Is this item acceptable? */
544 if (!item_tester_okay(o_ptr, tval) && !(mode & USE_FULL)) continue;
546 object_desc(o_name, o_ptr, 0);
548 /* Save the object index, color, and description */
550 out_color[k] = tval_to_attr[o_ptr->tval % 128];
552 /* Grey out charging items */
555 out_color[k] = TERM_L_DARK;
558 (void)strcpy(out_desc[k], o_name);
560 /* Find the predicted "line length" */
561 l = strlen(out_desc[k]) + 5;
563 /* Be sure to account for the weight */
564 if (show_weights) l += 9;
566 /* Account for icon if displayed */
570 if (use_bigtile) l++;
573 /* Maintain the maximum length */
574 if (l > len) len = l;
576 /* Advance to next "line" */
580 /* Find the column to start in */
581 col = (len > wid - 4) ? 0 : (wid - len - 1);
583 /* Output each entry */
584 for (j = 0; j < k; j++)
587 o_ptr = &p_ptr->inventory_list[i];
590 prt("", j + 1, col ? col - 2 : col);
592 if (use_menu && target_item)
594 if (j == (target_item - 1))
596 strcpy(tmp_val, _("》", "> "));
597 target_item_label = i;
599 else strcpy(tmp_val, " ");
601 else if (i <= INVEN_PACK)
603 /* Prepare an index --(-- */
604 sprintf(tmp_val, "%c)", inven_label[i]);
608 /* Prepare an index --(-- */
609 sprintf(tmp_val, "%c)", index_to_label(i));
612 /* Clear the line with the (possibly indented) index */
613 put_str(tmp_val, j + 1, col);
617 /* Display graphics for object, if desired */
620 TERM_COLOR a = object_attr(o_ptr);
621 SYMBOL_CODE c = object_char(o_ptr);
622 Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
623 if (use_bigtile) cur_col++;
629 /* Display the entry itself */
630 c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
632 /* Display the weight if needed */
635 int wgt = o_ptr->weight * o_ptr->number;
637 (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
639 (void)sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
642 prt(tmp_val, j + 1, wid - 9);
646 /* Make a "shadow" below the list (only if needed) */
647 if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
649 /* Save the new column */
652 return target_item_label;
657 * @brief 選択したアイテムの確認処理の補助 /
658 * Verify the choice of an item.
659 * @param prompt メッセージ表示の一部
660 * @param item 選択アイテムID
661 * @return 確認がYesならTRUEを返す。
662 * @details The item can be negative to mean "item on floor".
664 static bool verify(concptr prompt, INVENTORY_IDX item)
666 GAME_TEXT o_name[MAX_NLEN];
667 char out_val[MAX_NLEN + 20];
674 o_ptr = &p_ptr->inventory_list[item];
680 o_ptr = ¤t_floor_ptr->o_list[0 - item];
682 object_desc(o_name, o_ptr, 0);
685 (void)sprintf(out_val, _("%s%sですか? ", "%s %s? "), prompt, o_name);
688 return (get_check(out_val));
693 * @brief 選択したアイテムの確認処理のメインルーチン /
694 * @param item 選択アイテムID
695 * @return 確認がYesならTRUEを返す。
696 * @details The item can be negative to mean "item on floor".
697 * Hack -- allow user to "prevent" certain choices
699 static bool get_item_allow(INVENTORY_IDX item)
703 if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
708 o_ptr = &p_ptr->inventory_list[item];
714 o_ptr = ¤t_floor_ptr->o_list[0 - item];
718 if (!o_ptr->inscription) return (TRUE);
721 s = my_strchr(quark_str(o_ptr->inscription), '!');
723 /* Process preventions */
726 /* Check the "restriction" */
727 if ((s[1] == command_cmd) || (s[1] == '*'))
729 /* Verify the choice */
730 if (!verify(_("本当に", "Really try"), item)) return (FALSE);
733 /* Find another '!' */
734 s = my_strchr(s + 1, '!');
743 * @brief オブジェクト選択の汎用関数 /
744 * Let the user select an item, save its "index"
745 * @param cp 選択したオブジェクトのIDを返す。
746 * @param pmt 選択目的のメッセージ
747 * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
748 * @param mode オプションフラグ
749 * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
750 * Return TRUE only if an acceptable item was chosen by the user.\n
752 * The selected item must satisfy the "item_tester_hook()" function,\n
753 * if that hook is set, and the "item_tester_tval", if that value is set.\n
755 * All "item_tester" restrictions are cleared before this function returns.\n
757 * The user is allowed to choose acceptable items from the equipment,\n
758 * p_ptr->inventory_list, or floor, respectively, if the proper flag was given,\n
759 * and there are any acceptable items in that location.\n
761 * The equipment or p_ptr->inventory_list are displayed (even if no acceptable\n
762 * items are in that location) if the proper flag was given.\n
764 * If there are no acceptable items available anywhere, and "str" is\n
765 * not NULL, then it will be used as the text of a warning message\n
766 * before the function returns.\n
768 * Note that the user must press "-" to specify the item on the floor,\n
769 * and there is no way to "examine" the item on the floor, while the\n
770 * use of "capital" letters will "examine" an p_ptr->inventory_list/equipment item,\n
771 * and prompt for its use.\n
773 * If a legal item is selected from the p_ptr->inventory_list, we save it in "cp"\n
774 * directly (0 to 35), and return TRUE.\n
776 * If a legal item is selected from the floor, we save it in "cp" as\n
777 * a negative (-1 to -511), and return TRUE.\n
779 * If no item is available, we do nothing to "cp", and we display a\n
780 * warning message, using "str" if available, and return FALSE.\n
782 * If no item is selected, we do nothing to "cp", and return FALSE.\n
784 * Global "p_ptr->command_new" is used when viewing the p_ptr->inventory_list or equipment\n
785 * to allow the user to enter a command while viewing those screens, and\n
786 * also to induce "auto-enter" of stores, and other such stuff.\n
788 * Global "p_ptr->command_see" may be set before calling this function to start\n
789 * out in "browse" mode. It is cleared before this function returns.\n
791 * Global "p_ptr->command_wrk" is used to choose between equip/inven listings.\n
792 * If it is TRUE then we are viewing p_ptr->inventory_list, else equipment.\n
794 * We always erase the prompt when we are done, leaving a blank line,\n
795 * or a warning message, if appropriate, if no items are available.\n
797 bool get_item(OBJECT_IDX *cp, concptr pmt, concptr str, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
799 OBJECT_IDX this_o_idx, next_o_idx = 0;
816 bool allow_floor = FALSE;
823 int menu_line = (use_menu ? 1 : 0);
827 static char prev_tag = '\0';
830 if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode, tval);
833 if (mode & USE_EQUIP) equip = TRUE;
834 if (mode & USE_INVEN) inven = TRUE;
835 if (mode & USE_FLOOR) floor = TRUE;
837 /* Get the item index */
841 if (mode & USE_FORCE && (*cp == INVEN_FORCE))
844 item_tester_hook = NULL;
845 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
850 else if (floor && (*cp < 0))
856 o_ptr = ¤t_floor_ptr->o_list[k];
858 /* Validate the item */
859 if (item_tester_okay(o_ptr, tval) || (mode & USE_FULL))
861 /* Forget restrictions */
863 item_tester_hook = NULL;
864 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
871 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
872 (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
874 if (prev_tag && command_cmd)
876 /* Look up the tag and validate the item */
877 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN, tval)) /* Reject */;
878 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
879 else if (!get_item_okay(k)) /* Reject */;
882 /* Accept that choice */
885 /* Forget restrictions */
887 item_tester_hook = NULL;
888 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
894 prev_tag = '\0'; /* prev_tag is no longer effective */
897 /* Verify the item */
898 else if (get_item_okay(*cp))
900 /* Forget restrictions */
902 item_tester_hook = NULL;
903 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
915 /* No item selected */
919 /* Full p_ptr->inventory_list */
923 /* Forbid p_ptr->inventory_list */
927 for (j = 0; j < INVEN_PACK; j++)
928 if (item_tester_okay(&p_ptr->inventory_list[j], tval) || (mode & USE_FULL)) max_inven++;
931 /* Restrict p_ptr->inventory_list indexes */
932 while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
933 while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
938 e2 = INVEN_TOTAL - 1;
940 /* Forbid equipment */
944 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
945 if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j], tval) || (mode & USE_FULL)) max_equip++;
946 if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
949 /* Restrict equipment indexes */
950 while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
951 while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
953 if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
957 if (e2 < INVEN_LARM) e2 = INVEN_LARM;
959 else if (p_ptr->hidarite) e1 = INVEN_RARM;
963 /* Restrict floor usage */
966 /* Scan all objects in the grid */
967 for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
970 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
971 next_o_idx = o_ptr->next_o_idx;
973 /* Accept the item on the floor if legal */
974 if ((item_tester_okay(o_ptr, tval) || (mode & USE_FULL)) && (o_ptr->marked & OM_FOUND)) allow_floor = TRUE;
978 /* Require at least one legal choice */
979 if (!allow_floor && (i1 > i2) && (e1 > e2))
981 /* Cancel p_ptr->command_see */
986 if (mode & USE_FORCE) {
992 /* Analyze choices */
995 /* Hack -- Start on equipment if requested */
996 if (command_see && command_wrk && equip)
1001 /* Use p_ptr->inventory_list if allowed */
1004 command_wrk = FALSE;
1007 /* Use equipment if allowed */
1013 /* Use p_ptr->inventory_list for floor */
1016 command_wrk = FALSE;
1022 * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
1024 if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
1026 /* Hack -- start out in "display" mode */
1033 /* Repeat until done */
1036 COMMAND_CODE get_item_label = 0;
1043 for (j = 0; j < 8; j++)
1046 if (!angband_term[j]) continue;
1048 /* Count windows displaying inven */
1049 if (window_flag[j] & (PW_INVEN)) ni++;
1051 /* Count windows displaying equip */
1052 if (window_flag[j] & (PW_EQUIP)) ne++;
1055 /* Toggle if needed */
1056 if ((command_wrk && ni && !ne) || (!command_wrk && !ni && ne))
1059 toggle_inven_equip();
1065 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1068 /* Inventory screen */
1071 /* Redraw if needed */
1072 if (command_see) get_item_label = show_inven(menu_line, mode, tval);
1075 /* Equipment screen */
1078 /* Redraw if needed */
1079 if (command_see) get_item_label = show_equip(menu_line, mode, tval);
1082 /* Viewing p_ptr->inventory_list */
1085 /* Begin the prompt */
1086 sprintf(out_val, _("持ち物:", "Inven:"));
1088 /* Some legal items */
1089 if ((i1 <= i2) && !use_menu)
1091 /* Build the prompt */
1092 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
1093 index_to_label(i1), index_to_label(i2));
1096 strcat(out_val, tmp_val);
1099 /* Indicate ability to "view" */
1100 if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
1103 if (equip) strcat(out_val, format(_(" %s 装備品,", " %s for Equip,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "/")));
1106 /* Viewing equipment */
1109 /* Begin the prompt */
1110 sprintf(out_val, _("装備品:", "Equip:"));
1112 /* Some legal items */
1113 if ((e1 <= e2) && !use_menu)
1115 /* Build the prompt */
1116 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
1117 index_to_label(e1), index_to_label(e2));
1120 strcat(out_val, tmp_val);
1123 /* Indicate ability to "view" */
1124 if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
1127 if (inven) strcat(out_val, format(_(" %s 持ち物,", " %s for Inven,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "'/'")));
1130 /* Indicate legality of the "floor" item */
1131 if (allow_floor) strcat(out_val, _(" '-'床上,", " - for floor,"));
1132 if (mode & USE_FORCE) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
1134 /* Finish the prompt */
1135 strcat(out_val, " ESC");
1137 /* Build the prompt */
1138 sprintf(tmp_val, "(%s) %s", out_val, pmt);
1140 /* Show the prompt */
1148 int max_line = (command_wrk ? max_equip : max_inven);
1164 menu_line += (max_line - 1);
1183 /* Verify legality */
1184 if (!inven || !equip)
1190 /* Hack -- Fix screen */
1197 /* Switch inven/equip */
1198 command_wrk = !command_wrk;
1199 max_line = (command_wrk ? max_equip : max_inven);
1200 if (menu_line > max_line) menu_line = max_line;
1202 /* Need to redraw */
1211 if (command_wrk == USE_FLOOR)
1214 (*cp) = -get_item_label;
1218 /* Validate the item */
1219 if (!get_item_okay(get_item_label))
1225 /* Allow player to "refuse" certain actions */
1226 if (!get_item_allow(get_item_label))
1232 /* Accept that choice */
1233 (*cp) = get_item_label;
1242 if (mode & USE_FORCE) {
1250 if (menu_line > max_line) menu_line -= max_line;
1271 command_see = FALSE;
1288 /* Verify legality */
1289 if (!inven || !equip)
1295 /* Hack -- Fix screen */
1302 /* Switch inven/equip */
1303 command_wrk = !command_wrk;
1305 /* Need to redraw */
1311 /* Use floor item */
1314 /* Scan all objects in the grid */
1315 for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
1318 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
1319 next_o_idx = o_ptr->next_o_idx;
1321 /* Validate the item */
1322 if (!item_tester_okay(o_ptr, tval) && !(mode & USE_FULL)) continue;
1327 /* Verify the item (if required) */
1328 if (other_query_flag && !verify(_("本当に", "Try"), k)) continue;
1330 /* Allow player to "refuse" certain actions */
1331 if (!get_item_allow(k)) continue;
1333 /* Accept that choice */
1349 case '1': case '2': case '3':
1350 case '4': case '5': case '6':
1351 case '7': case '8': case '9':
1353 /* Look up the tag */
1354 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN, tval))
1360 /* Hack -- Validate the item */
1361 if ((k < INVEN_RARM) ? !inven : !equip)
1367 /* Validate the item */
1368 if (!get_item_okay(k))
1374 /* Allow player to "refuse" certain actions */
1375 if (!get_item_allow(k))
1381 /* Accept that choice */
1393 /* Choose "default" p_ptr->inventory_list item */
1396 k = ((i1 == i2) ? i1 : -1);
1399 /* Choose "default" equipment item */
1402 k = ((e1 == e2) ? e1 : -1);
1405 /* Validate the item */
1406 if (!get_item_okay(k))
1412 /* Allow player to "refuse" certain actions */
1413 if (!get_item_allow(k))
1419 /* Accept that choice */
1429 if (mode & USE_FORCE) {
1442 bool not_found = FALSE;
1444 /* Look up the alphabetical tag */
1445 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN, tval))
1450 /* Hack -- Validate the item */
1451 else if ((k < INVEN_RARM) ? !inven : !equip)
1456 /* Validate the item */
1457 else if (!get_item_okay(k))
1464 /* Accept that choice */
1472 /* Extract "query" setting */
1473 ver = isupper(which);
1474 which = (char)tolower(which);
1476 /* Convert letter to p_ptr->inventory_list index */
1479 if (which == '(') k = i1;
1480 else if (which == ')') k = i2;
1481 else k = label_to_inven(which);
1484 /* Convert letter to equipment index */
1487 if (which == '(') k = e1;
1488 else if (which == ')') k = e2;
1489 else k = label_to_equip(which);
1492 /* Validate the item */
1493 if (!get_item_okay(k))
1499 /* Verify the item */
1500 if (ver && !verify(_("本当に", "Try"), k))
1506 /* Allow player to "refuse" certain actions */
1507 if (!get_item_allow(k))
1513 /* Accept that choice */
1524 /* Fix the screen if necessary */
1529 /* Hack -- Cancel "display" */
1530 command_see = FALSE;
1534 /* Forget the tval restriction */
1537 /* Forget the item_tester_hook restriction */
1538 item_tester_hook = NULL;
1541 /* Clean up 'show choices' */
1542 /* Toggle again if needed */
1543 if (toggle) toggle_inven_equip();
1545 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1548 /* Clear the prompt line */
1551 /* Warning if needed */
1552 if (oops && str) msg_print(str);
1557 if (command_cmd) prev_tag = cur_tag;
1558 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1564 * Choose an item and get auto-picker entry from it.
1566 object_type *choose_object(OBJECT_IDX *idx, concptr q, concptr s, BIT_FLAGS option)
1569 if (!get_item(&item, q, s, option, item_tester_tval)) return NULL;
1570 if (idx) *idx = item;
1572 if (item == INVEN_FORCE) return NULL;
1574 /* Get the item (in the pack) */
1575 else if (item >= 0) return &p_ptr->inventory_list[item];
1577 /* Get the item (on the floor) */
1578 else return ¤t_floor_ptr->o_list[0 - item];
1583 * @brief 床下に落ちているオブジェクトの数を返す / scan_floor
1584 * @param items オブジェクトのIDリストを返すための配列参照ポインタ
1585 * @param y 走査するフロアのY座標
1586 * @param x 走査するフロアのX座標
1587 * @param mode オプションフラグ
1588 * @return 対象のマスに落ちているアイテム数
1590 * Return a list of o_list[] indexes of items at the given current_floor_ptr->grid_array
1591 * location. Valid flags are:
1593 * mode & 0x01 -- Item tester
1594 * mode & 0x02 -- Marked items only
1595 * mode & 0x04 -- Stop after first
1597 ITEM_NUMBER scan_floor(OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode)
1599 OBJECT_IDX this_o_idx, next_o_idx;
1601 ITEM_NUMBER num = 0;
1604 if (!in_bounds(y, x)) return 0;
1606 /* Scan all objects in the grid */
1607 for (this_o_idx = current_floor_ptr->grid_array[y][x].o_idx; this_o_idx; this_o_idx = next_o_idx)
1610 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
1611 next_o_idx = o_ptr->next_o_idx;
1614 if ((mode & 0x01) && !item_tester_okay(o_ptr, item_tester_tval)) continue;
1617 if ((mode & 0x02) && !(o_ptr->marked & OM_FOUND)) continue;
1619 /* Accept this item */
1620 /* XXX Hack -- Enforce limit */
1622 items[num] = this_o_idx;
1627 if (mode & 0x04) break;
1634 * @brief 床下に落ちているアイテムの一覧を返す / Display a list of the items on the floor at the given location.
1635 * @param target_item カーソルの初期値
1636 * @param y 走査するフロアのY座標
1637 * @param x 走査するフロアのX座標
1638 * @param min_width 表示の長さ
1639 * @return 選択したアイテムの添え字
1642 COMMAND_CODE show_floor(int target_item, POSITION y, POSITION x, TERM_LEN *min_width)
1650 GAME_TEXT o_name[MAX_NLEN];
1653 COMMAND_CODE out_index[23];
1654 TERM_COLOR out_color[23];
1655 char out_desc[23][MAX_NLEN];
1656 COMMAND_CODE target_item_label = 0;
1658 OBJECT_IDX floor_list[23];
1659 ITEM_NUMBER floor_num;
1661 char floor_label[52 + 1];
1663 bool dont_need_to_show_weights = TRUE;
1665 Term_get_size(&wid, &hgt);
1667 /* Default length */
1668 len = MAX((*min_width), 20);
1670 /* Scan for objects in the grid, using item_tester_okay() */
1671 floor_num = scan_floor(floor_list, y, x, 0x03);
1673 /* Display the floor objects */
1674 for (k = 0, i = 0; i < floor_num && i < 23; i++)
1676 o_ptr = ¤t_floor_ptr->o_list[floor_list[i]];
1678 object_desc(o_name, o_ptr, 0);
1680 /* Save the index */
1683 /* Acquire p_ptr->inventory_list color */
1684 out_color[k] = tval_to_attr[o_ptr->tval & 0x7F];
1686 /* Save the object description */
1687 strcpy(out_desc[k], o_name);
1689 /* Find the predicted "line length" */
1690 l = strlen(out_desc[k]) + 5;
1692 /* Be sure to account for the weight */
1693 if (show_weights) l += 9;
1695 if (o_ptr->tval != TV_GOLD) dont_need_to_show_weights = FALSE;
1697 /* Maintain the maximum length */
1698 if (l > len) len = l;
1700 /* Advance to next "line" */
1704 if (show_weights && dont_need_to_show_weights) len -= 9;
1709 /* Find the column to start in */
1710 col = (len > wid - 4) ? 0 : (wid - len - 1);
1712 prepare_label_string_floor(floor_label, floor_list, floor_num);
1714 /* Output each entry */
1715 for (j = 0; j < k; j++)
1717 m = floor_list[out_index[j]];
1718 o_ptr = ¤t_floor_ptr->o_list[m];
1720 /* Clear the line */
1721 prt("", j + 1, col ? col - 2 : col);
1723 if (use_menu && target_item)
1725 if (j == (target_item - 1))
1727 strcpy(tmp_val, _("》", "> "));
1728 target_item_label = m;
1730 else strcpy(tmp_val, " ");
1734 /* Prepare an index --(-- */
1735 sprintf(tmp_val, "%c)", floor_label[j]);
1738 /* Clear the line with the (possibly indented) index */
1739 put_str(tmp_val, j + 1, col);
1741 /* Display the entry itself */
1742 c_put_str(out_color[j], out_desc[j], j + 1, col + 3);
1744 /* Display the weight if needed */
1745 if (show_weights && (o_ptr->tval != TV_GOLD))
1747 int wgt = o_ptr->weight * o_ptr->number;
1749 sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
1751 sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1754 prt(tmp_val, j + 1, wid - 9);
1758 /* Make a "shadow" below the list (only if needed) */
1759 if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
1761 return target_item_label;
1765 * @brief オブジェクト選択の汎用関数(床上アイテム用) /
1766 * Let the user select an item, save its "index"
1767 * @param cp 選択したオブジェクトのIDを返す。
1768 * @param pmt 選択目的のメッセージ
1769 * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
1770 * @param mode オプションフラグ
1771 * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
1773 bool get_item_floor(COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
1775 char n1 = ' ', n2 = ' ', which = ' ';
1778 COMMAND_CODE i1, i2;
1779 COMMAND_CODE e1, e2;
1787 bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
1788 bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
1789 bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
1790 bool force = (mode & USE_FORCE) ? TRUE : FALSE;
1792 bool allow_equip = FALSE;
1793 bool allow_inven = FALSE;
1794 bool allow_floor = FALSE;
1796 bool toggle = FALSE;
1801 ITEM_NUMBER floor_num;
1802 OBJECT_IDX floor_list[23];
1804 TERM_LEN min_width = 0;
1806 int menu_line = (use_menu ? 1 : 0);
1810 static char prev_tag = '\0';
1811 char cur_tag = '\0';
1813 /* Get the item index */
1814 if (repeat_pull(cp))
1817 if (force && (*cp == INVEN_FORCE))
1820 item_tester_hook = NULL;
1821 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1826 else if (floor && (*cp < 0))
1828 if (prev_tag && command_cmd)
1830 /* Scan all objects in the grid */
1831 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
1833 /* Look up the tag */
1834 if (get_tag_floor(&k, prev_tag, floor_list, floor_num))
1836 /* Accept that choice */
1837 (*cp) = 0 - floor_list[k];
1839 /* Forget restrictions */
1841 item_tester_hook = NULL;
1842 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1848 prev_tag = '\0'; /* prev_tag is no longer effective */
1851 /* Validate the item */
1852 else if (item_tester_okay(¤t_floor_ptr->o_list[0 - (*cp)], tval) || (mode & USE_FULL))
1854 /* Forget restrictions */
1856 item_tester_hook = NULL;
1857 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1864 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
1865 (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
1867 if (prev_tag && command_cmd)
1869 /* Look up the tag and validate the item */
1870 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN, tval)) /* Reject */;
1871 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
1872 else if (!get_item_okay(k)) /* Reject */;
1875 /* Accept that choice */
1878 /* Forget restrictions */
1880 item_tester_hook = NULL;
1881 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1887 prev_tag = '\0'; /* prev_tag is no longer effective */
1890 /* Verify the item */
1891 else if (get_item_okay(*cp))
1893 /* Forget restrictions */
1895 item_tester_hook = NULL;
1896 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1910 /* No item selected */
1914 /* Full p_ptr->inventory_list */
1916 i2 = INVEN_PACK - 1;
1918 /* Forbid p_ptr->inventory_list */
1919 if (!inven) i2 = -1;
1922 for (j = 0; j < INVEN_PACK; j++)
1923 if (item_tester_okay(&p_ptr->inventory_list[j], tval) || (mode & USE_FULL)) max_inven++;
1926 /* Restrict p_ptr->inventory_list indexes */
1927 while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
1928 while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
1931 /* Full equipment */
1933 e2 = INVEN_TOTAL - 1;
1935 /* Forbid equipment */
1936 if (!equip) e2 = -1;
1939 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
1940 if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&p_ptr->inventory_list[j], tval) || (mode & USE_FULL)) max_equip++;
1941 if (p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) max_equip++;
1944 /* Restrict equipment indexes */
1945 while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
1946 while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
1948 if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
1952 if (e2 < INVEN_LARM) e2 = INVEN_LARM;
1954 else if (p_ptr->hidarite) e1 = INVEN_RARM;
1958 /* Count "okay" floor items */
1961 /* Restrict floor usage */
1964 /* Scan all objects in the grid */
1965 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
1968 /* Accept p_ptr->inventory_list */
1969 if (i1 <= i2) allow_inven = TRUE;
1971 /* Accept equipment */
1972 if (e1 <= e2) allow_equip = TRUE;
1975 if (floor_num) allow_floor = TRUE;
1977 /* Require at least one legal choice */
1978 if (!allow_inven && !allow_equip && !allow_floor)
1980 /* Cancel p_ptr->command_see */
1981 command_see = FALSE;
1991 /* Analyze choices */
1994 /* Hack -- Start on equipment if requested */
1995 if (command_see && (command_wrk == (USE_EQUIP))
1998 command_wrk = (USE_EQUIP);
2001 /* Use p_ptr->inventory_list if allowed */
2002 else if (allow_inven)
2004 command_wrk = (USE_INVEN);
2007 /* Use equipment if allowed */
2008 else if (allow_equip)
2010 command_wrk = (USE_EQUIP);
2013 /* Use floor if allowed */
2014 else if (allow_floor)
2016 command_wrk = (USE_FLOOR);
2021 * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
2023 if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
2025 /* Hack -- start out in "display" mode */
2031 /* Repeat until done */
2034 COMMAND_CODE get_item_label = 0;
2041 for (j = 0; j < 8; j++)
2044 if (!angband_term[j]) continue;
2046 /* Count windows displaying inven */
2047 if (window_flag[j] & (PW_INVEN)) ni++;
2049 /* Count windows displaying equip */
2050 if (window_flag[j] & (PW_EQUIP)) ne++;
2053 /* Toggle if needed */
2054 if ((command_wrk == (USE_EQUIP) && ni && !ne) ||
2055 (command_wrk == (USE_INVEN) && !ni && ne))
2058 toggle_inven_equip();
2064 p_ptr->window |= (PW_INVEN | PW_EQUIP);
2067 /* Inventory screen */
2068 if (command_wrk == (USE_INVEN))
2070 /* Extract the legal requests */
2074 /* Redraw if needed */
2075 if (command_see) get_item_label = show_inven(menu_line, mode, tval);
2078 /* Equipment screen */
2079 else if (command_wrk == (USE_EQUIP))
2081 /* Extract the legal requests */
2082 n1 = I2A(e1 - INVEN_RARM);
2083 n2 = I2A(e2 - INVEN_RARM);
2085 /* Redraw if needed */
2086 if (command_see) get_item_label = show_equip(menu_line, mode, tval);
2090 else if (command_wrk == (USE_FLOOR))
2093 k = MIN(floor_top + 23, floor_num) - 1;
2095 /* Extract the legal requests */
2096 n1 = I2A(j - floor_top);
2097 n2 = I2A(k - floor_top);
2099 /* Redraw if needed */
2100 if (command_see) get_item_label = show_floor(menu_line, p_ptr->y, p_ptr->x, &min_width);
2103 /* Viewing p_ptr->inventory_list */
2104 if (command_wrk == (USE_INVEN))
2106 /* Begin the prompt */
2107 sprintf(out_val, _("持ち物:", "Inven:"));
2111 /* Build the prompt */
2112 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2113 index_to_label(i1), index_to_label(i2));
2116 strcat(out_val, tmp_val);
2119 /* Indicate ability to "view" */
2120 if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2126 strcat(out_val, _(" '/' 装備品,", " / for Equip,"));
2127 else if (allow_floor)
2128 strcat(out_val, _(" '6' 装備品,", " 6 for Equip,"));
2130 strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
2137 strcat(out_val, _(" '-'床上,", " - for floor,"));
2138 else if (allow_equip)
2139 strcat(out_val, _(" '4' 床上,", " 4 for floor,"));
2141 strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
2145 /* Viewing equipment */
2146 else if (command_wrk == (USE_EQUIP))
2148 /* Begin the prompt */
2149 sprintf(out_val, _("装備品:", "Equip:"));
2153 /* Build the prompt */
2154 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2155 index_to_label(e1), index_to_label(e2));
2158 strcat(out_val, tmp_val);
2161 /* Indicate ability to "view" */
2162 if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2168 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
2169 else if (allow_floor)
2170 strcat(out_val, _(" '4' 持ち物,", " 4 for Inven,"));
2172 strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
2179 strcat(out_val, _(" '-'床上,", " - for floor,"));
2180 else if (allow_inven)
2181 strcat(out_val, _(" '6' 床上,", " 6 for floor,"));
2183 strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
2188 else if (command_wrk == (USE_FLOOR))
2190 /* Begin the prompt */
2191 sprintf(out_val, _("床上:", "Floor:"));
2195 /* Build the prompt */
2196 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
2199 strcat(out_val, tmp_val);
2202 /* Indicate ability to "view" */
2203 if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2207 if (allow_inven && allow_equip)
2209 strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
2211 else if (allow_inven)
2213 strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
2215 else if (allow_equip)
2217 strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
2221 else if (allow_inven)
2223 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
2225 else if (allow_equip)
2227 strcat(out_val, _(" '/'装備品,", " / for Equip,"));
2231 if (command_see && !use_menu)
2233 strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
2238 if (force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
2240 /* Finish the prompt */
2241 strcat(out_val, " ESC");
2243 /* Build the prompt */
2244 sprintf(tmp_val, "(%s) %s", out_val, pmt);
2246 /* Show the prompt */
2255 if (command_wrk == USE_INVEN) max_line = max_inven;
2256 else if (command_wrk == USE_EQUIP) max_line = max_equip;
2257 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
2273 menu_line += (max_line - 1);
2289 /* Verify legality */
2290 if (command_wrk == (USE_INVEN))
2292 if (allow_floor) command_wrk = USE_FLOOR;
2293 else if (allow_equip) command_wrk = USE_EQUIP;
2300 else if (command_wrk == (USE_EQUIP))
2302 if (allow_inven) command_wrk = USE_INVEN;
2303 else if (allow_floor) command_wrk = USE_FLOOR;
2310 else if (command_wrk == (USE_FLOOR))
2312 if (allow_equip) command_wrk = USE_EQUIP;
2313 else if (allow_inven) command_wrk = USE_INVEN;
2326 /* Hack -- Fix screen */
2333 /* Switch inven/equip */
2334 if (command_wrk == USE_INVEN) max_line = max_inven;
2335 else if (command_wrk == USE_EQUIP) max_line = max_equip;
2336 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
2337 if (menu_line > max_line) menu_line = max_line;
2339 /* Need to redraw */
2347 /* Verify legality */
2348 if (command_wrk == (USE_INVEN))
2350 if (allow_equip) command_wrk = USE_EQUIP;
2351 else if (allow_floor) command_wrk = USE_FLOOR;
2358 else if (command_wrk == (USE_EQUIP))
2360 if (allow_floor) command_wrk = USE_FLOOR;
2361 else if (allow_inven) command_wrk = USE_INVEN;
2368 else if (command_wrk == (USE_FLOOR))
2370 if (allow_inven) command_wrk = USE_INVEN;
2371 else if (allow_equip) command_wrk = USE_EQUIP;
2384 /* Hack -- Fix screen */
2391 /* Switch inven/equip */
2392 if (command_wrk == USE_INVEN) max_line = max_inven;
2393 else if (command_wrk == USE_EQUIP) max_line = max_equip;
2394 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
2395 if (menu_line > max_line) menu_line = max_line;
2397 /* Need to redraw */
2406 if (command_wrk == USE_FLOOR)
2409 (*cp) = -get_item_label;
2413 /* Validate the item */
2414 if (!get_item_okay(get_item_label))
2420 /* Allow player to "refuse" certain actions */
2421 if (!get_item_allow(get_item_label))
2427 /* Accept that choice */
2428 (*cp) = get_item_label;
2445 if (menu_line > max_line) menu_line -= max_line;
2466 command_see = FALSE;
2487 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
2489 if (command_wrk != (USE_FLOOR)) break;
2491 /* Get the object being moved. */
2492 o_idx = g_ptr->o_idx;
2494 /* Only rotate a pile of two or more objects. */
2495 if (!(o_idx && current_floor_ptr->o_list[o_idx].next_o_idx)) break;
2497 /* Remove the first object from the list. */
2498 excise_object_idx(o_idx);
2500 /* Find end of the list. */
2502 while (current_floor_ptr->o_list[i].next_o_idx)
2503 i = current_floor_ptr->o_list[i].next_o_idx;
2505 /* Add after the last object. */
2506 current_floor_ptr->o_list[i].next_o_idx = o_idx;
2508 /* Re-scan floor list */
2509 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2511 /* Hack -- Fix screen */
2523 if (command_wrk == (USE_INVEN))
2530 command_wrk = (USE_EQUIP);
2532 else if (command_wrk == (USE_EQUIP))
2539 command_wrk = (USE_INVEN);
2541 else if (command_wrk == (USE_FLOOR))
2545 command_wrk = (USE_INVEN);
2547 else if (allow_equip)
2549 command_wrk = (USE_EQUIP);
2558 /* Hack -- Fix screen */
2565 /* Need to redraw */
2578 * If we are already examining the floor, and there
2579 * is only one item, we will always select it.
2580 * If we aren't examining the floor and there is only
2581 * one item, we will select it if floor_query_flag
2586 if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag))
2589 k = 0 - floor_list[0];
2591 /* Allow player to "refuse" certain actions */
2592 if (!get_item_allow(k))
2598 /* Accept that choice */
2607 /* Hack -- Fix screen */
2614 command_wrk = (USE_FLOOR);
2620 case '1': case '2': case '3':
2621 case '4': case '5': case '6':
2622 case '7': case '8': case '9':
2624 if (command_wrk != USE_FLOOR)
2626 /* Look up the tag */
2627 if (!get_tag(&k, which, command_wrk, tval))
2633 /* Hack -- Validate the item */
2634 if ((k < INVEN_RARM) ? !inven : !equip)
2640 /* Validate the item */
2641 if (!get_item_okay(k))
2649 /* Look up the alphabetical tag */
2650 if (get_tag_floor(&k, which, floor_list, floor_num))
2653 k = 0 - floor_list[k];
2662 /* Allow player to "refuse" certain actions */
2663 if (!get_item_allow(k))
2669 /* Accept that choice */
2681 /* Choose "default" p_ptr->inventory_list item */
2682 if (command_wrk == (USE_INVEN))
2684 k = ((i1 == i2) ? i1 : -1);
2687 /* Choose "default" equipment item */
2688 else if (command_wrk == (USE_EQUIP))
2690 k = ((e1 == e2) ? e1 : -1);
2693 /* Choose "default" floor item */
2694 else if (command_wrk == (USE_FLOOR))
2699 k = 0 - floor_list[0];
2701 /* Allow player to "refuse" certain actions */
2702 if (!get_item_allow(k))
2708 /* Accept that choice */
2716 /* Validate the item */
2717 if (!get_item_okay(k))
2723 /* Allow player to "refuse" certain actions */
2724 if (!get_item_allow(k))
2730 /* Accept that choice */
2754 if (command_wrk != USE_FLOOR)
2756 bool not_found = FALSE;
2758 /* Look up the alphabetical tag */
2759 if (!get_tag(&k, which, command_wrk, tval))
2764 /* Hack -- Validate the item */
2765 else if ((k < INVEN_RARM) ? !inven : !equip)
2770 /* Validate the item */
2771 else if (!get_item_okay(k))
2778 /* Accept that choice */
2788 /* Look up the alphabetical tag */
2789 if (get_tag_floor(&k, which, floor_list, floor_num))
2792 k = 0 - floor_list[k];
2794 /* Accept that choice */
2803 /* Extract "query" setting */
2804 ver = isupper(which);
2805 which = (char)tolower(which);
2807 /* Convert letter to p_ptr->inventory_list index */
2808 if (command_wrk == (USE_INVEN))
2810 if (which == '(') k = i1;
2811 else if (which == ')') k = i2;
2812 else k = label_to_inven(which);
2815 /* Convert letter to equipment index */
2816 else if (command_wrk == (USE_EQUIP))
2818 if (which == '(') k = e1;
2819 else if (which == ')') k = e2;
2820 else k = label_to_equip(which);
2823 /* Convert letter to floor index */
2824 else if (command_wrk == USE_FLOOR)
2826 if (which == '(') k = 0;
2827 else if (which == ')') k = floor_num - 1;
2828 else k = islower(which) ? A2I(which) : -1;
2829 if (k < 0 || k >= floor_num || k >= 23)
2836 k = 0 - floor_list[k];
2839 /* Validate the item */
2840 if ((command_wrk != USE_FLOOR) && !get_item_okay(k))
2846 /* Verify the item */
2847 if (ver && !verify(_("本当に", "Try"), k))
2853 /* Allow player to "refuse" certain actions */
2854 if (!get_item_allow(k))
2860 /* Accept that choice */
2870 /* Fix the screen if necessary */
2875 /* Hack -- Cancel "display" */
2876 command_see = FALSE;
2880 /* Forget the tval restriction */
2883 /* Forget the item_tester_hook restriction */
2884 item_tester_hook = NULL;
2887 /* Clean up 'show choices' */
2888 /* Toggle again if needed */
2889 if (toggle) toggle_inven_equip();
2891 p_ptr->window |= (PW_INVEN | PW_EQUIP);
2894 /* Clear the prompt line */
2897 /* Warning if needed */
2898 if (oops && str) msg_print(str);
2903 if (command_cmd) prev_tag = cur_tag;
2904 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2910 * @brief 床上のアイテムを拾う選択用サブルーチン
2911 * @return プレイヤーによりアイテムが選択されたならTRUEを返す。
2913 static bool py_pickup_floor_aux(void)
2915 OBJECT_IDX this_o_idx;
2919 /* Restrict the choices */
2920 item_tester_hook = inven_carry_okay;
2923 q = _("どれを拾いますか?", "Get which item? ");
2924 s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
2926 if (choose_object(&item, q, s, (USE_FLOOR)))
2928 this_o_idx = 0 - item;
2935 /* Pick up the object */
2936 py_pickup_aux(this_o_idx);
2942 * @brief 床上のアイテムを拾うメイン処理
2943 * @param pickup FALSEなら金銭の自動拾いのみを行う/ FALSE then only gold will be picked up
2946 * This is called by py_pickup() when easy_floor is TRUE.
2948 void py_pickup_floor(bool pickup)
2950 OBJECT_IDX this_o_idx, next_o_idx = 0;
2952 GAME_TEXT o_name[MAX_NLEN];
2956 OBJECT_IDX floor_o_idx = 0;
2960 /* Scan the pile of objects */
2961 for (this_o_idx = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
2963 /* Access the object */
2964 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
2966 object_desc(o_name, o_ptr, 0);
2968 /* Access the next object */
2969 next_o_idx = o_ptr->next_o_idx;
2971 disturb(FALSE, FALSE);
2974 if (o_ptr->tval == TV_GOLD)
2977 msg_format(" $%ld の価値がある%sを見つけた。",
2978 (long)o_ptr->pval, o_name);
2980 msg_format("You have found %ld gold pieces worth of %s.",
2981 (long)o_ptr->pval, o_name);
2984 /* Collect the gold */
2985 p_ptr->au += o_ptr->pval;
2988 p_ptr->redraw |= (PR_GOLD);
2990 p_ptr->window |= (PW_PLAYER);
2992 /* Delete the gold */
2993 delete_object_idx(this_o_idx);
2995 /* Check the next object */
2998 else if (o_ptr->marked & OM_NOMSG)
3000 /* If 0 or 1 non-NOMSG items are in the pile, the NOMSG ones are
3001 * ignored. Otherwise, they are included in the prompt. */
3002 o_ptr->marked &= ~(OM_NOMSG);
3006 /* Count non-gold objects that can be picked up. */
3007 if (inven_carry_okay(o_ptr))
3012 /* Count non-gold objects */
3015 /* Remember this index */
3016 floor_o_idx = this_o_idx;
3019 /* There are no non-gold objects */
3023 /* Mention the number of objects */
3029 /* Access the object */
3030 o_ptr = ¤t_floor_ptr->o_list[floor_o_idx];
3032 #ifdef ALLOW_EASY_SENSE
3034 /* Option: Make object sensing easy */
3037 /* Sense the object */
3038 (void)sense_object(o_ptr);
3041 #endif /* ALLOW_EASY_SENSE */
3043 object_desc(o_name, o_ptr, 0);
3045 msg_format(_("%sがある。", "You see %s."), o_name);
3048 /* Multiple objects */
3051 msg_format(_("%d 個のアイテムの山がある。", "You see a pile of %d items."), floor_num);
3057 /* The player has no room for anything on the floor. */
3063 /* Access the object */
3064 o_ptr = ¤t_floor_ptr->o_list[floor_o_idx];
3066 #ifdef ALLOW_EASY_SENSE
3068 /* Option: Make object sensing easy */
3071 /* Sense the object */
3072 (void)sense_object(o_ptr);
3075 #endif /* ALLOW_EASY_SENSE */
3077 object_desc(o_name, o_ptr, 0);
3079 msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
3082 /* Multiple objects */
3085 msg_print(_("ザックには床にあるどのアイテムも入らない。", "You have no room for any of the objects on the floor."));
3095 /* Hack -- query every object */
3096 if (carry_query_flag)
3098 char out_val[MAX_NLEN + 20];
3100 /* Access the object */
3101 o_ptr = ¤t_floor_ptr->o_list[floor_o_idx];
3103 #ifdef ALLOW_EASY_SENSE
3105 /* Option: Make object sensing easy */
3108 /* Sense the object */
3109 (void)sense_object(o_ptr);
3112 #endif /* ALLOW_EASY_SENSE */
3114 object_desc(o_name, o_ptr, 0);
3116 /* Build a prompt */
3117 (void)sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
3119 /* Ask the user to confirm */
3120 if (!get_check(out_val))
3126 /* Access the object */
3127 o_ptr = ¤t_floor_ptr->o_list[floor_o_idx];
3129 #ifdef ALLOW_EASY_SENSE
3131 /* Option: Make object sensing easy */
3134 /* Sense the object */
3135 (void)sense_object(o_ptr);
3138 #endif /* ALLOW_EASY_SENSE */
3140 /* Pick up the object */
3141 py_pickup_aux(floor_o_idx);
3144 /* Allow the user to choose an object */
3147 while (can_pickup--)
3149 if (!py_pickup_floor_aux()) break;
3157 * @brief 所持アイテム一覧を表示する /
3158 * Choice window "shadow" of the "show_inven()" function
3161 void display_inven(OBJECT_TYPE_VALUE tval)
3163 register int i, n, z = 0;
3165 TERM_COLOR attr = TERM_WHITE;
3167 GAME_TEXT o_name[MAX_NLEN];
3170 Term_get_size(&wid, &hgt);
3172 for (i = 0; i < INVEN_PACK; i++)
3174 o_ptr = &p_ptr->inventory_list[i];
3175 if (!o_ptr->k_idx) continue;
3179 for (i = 0; i < z; i++)
3181 o_ptr = &p_ptr->inventory_list[i];
3182 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
3183 if (item_tester_okay(o_ptr, tval))
3185 tmp_val[0] = index_to_label(i);
3189 Term_putstr(0, i, 3, TERM_WHITE, tmp_val);
3190 object_desc(o_name, o_ptr, 0);
3192 attr = tval_to_attr[o_ptr->tval % 128];
3198 Term_putstr(3, i, n, attr, o_name);
3199 Term_erase(3 + n, i, 255);
3203 int wgt = o_ptr->weight * o_ptr->number;
3205 sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
3207 sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
3209 prt(tmp_val, i, wid - 9);
3213 for (i = z; i < hgt; i++)
3215 Term_erase(0, i, 255);
3221 * @brief 装備アイテムの表示を行う /
3222 * Display the equipment.
3223 * @param target_item アイテムの選択処理を行うか否か。
3224 * @return 選択したアイテムのタグ
3226 COMMAND_CODE show_equip(int target_item, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
3230 int col, cur_col, len;
3233 GAME_TEXT o_name[MAX_NLEN];
3234 COMMAND_CODE out_index[23];
3235 TERM_COLOR out_color[23];
3236 char out_desc[23][MAX_NLEN];
3237 COMMAND_CODE target_item_label = 0;
3239 char equip_label[52 + 1];
3241 /* Starting column */
3244 Term_get_size(&wid, &hgt);
3246 /* Maximal length */
3247 len = wid - col - 1;
3250 /* Scan the equipment list */
3251 for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
3253 o_ptr = &p_ptr->inventory_list[i];
3255 /* Is this item acceptable? */
3256 if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr, tval) || (mode & USE_FULL)) &&
3257 (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
3258 (mode & IGNORE_BOTHHAND_SLOT))) continue;
3260 object_desc(o_name, o_ptr, 0);
3262 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
3264 (void)strcpy(out_desc[k], _("(武器を両手持ち)", "(wielding with two-hands)"));
3265 out_color[k] = TERM_WHITE;
3269 (void)strcpy(out_desc[k], o_name);
3270 out_color[k] = tval_to_attr[o_ptr->tval % 128];
3274 /* Grey out charging items */
3277 out_color[k] = TERM_L_DARK;
3280 /* Extract the maximal length (see below) */
3282 l = strlen(out_desc[k]) + (2 + 1);
3284 l = strlen(out_desc[k]) + (2 + 3);
3288 /* Increase length for labels (if needed) */
3290 if (show_labels) l += (7 + 2);
3292 if (show_labels) l += (14 + 2);
3296 /* Increase length for weight (if needed) */
3297 if (show_weights) l += 9;
3299 if (show_item_graph) l += 2;
3301 /* Maintain the max-length */
3302 if (l > len) len = l;
3304 /* Advance the entry */
3308 /* Hack -- Find a column to start in */
3310 col = (len > wid - 6) ? 0 : (wid - len - 1);
3312 col = (len > wid - 4) ? 0 : (wid - len - 1);
3315 prepare_label_string(equip_label, USE_EQUIP, tval);
3317 /* Output each entry */
3318 for (j = 0; j < k; j++)
3321 o_ptr = &p_ptr->inventory_list[i];
3323 /* Clear the line */
3324 prt("", j + 1, col ? col - 2 : col);
3326 if (use_menu && target_item)
3328 if (j == (target_item - 1))
3330 strcpy(tmp_val, _("》", "> "));
3331 target_item_label = i;
3333 else strcpy(tmp_val, " ");
3335 else if (i >= INVEN_RARM)
3337 /* Prepare an index --(-- */
3338 sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
3342 /* Prepare an index --(-- */
3343 sprintf(tmp_val, "%c)", index_to_label(i));
3346 /* Clear the line with the (possibly indented) index */
3347 put_str(tmp_val, j + 1, col);
3351 /* Display graphics for object, if desired */
3352 if (show_item_graph)
3354 TERM_COLOR a = object_attr(o_ptr);
3355 SYMBOL_CODE c = object_char(o_ptr);
3356 Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
3357 if (use_bigtile) cur_col++;
3365 /* Mention the use */
3366 (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
3368 put_str(tmp_val, j + 1, cur_col);
3370 /* Display the entry itself */
3371 c_put_str(out_color[j], out_desc[j], j + 1, _(cur_col + 9, cur_col + 16));
3377 /* Display the entry itself */
3378 c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
3381 /* Display the weight if needed */
3384 int wgt = o_ptr->weight * o_ptr->number;
3386 (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
3388 (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
3391 prt(tmp_val, j + 1, wid - 9);
3395 /* Make a "shadow" below the list (only if needed) */
3396 if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
3398 /* Save the new column */
3401 return target_item_label;