OSDN Git Service

cb3414393449abddbf42ef3efdd8b4d82839b4be
[hengband/hengband.git] / src / player-inventory.c
1 #include "angband.h"
2 #include "core.h"
3 #include "util.h"
4 #include "term.h"
5 #include "object.h"
6 #include "objectkind.h"
7 #include "object-flavor.h"
8 #include "floor.h"
9 #include "player-move.h"
10
11 #include "view-mainwindow.h"
12
13 bool select_ring_slot;
14
15 /*!
16  * @brief プレイヤーの所持/装備オブジェクトIDが指輪枠かを返す /
17  * @param i プレイヤーの所持/装備オブジェクトID
18  * @return 指輪枠ならばTRUEを返す。
19  */
20 bool is_ring_slot(int i)
21 {
22         return (i == INVEN_RIGHT) || (i == INVEN_LEFT);
23 }
24
25
26 /*!
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
30  */
31 INVENTORY_IDX label_to_equip(int c)
32 {
33         INVENTORY_IDX i;
34
35         /* Convert */
36         i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1) + INVEN_RARM;
37
38         /* Verify the index */
39         if ((i < INVEN_RARM) || (i >= INVEN_TOTAL)) return (-1);
40
41         if (select_ring_slot) return is_ring_slot(i) ? i : -1;
42
43         /* Empty slots can never be chosen */
44         if (!p_ptr->inventory_list[i].k_idx) return (-1);
45
46         /* Return the index */
47         return (i);
48 }
49
50
51
52
53 /*!
54  * @brief 装備アイテム一覧を表示する /
55  * Choice window "shadow" of the "show_equip()" function
56  * @return なし
57  */
58 void display_equip(OBJECT_TYPE_VALUE tval)
59 {
60         register int i, n;
61         object_type *o_ptr;
62         TERM_COLOR attr = TERM_WHITE;
63         char tmp_val[80];
64         GAME_TEXT o_name[MAX_NLEN];
65         TERM_LEN wid, hgt;
66
67         Term_get_size(&wid, &hgt);
68
69         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
70         {
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))
74                 {
75                         tmp_val[0] = index_to_label(i);
76                         tmp_val[1] = ')';
77                 }
78
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)
81                 {
82                         strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
83                         attr = TERM_WHITE;
84                 }
85                 else
86                 {
87                         object_desc(o_name, o_ptr, 0);
88                         attr = tval_to_attr[o_ptr->tval % 128];
89                 }
90
91                 n = strlen(o_name);
92                 if (o_ptr->timeout)
93                 {
94                         attr = TERM_L_DARK;
95                 }
96                 Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
97
98                 Term_erase(3 + n, i - INVEN_RARM, 255);
99
100                 if (show_weights)
101                 {
102                         int wgt = o_ptr->weight * o_ptr->number;
103 #ifdef JP
104                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
105 #else
106                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
107 #endif
108
109                         prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
110                 }
111
112                 if (show_labels)
113                 {
114                         Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
115                         prt(mention_use(i), i - INVEN_RARM, wid - 15);
116                 }
117         }
118
119         for (i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
120         {
121                 Term_erase(0, i, 255);
122         }
123 }
124
125 /*!
126  * @brief サブウィンドウに所持品、装備品リストの表示を行う /
127  * Flip "inven" and "equip" in any sub-windows
128  * @return なし
129  */
130 void toggle_inven_equip(void)
131 {
132         int j;
133
134         /* Scan windows */
135         for (j = 0; j < 8; j++)
136         {
137                 /* Unused */
138                 if (!angband_term[j]) continue;
139
140                 /* Flip inven to equip */
141                 if (window_flag[j] & (PW_INVEN))
142                 {
143                         /* Flip flags */
144                         window_flag[j] &= ~(PW_INVEN);
145                         window_flag[j] |= (PW_EQUIP);
146
147                         p_ptr->window |= (PW_EQUIP);
148                 }
149
150                 /* Flip inven to equip */
151                 else if (window_flag[j] & (PW_EQUIP))
152                 {
153                         /* Flip flags */
154                         window_flag[j] &= ~(PW_EQUIP);
155                         window_flag[j] |= (PW_INVEN);
156
157                         p_ptr->window |= (PW_INVEN);
158                 }
159         }
160 }
161
162
163 /*!
164  * @brief プレイヤーの所持/装備オブジェクトが正規のものかを返す /
165  * Auxiliary function for "get_item()" -- test an index
166  * @param i 選択アイテムID
167  * @return 正規のIDならばTRUEを返す。
168  */
169 bool get_item_okay(OBJECT_IDX i)
170 {
171         /* Illegal items */
172         if ((i < 0) || (i >= INVEN_TOTAL)) return (FALSE);
173
174         if (select_ring_slot) return is_ring_slot(i);
175
176         /* Verify the item */
177         if (!item_tester_okay(&p_ptr->inventory_list[i], item_tester_tval)) return (FALSE);
178
179         /* Assume okay */
180         return (TRUE);
181 }
182
183 /*!
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).
188  */
189 bool can_get_item(OBJECT_TYPE_VALUE tval)
190 {
191         int j;
192         OBJECT_IDX floor_list[23];
193         ITEM_NUMBER floor_num = 0;
194
195         for (j = 0; j < INVEN_TOTAL; j++)
196                 if (item_tester_okay(&p_ptr->inventory_list[j], tval))
197                         return TRUE;
198
199         floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
200         if (floor_num)
201                 return TRUE;
202
203         return FALSE;
204 }
205
206
207 /*!
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を返す
215  * @details
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
219  *\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
222  */
223 static bool get_tag_floor(COMMAND_CODE *cp, char tag, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
224 {
225         COMMAND_CODE i;
226         concptr s;
227
228         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
229
230         /* Check every object in the grid */
231         for (i = 0; i < floor_num && i < 23; i++)
232         {
233                 object_type *o_ptr = &current_floor_ptr->o_list[floor_list[i]];
234
235                 /* Skip empty inscriptions */
236                 if (!o_ptr->inscription) continue;
237
238                 /* Find a '@' */
239                 s = my_strchr(quark_str(o_ptr->inscription), '@');
240
241                 /* Process all tags */
242                 while (s)
243                 {
244                         /* Check the special tags */
245                         if ((s[1] == command_cmd) && (s[2] == tag))
246                         {
247                                 /* Save the actual floor object ID */
248                                 *cp = i;
249
250                                 /* Success */
251                                 return (TRUE);
252                         }
253
254                         /* Find another '@' */
255                         s = my_strchr(s + 1, '@');
256                 }
257         }
258
259
260         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
261
262         /* Don't allow {@#} with '#' being alphabet */
263         if (tag < '0' || '9' < tag)
264         {
265                 /* No such tag */
266                 return FALSE;
267         }
268
269         /* Check every object in the grid */
270         for (i = 0; i < floor_num && i < 23; i++)
271         {
272                 object_type *o_ptr = &current_floor_ptr->o_list[floor_list[i]];
273
274                 /* Skip empty inscriptions */
275                 if (!o_ptr->inscription) continue;
276
277                 /* Find a '@' */
278                 s = my_strchr(quark_str(o_ptr->inscription), '@');
279
280                 /* Process all tags */
281                 while (s)
282                 {
283                         /* Check the normal tags */
284                         if (s[1] == tag)
285                         {
286                                 /* Save the floor object ID */
287                                 *cp = i;
288
289                                 /* Success */
290                                 return (TRUE);
291                         }
292
293                         /* Find another '@' */
294                         s = my_strchr(s + 1, '@');
295                 }
296         }
297
298         /* No such tag */
299         return (FALSE);
300 }
301
302
303 /*!
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を返す
310  * @details
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
314  *\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
317  */
318 static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
319 {
320         COMMAND_CODE i;
321         COMMAND_CODE start, end;
322         concptr s;
323
324         /* Extract index from mode */
325         switch (mode)
326         {
327         case USE_EQUIP:
328                 start = INVEN_RARM;
329                 end = INVEN_TOTAL - 1;
330                 break;
331
332         case USE_INVEN:
333                 start = 0;
334                 end = INVEN_PACK - 1;
335                 break;
336
337         default:
338                 return FALSE;
339         }
340
341         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
342
343         /* Check every p_ptr->inventory_list object */
344         for (i = start; i <= end; i++)
345         {
346                 object_type *o_ptr = &p_ptr->inventory_list[i];
347                 if (!o_ptr->k_idx) continue;
348
349                 /* Skip empty inscriptions */
350                 if (!o_ptr->inscription) continue;
351
352                 /* Skip non-choice */
353                 if (!item_tester_okay(o_ptr, tval) && !(mode & USE_FULL)) continue;
354
355                 /* Find a '@' */
356                 s = my_strchr(quark_str(o_ptr->inscription), '@');
357
358                 /* Process all tags */
359                 while (s)
360                 {
361                         /* Check the special tags */
362                         if ((s[1] == command_cmd) && (s[2] == tag))
363                         {
364                                 /* Save the actual p_ptr->inventory_list ID */
365                                 *cp = i;
366
367                                 /* Success */
368                                 return (TRUE);
369                         }
370
371                         /* Find another '@' */
372                         s = my_strchr(s + 1, '@');
373                 }
374         }
375
376
377         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
378
379         /* Don't allow {@#} with '#' being alphabet */
380         if (tag < '0' || '9' < tag)
381         {
382                 /* No such tag */
383                 return FALSE;
384         }
385
386         /* Check every object */
387         for (i = start; i <= end; i++)
388         {
389                 object_type *o_ptr = &p_ptr->inventory_list[i];
390                 if (!o_ptr->k_idx) continue;
391
392                 /* Skip empty inscriptions */
393                 if (!o_ptr->inscription) continue;
394
395                 /* Skip non-choice */
396                 if (!item_tester_okay(o_ptr, tval) && !(mode & USE_FULL)) continue;
397
398                 /* Find a '@' */
399                 s = my_strchr(quark_str(o_ptr->inscription), '@');
400
401                 /* Process all tags */
402                 while (s)
403                 {
404                         /* Check the normal tags */
405                         if (s[1] == tag)
406                         {
407                                 /* Save the actual p_ptr->inventory_list ID */
408                                 *cp = i;
409
410                                 /* Success */
411                                 return (TRUE);
412                         }
413
414                         /* Find another '@' */
415                         s = my_strchr(s + 1, '@');
416                 }
417         }
418
419         /* No such tag */
420         return (FALSE);
421 }
422
423 /*!
424  * @brief タグIDにあわせてタグアルファベットのリストを返す /
425  * Move around label characters with correspond tags
426  * @param label ラベルリストを取得する文字列参照ポインタ
427  * @param mode 所持品リストか装備品リストかの切り替え
428  * @return なし
429  */
430 void prepare_label_string(char *label, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
431 {
432         concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
433         int  offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
434         int  i;
435
436         /* Prepare normal labels */
437         strcpy(label, alphabet_chars);
438
439         /* Move each label */
440         for (i = 0; i < 52; i++)
441         {
442                 COMMAND_CODE index;
443                 SYMBOL_CODE c = alphabet_chars[i];
444
445                 /* Find a tag with this label */
446                 if (get_tag(&index, c, mode, tval))
447                 {
448                         /* Delete the overwritten label */
449                         if (label[i] == c) label[i] = ' ';
450
451                         /* Move the label to the place of corresponding tag */
452                         label[index - offset] = c;
453                 }
454         }
455 }
456
457
458 /*!
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
464  * @return なし
465  */
466  /*
467   */
468 static void prepare_label_string_floor(char *label, FLOOR_IDX floor_list[], ITEM_NUMBER floor_num)
469 {
470         concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
471         int  i;
472
473         /* Prepare normal labels */
474         strcpy(label, alphabet_chars);
475
476         /* Move each label */
477         for (i = 0; i < 52; i++)
478         {
479                 COMMAND_CODE index;
480                 SYMBOL_CODE c = alphabet_chars[i];
481
482                 /* Find a tag with this label */
483                 if (get_tag_floor(&index, c, floor_list, floor_num))
484                 {
485                         /* Delete the overwritten label */
486                         if (label[i] == c) label[i] = ' ';
487
488                         /* Move the label to the place of corresponding tag */
489                         label[index] = c;
490                 }
491         }
492 }
493
494 /*!
495  * @brief 所持アイテムの表示を行う /
496  * Display the p_ptr->inventory_list.
497  * @param target_item アイテムの選択処理を行うか否か。
498  * @return 選択したアイテムのタグ
499  * @details
500  * Hack -- do not display "trailing" empty slots
501  */
502 COMMAND_CODE show_inven(int target_item, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
503 {
504         COMMAND_CODE i;
505         int j, k, l, z = 0;
506         int             col, cur_col, len;
507         object_type *o_ptr;
508         GAME_TEXT o_name[MAX_NLEN];
509         char            tmp_val[80];
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;
514         TERM_LEN wid, hgt;
515         char inven_label[52 + 1];
516
517         /* Starting column */
518         col = command_gap;
519
520         Term_get_size(&wid, &hgt);
521
522         /* Default "max-length" */
523         len = wid - col - 1;
524
525
526         /* Find the "final" slot */
527         for (i = 0; i < INVEN_PACK; i++)
528         {
529                 o_ptr = &p_ptr->inventory_list[i];
530                 if (!o_ptr->k_idx) continue;
531
532                 /* Track */
533                 z = i + 1;
534         }
535
536         prepare_label_string(inven_label, USE_INVEN, tval);
537
538         /* Display the p_ptr->inventory_list */
539         for (k = 0, i = 0; i < z; i++)
540         {
541                 o_ptr = &p_ptr->inventory_list[i];
542
543                 /* Is this item acceptable? */
544                 if (!item_tester_okay(o_ptr, tval) && !(mode & USE_FULL)) continue;
545
546                 object_desc(o_name, o_ptr, 0);
547
548                 /* Save the object index, color, and description */
549                 out_index[k] = i;
550                 out_color[k] = tval_to_attr[o_ptr->tval % 128];
551
552                 /* Grey out charging items */
553                 if (o_ptr->timeout)
554                 {
555                         out_color[k] = TERM_L_DARK;
556                 }
557
558                 (void)strcpy(out_desc[k], o_name);
559
560                 /* Find the predicted "line length" */
561                 l = strlen(out_desc[k]) + 5;
562
563                 /* Be sure to account for the weight */
564                 if (show_weights) l += 9;
565
566                 /* Account for icon if displayed */
567                 if (show_item_graph)
568                 {
569                         l += 2;
570                         if (use_bigtile) l++;
571                 }
572
573                 /* Maintain the maximum length */
574                 if (l > len) len = l;
575
576                 /* Advance to next "line" */
577                 k++;
578         }
579
580         /* Find the column to start in */
581         col = (len > wid - 4) ? 0 : (wid - len - 1);
582
583         /* Output each entry */
584         for (j = 0; j < k; j++)
585         {
586                 i = out_index[j];
587                 o_ptr = &p_ptr->inventory_list[i];
588
589                 /* Clear the line */
590                 prt("", j + 1, col ? col - 2 : col);
591
592                 if (use_menu && target_item)
593                 {
594                         if (j == (target_item - 1))
595                         {
596                                 strcpy(tmp_val, _("》", "> "));
597                                 target_item_label = i;
598                         }
599                         else strcpy(tmp_val, "  ");
600                 }
601                 else if (i <= INVEN_PACK)
602                 {
603                         /* Prepare an index --(-- */
604                         sprintf(tmp_val, "%c)", inven_label[i]);
605                 }
606                 else
607                 {
608                         /* Prepare an index --(-- */
609                         sprintf(tmp_val, "%c)", index_to_label(i));
610                 }
611
612                 /* Clear the line with the (possibly indented) index */
613                 put_str(tmp_val, j + 1, col);
614
615                 cur_col = col + 3;
616
617                 /* Display graphics for object, if desired */
618                 if (show_item_graph)
619                 {
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++;
624
625                         cur_col += 2;
626                 }
627
628
629                 /* Display the entry itself */
630                 c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
631
632                 /* Display the weight if needed */
633                 if (show_weights)
634                 {
635                         int wgt = o_ptr->weight * o_ptr->number;
636 #ifdef JP
637                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
638 #else
639                         (void)sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
640 #endif
641
642                         prt(tmp_val, j + 1, wid - 9);
643                 }
644         }
645
646         /* Make a "shadow" below the list (only if needed) */
647         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
648
649         /* Save the new column */
650         command_gap = col;
651
652         return target_item_label;
653 }
654
655
656 /*!
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".
663  */
664 static bool verify(concptr prompt, INVENTORY_IDX item)
665 {
666         GAME_TEXT o_name[MAX_NLEN];
667         char        out_val[MAX_NLEN + 20];
668         object_type *o_ptr;
669
670
671         /* Inventory */
672         if (item >= 0)
673         {
674                 o_ptr = &p_ptr->inventory_list[item];
675         }
676
677         /* Floor */
678         else
679         {
680                 o_ptr = &current_floor_ptr->o_list[0 - item];
681         }
682         object_desc(o_name, o_ptr, 0);
683
684         /* Prompt */
685         (void)sprintf(out_val, _("%s%sですか? ", "%s %s? "), prompt, o_name);
686
687         /* Query */
688         return (get_check(out_val));
689 }
690
691
692 /*!
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
698  */
699 static bool get_item_allow(INVENTORY_IDX item)
700 {
701         concptr s;
702         object_type *o_ptr;
703         if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
704
705         /* Inventory */
706         if (item >= 0)
707         {
708                 o_ptr = &p_ptr->inventory_list[item];
709         }
710
711         /* Floor */
712         else
713         {
714                 o_ptr = &current_floor_ptr->o_list[0 - item];
715         }
716
717         /* No inscription */
718         if (!o_ptr->inscription) return (TRUE);
719
720         /* Find a '!' */
721         s = my_strchr(quark_str(o_ptr->inscription), '!');
722
723         /* Process preventions */
724         while (s)
725         {
726                 /* Check the "restriction" */
727                 if ((s[1] == command_cmd) || (s[1] == '*'))
728                 {
729                         /* Verify the choice */
730                         if (!verify(_("本当に", "Really try"), item)) return (FALSE);
731                 }
732
733                 /* Find another '!' */
734                 s = my_strchr(s + 1, '!');
735         }
736
737         /* Allow it */
738         return (TRUE);
739 }
740
741
742 /*!
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
751  * @details
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
754  *\n
755  * All "item_tester" restrictions are cleared before this function returns.\n
756  *\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
760  *\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
763  *\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
767  *\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
772  *\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
775  *\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
778  *\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
781  *\n
782  * If no item is selected, we do nothing to "cp", and return FALSE.\n
783  *\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
787  *\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
790  *\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
793  *\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
796  */
797 bool get_item(OBJECT_IDX *cp, concptr pmt, concptr str, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
798 {
799         OBJECT_IDX this_o_idx, next_o_idx = 0;
800
801         char which = ' ';
802
803         int j;
804         OBJECT_IDX k;
805         OBJECT_IDX i1, i2;
806         OBJECT_IDX e1, e2;
807
808         bool done, item;
809
810         bool oops = FALSE;
811
812         bool equip = FALSE;
813         bool inven = FALSE;
814         bool floor = FALSE;
815
816         bool allow_floor = FALSE;
817
818         bool toggle = FALSE;
819
820         char tmp_val[160];
821         char out_val[160];
822
823         int menu_line = (use_menu ? 1 : 0);
824         int max_inven = 0;
825         int max_equip = 0;
826
827         static char prev_tag = '\0';
828         char cur_tag = '\0';
829
830         if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode, tval);
831
832         /* Extract args */
833         if (mode & USE_EQUIP) equip = TRUE;
834         if (mode & USE_INVEN) inven = TRUE;
835         if (mode & USE_FLOOR) floor = TRUE;
836
837         /* Get the item index */
838         if (repeat_pull(cp))
839         {
840                 /* the_force */
841                 if (mode & USE_FORCE && (*cp == INVEN_FORCE))
842                 {
843                         tval = 0;
844                         item_tester_hook = NULL;
845                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
846                         return (TRUE);
847                 }
848
849                 /* Floor item? */
850                 else if (floor && (*cp < 0))
851                 {
852                         object_type *o_ptr;
853
854                         /* Special index */
855                         k = 0 - (*cp);
856                         o_ptr = &current_floor_ptr->o_list[k];
857
858                         /* Validate the item */
859                         if (item_tester_okay(o_ptr, tval) || (mode & USE_FULL))
860                         {
861                                 /* Forget restrictions */
862                                 tval = 0;
863                                 item_tester_hook = NULL;
864                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
865
866                                 /* Success */
867                                 return TRUE;
868                         }
869                 }
870
871                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
872                         (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
873                 {
874                         if (prev_tag && command_cmd)
875                         {
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 */;
880                                 else
881                                 {
882                                         /* Accept that choice */
883                                         (*cp) = k;
884
885                                         /* Forget restrictions */
886                                         tval = 0;
887                                         item_tester_hook = NULL;
888                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
889
890                                         /* Success */
891                                         return TRUE;
892                                 }
893
894                                 prev_tag = '\0'; /* prev_tag is no longer effective */
895                         }
896
897                         /* Verify the item */
898                         else if (get_item_okay(*cp))
899                         {
900                                 /* Forget restrictions */
901                                 tval = 0;
902                                 item_tester_hook = NULL;
903                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
904
905                                 /* Success */
906                                 return TRUE;
907                         }
908                 }
909         }
910         msg_print(NULL);
911
912         /* Not done */
913         done = FALSE;
914
915         /* No item selected */
916         item = FALSE;
917
918
919         /* Full p_ptr->inventory_list */
920         i1 = 0;
921         i2 = INVEN_PACK - 1;
922
923         /* Forbid p_ptr->inventory_list */
924         if (!inven) i2 = -1;
925         else if (use_menu)
926         {
927                 for (j = 0; j < INVEN_PACK; j++)
928                         if (item_tester_okay(&p_ptr->inventory_list[j], tval) || (mode & USE_FULL)) max_inven++;
929         }
930
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--;
934
935
936         /* Full equipment */
937         e1 = INVEN_RARM;
938         e2 = INVEN_TOTAL - 1;
939
940         /* Forbid equipment */
941         if (!equip) e2 = -1;
942         else if (use_menu)
943         {
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++;
947         }
948
949         /* Restrict equipment indexes */
950         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
951         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
952
953         if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
954         {
955                 if (p_ptr->migite)
956                 {
957                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
958                 }
959                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
960         }
961
962
963         /* Restrict floor usage */
964         if (floor)
965         {
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)
968                 {
969                         object_type *o_ptr;
970                         o_ptr = &current_floor_ptr->o_list[this_o_idx];
971                         next_o_idx = o_ptr->next_o_idx;
972
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;
975                 }
976         }
977
978         /* Require at least one legal choice */
979         if (!allow_floor && (i1 > i2) && (e1 > e2))
980         {
981                 /* Cancel p_ptr->command_see */
982                 command_see = FALSE;
983                 oops = TRUE;
984                 done = TRUE;
985
986                 if (mode & USE_FORCE) {
987                         *cp = INVEN_FORCE;
988                         item = TRUE;
989                 }
990         }
991
992         /* Analyze choices */
993         else
994         {
995                 /* Hack -- Start on equipment if requested */
996                 if (command_see && command_wrk && equip)
997                 {
998                         command_wrk = TRUE;
999                 }
1000
1001                 /* Use p_ptr->inventory_list if allowed */
1002                 else if (inven)
1003                 {
1004                         command_wrk = FALSE;
1005                 }
1006
1007                 /* Use equipment if allowed */
1008                 else if (equip)
1009                 {
1010                         command_wrk = TRUE;
1011                 }
1012
1013                 /* Use p_ptr->inventory_list for floor */
1014                 else
1015                 {
1016                         command_wrk = FALSE;
1017                 }
1018         }
1019
1020
1021         /*
1022          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
1023          */
1024         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
1025
1026         /* Hack -- start out in "display" mode */
1027         if (command_see)
1028         {
1029                 screen_save();
1030         }
1031
1032
1033         /* Repeat until done */
1034         while (!done)
1035         {
1036                 COMMAND_CODE get_item_label = 0;
1037
1038                 /* Show choices */
1039                 int ni = 0;
1040                 int ne = 0;
1041
1042                 /* Scan windows */
1043                 for (j = 0; j < 8; j++)
1044                 {
1045                         /* Unused */
1046                         if (!angband_term[j]) continue;
1047
1048                         /* Count windows displaying inven */
1049                         if (window_flag[j] & (PW_INVEN)) ni++;
1050
1051                         /* Count windows displaying equip */
1052                         if (window_flag[j] & (PW_EQUIP)) ne++;
1053                 }
1054
1055                 /* Toggle if needed */
1056                 if ((command_wrk && ni && !ne) || (!command_wrk && !ni && ne))
1057                 {
1058                         /* Toggle */
1059                         toggle_inven_equip();
1060
1061                         /* Track toggles */
1062                         toggle = !toggle;
1063                 }
1064
1065                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1066                 handle_stuff();
1067
1068                 /* Inventory screen */
1069                 if (!command_wrk)
1070                 {
1071                         /* Redraw if needed */
1072                         if (command_see) get_item_label = show_inven(menu_line, mode, tval);
1073                 }
1074
1075                 /* Equipment screen */
1076                 else
1077                 {
1078                         /* Redraw if needed */
1079                         if (command_see) get_item_label = show_equip(menu_line, mode, tval);
1080                 }
1081
1082                 /* Viewing p_ptr->inventory_list */
1083                 if (!command_wrk)
1084                 {
1085                         /* Begin the prompt */
1086                         sprintf(out_val, _("持ち物:", "Inven:"));
1087
1088                         /* Some legal items */
1089                         if ((i1 <= i2) && !use_menu)
1090                         {
1091                                 /* Build the prompt */
1092                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
1093                                         index_to_label(i1), index_to_label(i2));
1094
1095                                 /* Append */
1096                                 strcat(out_val, tmp_val);
1097                         }
1098
1099                         /* Indicate ability to "view" */
1100                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
1101
1102                         /* Append */
1103                         if (equip) strcat(out_val, format(_(" %s 装備品,", " %s for Equip,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "/")));
1104                 }
1105
1106                 /* Viewing equipment */
1107                 else
1108                 {
1109                         /* Begin the prompt */
1110                         sprintf(out_val, _("装備品:", "Equip:"));
1111
1112                         /* Some legal items */
1113                         if ((e1 <= e2) && !use_menu)
1114                         {
1115                                 /* Build the prompt */
1116                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
1117                                         index_to_label(e1), index_to_label(e2));
1118
1119                                 /* Append */
1120                                 strcat(out_val, tmp_val);
1121                         }
1122
1123                         /* Indicate ability to "view" */
1124                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
1125
1126                         /* Append */
1127                         if (inven) strcat(out_val, format(_(" %s 持ち物,", " %s for Inven,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "'/'")));
1128                 }
1129
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,"));
1133
1134                 /* Finish the prompt */
1135                 strcat(out_val, " ESC");
1136
1137                 /* Build the prompt */
1138                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
1139
1140                 /* Show the prompt */
1141                 prt(tmp_val, 0, 0);
1142
1143                 /* Get a key */
1144                 which = inkey();
1145
1146                 if (use_menu)
1147                 {
1148                         int max_line = (command_wrk ? max_equip : max_inven);
1149                         switch (which)
1150                         {
1151                         case ESCAPE:
1152                         case 'z':
1153                         case 'Z':
1154                         case '0':
1155                         {
1156                                 done = TRUE;
1157                                 break;
1158                         }
1159
1160                         case '8':
1161                         case 'k':
1162                         case 'K':
1163                         {
1164                                 menu_line += (max_line - 1);
1165                                 break;
1166                         }
1167
1168                         case '2':
1169                         case 'j':
1170                         case 'J':
1171                         {
1172                                 menu_line++;
1173                                 break;
1174                         }
1175
1176                         case '4':
1177                         case '6':
1178                         case 'h':
1179                         case 'H':
1180                         case 'l':
1181                         case 'L':
1182                         {
1183                                 /* Verify legality */
1184                                 if (!inven || !equip)
1185                                 {
1186                                         bell();
1187                                         break;
1188                                 }
1189
1190                                 /* Hack -- Fix screen */
1191                                 if (command_see)
1192                                 {
1193                                         screen_load();
1194                                         screen_save();
1195                                 }
1196
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;
1201
1202                                 /* Need to redraw */
1203                                 break;
1204                         }
1205
1206                         case 'x':
1207                         case 'X':
1208                         case '\r':
1209                         case '\n':
1210                         {
1211                                 if (command_wrk == USE_FLOOR)
1212                                 {
1213                                         /* Special index */
1214                                         (*cp) = -get_item_label;
1215                                 }
1216                                 else
1217                                 {
1218                                         /* Validate the item */
1219                                         if (!get_item_okay(get_item_label))
1220                                         {
1221                                                 bell();
1222                                                 break;
1223                                         }
1224
1225                                         /* Allow player to "refuse" certain actions */
1226                                         if (!get_item_allow(get_item_label))
1227                                         {
1228                                                 done = TRUE;
1229                                                 break;
1230                                         }
1231
1232                                         /* Accept that choice */
1233                                         (*cp) = get_item_label;
1234                                 }
1235
1236                                 item = TRUE;
1237                                 done = TRUE;
1238                                 break;
1239                         }
1240                         case 'w':
1241                         {
1242                                 if (mode & USE_FORCE) {
1243                                         *cp = INVEN_FORCE;
1244                                         item = TRUE;
1245                                         done = TRUE;
1246                                         break;
1247                                 }
1248                         }
1249                         }
1250                         if (menu_line > max_line) menu_line -= max_line;
1251                 }
1252                 else
1253                 {
1254                         /* Parse it */
1255                         switch (which)
1256                         {
1257                         case ESCAPE:
1258                         {
1259                                 done = TRUE;
1260                                 break;
1261                         }
1262
1263                         case '*':
1264                         case '?':
1265                         case ' ':
1266                         {
1267                                 /* Hide the list */
1268                                 if (command_see)
1269                                 {
1270                                         /* Flip flag */
1271                                         command_see = FALSE;
1272                                         screen_load();
1273                                 }
1274
1275                                 /* Show the list */
1276                                 else
1277                                 {
1278                                         screen_save();
1279
1280                                         /* Flip flag */
1281                                         command_see = TRUE;
1282                                 }
1283                                 break;
1284                         }
1285
1286                         case '/':
1287                         {
1288                                 /* Verify legality */
1289                                 if (!inven || !equip)
1290                                 {
1291                                         bell();
1292                                         break;
1293                                 }
1294
1295                                 /* Hack -- Fix screen */
1296                                 if (command_see)
1297                                 {
1298                                         screen_load();
1299                                         screen_save();
1300                                 }
1301
1302                                 /* Switch inven/equip */
1303                                 command_wrk = !command_wrk;
1304
1305                                 /* Need to redraw */
1306                                 break;
1307                         }
1308
1309                         case '-':
1310                         {
1311                                 /* Use floor item */
1312                                 if (allow_floor)
1313                                 {
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)
1316                                         {
1317                                                 object_type *o_ptr;
1318                                                 o_ptr = &current_floor_ptr->o_list[this_o_idx];
1319                                                 next_o_idx = o_ptr->next_o_idx;
1320
1321                                                 /* Validate the item */
1322                                                 if (!item_tester_okay(o_ptr, tval) && !(mode & USE_FULL)) continue;
1323
1324                                                 /* Special index */
1325                                                 k = 0 - this_o_idx;
1326
1327                                                 /* Verify the item (if required) */
1328                                                 if (other_query_flag && !verify(_("本当に", "Try"), k)) continue;
1329
1330                                                 /* Allow player to "refuse" certain actions */
1331                                                 if (!get_item_allow(k)) continue;
1332
1333                                                 /* Accept that choice */
1334                                                 (*cp) = k;
1335                                                 item = TRUE;
1336                                                 done = TRUE;
1337                                                 break;
1338                                         }
1339
1340                                         /* Outer break */
1341                                         if (done) break;
1342                                 }
1343
1344                                 bell();
1345                                 break;
1346                         }
1347
1348                         case '0':
1349                         case '1': case '2': case '3':
1350                         case '4': case '5': case '6':
1351                         case '7': case '8': case '9':
1352                         {
1353                                 /* Look up the tag */
1354                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN, tval))
1355                                 {
1356                                         bell();
1357                                         break;
1358                                 }
1359
1360                                 /* Hack -- Validate the item */
1361                                 if ((k < INVEN_RARM) ? !inven : !equip)
1362                                 {
1363                                         bell();
1364                                         break;
1365                                 }
1366
1367                                 /* Validate the item */
1368                                 if (!get_item_okay(k))
1369                                 {
1370                                         bell();
1371                                         break;
1372                                 }
1373
1374                                 /* Allow player to "refuse" certain actions */
1375                                 if (!get_item_allow(k))
1376                                 {
1377                                         done = TRUE;
1378                                         break;
1379                                 }
1380
1381                                 /* Accept that choice */
1382                                 (*cp) = k;
1383                                 item = TRUE;
1384                                 done = TRUE;
1385                                 cur_tag = which;
1386                                 break;
1387                         }
1388
1389 #if 0
1390                         case '\n':
1391                         case '\r':
1392                         {
1393                                 /* Choose "default" p_ptr->inventory_list item */
1394                                 if (!command_wrk)
1395                                 {
1396                                         k = ((i1 == i2) ? i1 : -1);
1397                                 }
1398
1399                                 /* Choose "default" equipment item */
1400                                 else
1401                                 {
1402                                         k = ((e1 == e2) ? e1 : -1);
1403                                 }
1404
1405                                 /* Validate the item */
1406                                 if (!get_item_okay(k))
1407                                 {
1408                                         bell();
1409                                         break;
1410                                 }
1411
1412                                 /* Allow player to "refuse" certain actions */
1413                                 if (!get_item_allow(k))
1414                                 {
1415                                         done = TRUE;
1416                                         break;
1417                                 }
1418
1419                                 /* Accept that choice */
1420                                 (*cp) = k;
1421                                 item = TRUE;
1422                                 done = TRUE;
1423                                 break;
1424                         }
1425 #endif
1426
1427                         case 'w':
1428                         {
1429                                 if (mode & USE_FORCE) {
1430                                         *cp = INVEN_FORCE;
1431                                         item = TRUE;
1432                                         done = TRUE;
1433                                         break;
1434                                 }
1435
1436                                 /* Fall through */
1437                         }
1438
1439                         default:
1440                         {
1441                                 int ver;
1442                                 bool not_found = FALSE;
1443
1444                                 /* Look up the alphabetical tag */
1445                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN, tval))
1446                                 {
1447                                         not_found = TRUE;
1448                                 }
1449
1450                                 /* Hack -- Validate the item */
1451                                 else if ((k < INVEN_RARM) ? !inven : !equip)
1452                                 {
1453                                         not_found = TRUE;
1454                                 }
1455
1456                                 /* Validate the item */
1457                                 else if (!get_item_okay(k))
1458                                 {
1459                                         not_found = TRUE;
1460                                 }
1461
1462                                 if (!not_found)
1463                                 {
1464                                         /* Accept that choice */
1465                                         (*cp) = k;
1466                                         item = TRUE;
1467                                         done = TRUE;
1468                                         cur_tag = which;
1469                                         break;
1470                                 }
1471
1472                                 /* Extract "query" setting */
1473                                 ver = isupper(which);
1474                                 which = (char)tolower(which);
1475
1476                                 /* Convert letter to p_ptr->inventory_list index */
1477                                 if (!command_wrk)
1478                                 {
1479                                         if (which == '(') k = i1;
1480                                         else if (which == ')') k = i2;
1481                                         else k = label_to_inven(which);
1482                                 }
1483
1484                                 /* Convert letter to equipment index */
1485                                 else
1486                                 {
1487                                         if (which == '(') k = e1;
1488                                         else if (which == ')') k = e2;
1489                                         else k = label_to_equip(which);
1490                                 }
1491
1492                                 /* Validate the item */
1493                                 if (!get_item_okay(k))
1494                                 {
1495                                         bell();
1496                                         break;
1497                                 }
1498
1499                                 /* Verify the item */
1500                                 if (ver && !verify(_("本当に", "Try"), k))
1501                                 {
1502                                         done = TRUE;
1503                                         break;
1504                                 }
1505
1506                                 /* Allow player to "refuse" certain actions */
1507                                 if (!get_item_allow(k))
1508                                 {
1509                                         done = TRUE;
1510                                         break;
1511                                 }
1512
1513                                 /* Accept that choice */
1514                                 (*cp) = k;
1515                                 item = TRUE;
1516                                 done = TRUE;
1517                                 break;
1518                         }
1519                         }
1520                 }
1521         }
1522
1523
1524         /* Fix the screen if necessary */
1525         if (command_see)
1526         {
1527                 screen_load();
1528
1529                 /* Hack -- Cancel "display" */
1530                 command_see = FALSE;
1531         }
1532
1533
1534         /* Forget the tval restriction */
1535         tval = 0;
1536
1537         /* Forget the item_tester_hook restriction */
1538         item_tester_hook = NULL;
1539
1540
1541         /* Clean up  'show choices' */
1542         /* Toggle again if needed */
1543         if (toggle) toggle_inven_equip();
1544
1545         p_ptr->window |= (PW_INVEN | PW_EQUIP);
1546         handle_stuff();
1547
1548         /* Clear the prompt line */
1549         prt("", 0, 0);
1550
1551         /* Warning if needed */
1552         if (oops && str) msg_print(str);
1553
1554         if (item)
1555         {
1556                 repeat_push(*cp);
1557                 if (command_cmd) prev_tag = cur_tag;
1558                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1559         }
1560         return (item);
1561 }
1562
1563 /*
1564  * Choose an item and get auto-picker entry from it.
1565  */
1566 object_type *choose_object(OBJECT_IDX *idx, concptr q, concptr s, BIT_FLAGS option)
1567 {
1568         OBJECT_IDX item;
1569         if (!get_item(&item, q, s, option, item_tester_tval)) return NULL;
1570         if (idx) *idx = item;
1571
1572         if (item == INVEN_FORCE) return NULL;
1573
1574         /* Get the item (in the pack) */
1575         else if (item >= 0) return &p_ptr->inventory_list[item];
1576
1577         /* Get the item (on the floor) */
1578         else return &current_floor_ptr->o_list[0 - item];
1579 }
1580
1581
1582 /*!
1583  * @brief 床下に落ちているオブジェクトの数を返す / scan_floor
1584  * @param items オブジェクトのIDリストを返すための配列参照ポインタ
1585  * @param y 走査するフロアのY座標
1586  * @param x 走査するフロアのX座標
1587  * @param mode オプションフラグ
1588  * @return 対象のマスに落ちているアイテム数
1589  * @details
1590  * Return a list of o_list[] indexes of items at the given current_floor_ptr->grid_array
1591  * location. Valid flags are:
1592  *
1593  *              mode & 0x01 -- Item tester
1594  *              mode & 0x02 -- Marked items only
1595  *              mode & 0x04 -- Stop after first
1596  */
1597 ITEM_NUMBER scan_floor(OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode)
1598 {
1599         OBJECT_IDX this_o_idx, next_o_idx;
1600
1601         ITEM_NUMBER num = 0;
1602
1603         /* Sanity */
1604         if (!in_bounds(y, x)) return 0;
1605
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)
1608         {
1609                 object_type *o_ptr;
1610                 o_ptr = &current_floor_ptr->o_list[this_o_idx];
1611                 next_o_idx = o_ptr->next_o_idx;
1612
1613                 /* Item tester */
1614                 if ((mode & 0x01) && !item_tester_okay(o_ptr, item_tester_tval)) continue;
1615
1616                 /* Marked */
1617                 if ((mode & 0x02) && !(o_ptr->marked & OM_FOUND)) continue;
1618
1619                 /* Accept this item */
1620                 /* XXX Hack -- Enforce limit */
1621                 if (num < 23)
1622                         items[num] = this_o_idx;
1623
1624                 num++;
1625
1626                 /* Only one */
1627                 if (mode & 0x04) break;
1628         }
1629         return num;
1630 }
1631
1632
1633 /*!
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 選択したアイテムの添え字
1640  * @details
1641  */
1642 COMMAND_CODE show_floor(int target_item, POSITION y, POSITION x, TERM_LEN *min_width)
1643 {
1644         COMMAND_CODE i, m;
1645         int j, k, l;
1646         int col, len;
1647
1648         object_type *o_ptr;
1649
1650         GAME_TEXT o_name[MAX_NLEN];
1651         char tmp_val[80];
1652
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;
1657
1658         OBJECT_IDX floor_list[23];
1659         ITEM_NUMBER floor_num;
1660         TERM_LEN wid, hgt;
1661         char floor_label[52 + 1];
1662
1663         bool dont_need_to_show_weights = TRUE;
1664
1665         Term_get_size(&wid, &hgt);
1666
1667         /* Default length */
1668         len = MAX((*min_width), 20);
1669
1670         /* Scan for objects in the grid, using item_tester_okay() */
1671         floor_num = scan_floor(floor_list, y, x, 0x03);
1672
1673         /* Display the floor objects */
1674         for (k = 0, i = 0; i < floor_num && i < 23; i++)
1675         {
1676                 o_ptr = &current_floor_ptr->o_list[floor_list[i]];
1677
1678                 object_desc(o_name, o_ptr, 0);
1679
1680                 /* Save the index */
1681                 out_index[k] = i;
1682
1683                 /* Acquire p_ptr->inventory_list color */
1684                 out_color[k] = tval_to_attr[o_ptr->tval & 0x7F];
1685
1686                 /* Save the object description */
1687                 strcpy(out_desc[k], o_name);
1688
1689                 /* Find the predicted "line length" */
1690                 l = strlen(out_desc[k]) + 5;
1691
1692                 /* Be sure to account for the weight */
1693                 if (show_weights) l += 9;
1694
1695                 if (o_ptr->tval != TV_GOLD) dont_need_to_show_weights = FALSE;
1696
1697                 /* Maintain the maximum length */
1698                 if (l > len) len = l;
1699
1700                 /* Advance to next "line" */
1701                 k++;
1702         }
1703
1704         if (show_weights && dont_need_to_show_weights) len -= 9;
1705
1706         /* Save width */
1707         *min_width = len;
1708
1709         /* Find the column to start in */
1710         col = (len > wid - 4) ? 0 : (wid - len - 1);
1711
1712         prepare_label_string_floor(floor_label, floor_list, floor_num);
1713
1714         /* Output each entry */
1715         for (j = 0; j < k; j++)
1716         {
1717                 m = floor_list[out_index[j]];
1718                 o_ptr = &current_floor_ptr->o_list[m];
1719
1720                 /* Clear the line */
1721                 prt("", j + 1, col ? col - 2 : col);
1722
1723                 if (use_menu && target_item)
1724                 {
1725                         if (j == (target_item - 1))
1726                         {
1727                                 strcpy(tmp_val, _("》", "> "));
1728                                 target_item_label = m;
1729                         }
1730                         else strcpy(tmp_val, "   ");
1731                 }
1732                 else
1733                 {
1734                         /* Prepare an index --(-- */
1735                         sprintf(tmp_val, "%c)", floor_label[j]);
1736                 }
1737
1738                 /* Clear the line with the (possibly indented) index */
1739                 put_str(tmp_val, j + 1, col);
1740
1741                 /* Display the entry itself */
1742                 c_put_str(out_color[j], out_desc[j], j + 1, col + 3);
1743
1744                 /* Display the weight if needed */
1745                 if (show_weights && (o_ptr->tval != TV_GOLD))
1746                 {
1747                         int wgt = o_ptr->weight * o_ptr->number;
1748 #ifdef JP
1749                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
1750 #else
1751                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1752 #endif
1753
1754                         prt(tmp_val, j + 1, wid - 9);
1755                 }
1756         }
1757
1758         /* Make a "shadow" below the list (only if needed) */
1759         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
1760
1761         return target_item_label;
1762 }
1763
1764 /*!
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を返す。/
1772  */
1773 bool get_item_floor(COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
1774 {
1775         char n1 = ' ', n2 = ' ', which = ' ';
1776
1777         int j;
1778         COMMAND_CODE i1, i2;
1779         COMMAND_CODE e1, e2;
1780         COMMAND_CODE k;
1781
1782         bool done, item;
1783
1784         bool oops = FALSE;
1785
1786         /* Extract args */
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;
1791
1792         bool allow_equip = FALSE;
1793         bool allow_inven = FALSE;
1794         bool allow_floor = FALSE;
1795
1796         bool toggle = FALSE;
1797
1798         char tmp_val[160];
1799         char out_val[160];
1800
1801         ITEM_NUMBER floor_num;
1802         OBJECT_IDX floor_list[23];
1803         int floor_top = 0;
1804         TERM_LEN min_width = 0;
1805
1806         int menu_line = (use_menu ? 1 : 0);
1807         int max_inven = 0;
1808         int max_equip = 0;
1809
1810         static char prev_tag = '\0';
1811         char cur_tag = '\0';
1812
1813         /* Get the item index */
1814         if (repeat_pull(cp))
1815         {
1816                 /* the_force */
1817                 if (force && (*cp == INVEN_FORCE))
1818                 {
1819                         tval = 0;
1820                         item_tester_hook = NULL;
1821                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1822                         return (TRUE);
1823                 }
1824
1825                 /* Floor item? */
1826                 else if (floor && (*cp < 0))
1827                 {
1828                         if (prev_tag && command_cmd)
1829                         {
1830                                 /* Scan all objects in the grid */
1831                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
1832
1833                                 /* Look up the tag */
1834                                 if (get_tag_floor(&k, prev_tag, floor_list, floor_num))
1835                                 {
1836                                         /* Accept that choice */
1837                                         (*cp) = 0 - floor_list[k];
1838
1839                                         /* Forget restrictions */
1840                                         tval = 0;
1841                                         item_tester_hook = NULL;
1842                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1843
1844                                         /* Success */
1845                                         return TRUE;
1846                                 }
1847
1848                                 prev_tag = '\0'; /* prev_tag is no longer effective */
1849                         }
1850
1851                         /* Validate the item */
1852                         else if (item_tester_okay(&current_floor_ptr->o_list[0 - (*cp)], tval) || (mode & USE_FULL))
1853                         {
1854                                 /* Forget restrictions */
1855                                 tval = 0;
1856                                 item_tester_hook = NULL;
1857                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1858
1859                                 /* Success */
1860                                 return TRUE;
1861                         }
1862                 }
1863
1864                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
1865                         (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
1866                 {
1867                         if (prev_tag && command_cmd)
1868                         {
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 */;
1873                                 else
1874                                 {
1875                                         /* Accept that choice */
1876                                         (*cp) = k;
1877
1878                                         /* Forget restrictions */
1879                                         tval = 0;
1880                                         item_tester_hook = NULL;
1881                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1882
1883                                         /* Success */
1884                                         return TRUE;
1885                                 }
1886
1887                                 prev_tag = '\0'; /* prev_tag is no longer effective */
1888                         }
1889
1890                         /* Verify the item */
1891                         else if (get_item_okay(*cp))
1892                         {
1893                                 /* Forget restrictions */
1894                                 tval = 0;
1895                                 item_tester_hook = NULL;
1896                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
1897
1898                                 /* Success */
1899                                 return TRUE;
1900                         }
1901                 }
1902         }
1903
1904         msg_print(NULL);
1905
1906
1907         /* Not done */
1908         done = FALSE;
1909
1910         /* No item selected */
1911         item = FALSE;
1912
1913
1914         /* Full p_ptr->inventory_list */
1915         i1 = 0;
1916         i2 = INVEN_PACK - 1;
1917
1918         /* Forbid p_ptr->inventory_list */
1919         if (!inven) i2 = -1;
1920         else if (use_menu)
1921         {
1922                 for (j = 0; j < INVEN_PACK; j++)
1923                         if (item_tester_okay(&p_ptr->inventory_list[j], tval) || (mode & USE_FULL)) max_inven++;
1924         }
1925
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--;
1929
1930
1931         /* Full equipment */
1932         e1 = INVEN_RARM;
1933         e2 = INVEN_TOTAL - 1;
1934
1935         /* Forbid equipment */
1936         if (!equip) e2 = -1;
1937         else if (use_menu)
1938         {
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++;
1942         }
1943
1944         /* Restrict equipment indexes */
1945         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
1946         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
1947
1948         if (equip && p_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
1949         {
1950                 if (p_ptr->migite)
1951                 {
1952                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
1953                 }
1954                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
1955         }
1956
1957
1958         /* Count "okay" floor items */
1959         floor_num = 0;
1960
1961         /* Restrict floor usage */
1962         if (floor)
1963         {
1964                 /* Scan all objects in the grid */
1965                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
1966         }
1967
1968         /* Accept p_ptr->inventory_list */
1969         if (i1 <= i2) allow_inven = TRUE;
1970
1971         /* Accept equipment */
1972         if (e1 <= e2) allow_equip = TRUE;
1973
1974         /* Accept floor */
1975         if (floor_num) allow_floor = TRUE;
1976
1977         /* Require at least one legal choice */
1978         if (!allow_inven && !allow_equip && !allow_floor)
1979         {
1980                 /* Cancel p_ptr->command_see */
1981                 command_see = FALSE;
1982                 oops = TRUE;
1983                 done = TRUE;
1984
1985                 if (force) {
1986                         *cp = INVEN_FORCE;
1987                         item = TRUE;
1988                 }
1989         }
1990
1991         /* Analyze choices */
1992         else
1993         {
1994                 /* Hack -- Start on equipment if requested */
1995                 if (command_see && (command_wrk == (USE_EQUIP))
1996                         && allow_equip)
1997                 {
1998                         command_wrk = (USE_EQUIP);
1999                 }
2000
2001                 /* Use p_ptr->inventory_list if allowed */
2002                 else if (allow_inven)
2003                 {
2004                         command_wrk = (USE_INVEN);
2005                 }
2006
2007                 /* Use equipment if allowed */
2008                 else if (allow_equip)
2009                 {
2010                         command_wrk = (USE_EQUIP);
2011                 }
2012
2013                 /* Use floor if allowed */
2014                 else if (allow_floor)
2015                 {
2016                         command_wrk = (USE_FLOOR);
2017                 }
2018         }
2019
2020         /*
2021          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
2022          */
2023         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
2024
2025         /* Hack -- start out in "display" mode */
2026         if (command_see)
2027         {
2028                 screen_save();
2029         }
2030
2031         /* Repeat until done */
2032         while (!done)
2033         {
2034                 COMMAND_CODE get_item_label = 0;
2035
2036                 /* Show choices */
2037                 int ni = 0;
2038                 int ne = 0;
2039
2040                 /* Scan windows */
2041                 for (j = 0; j < 8; j++)
2042                 {
2043                         /* Unused */
2044                         if (!angband_term[j]) continue;
2045
2046                         /* Count windows displaying inven */
2047                         if (window_flag[j] & (PW_INVEN)) ni++;
2048
2049                         /* Count windows displaying equip */
2050                         if (window_flag[j] & (PW_EQUIP)) ne++;
2051                 }
2052
2053                 /* Toggle if needed */
2054                 if ((command_wrk == (USE_EQUIP) && ni && !ne) ||
2055                         (command_wrk == (USE_INVEN) && !ni && ne))
2056                 {
2057                         /* Toggle */
2058                         toggle_inven_equip();
2059
2060                         /* Track toggles */
2061                         toggle = !toggle;
2062                 }
2063
2064                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
2065                 handle_stuff();
2066
2067                 /* Inventory screen */
2068                 if (command_wrk == (USE_INVEN))
2069                 {
2070                         /* Extract the legal requests */
2071                         n1 = I2A(i1);
2072                         n2 = I2A(i2);
2073
2074                         /* Redraw if needed */
2075                         if (command_see) get_item_label = show_inven(menu_line, mode, tval);
2076                 }
2077
2078                 /* Equipment screen */
2079                 else if (command_wrk == (USE_EQUIP))
2080                 {
2081                         /* Extract the legal requests */
2082                         n1 = I2A(e1 - INVEN_RARM);
2083                         n2 = I2A(e2 - INVEN_RARM);
2084
2085                         /* Redraw if needed */
2086                         if (command_see) get_item_label = show_equip(menu_line, mode, tval);
2087                 }
2088
2089                 /* Floor screen */
2090                 else if (command_wrk == (USE_FLOOR))
2091                 {
2092                         j = floor_top;
2093                         k = MIN(floor_top + 23, floor_num) - 1;
2094
2095                         /* Extract the legal requests */
2096                         n1 = I2A(j - floor_top);
2097                         n2 = I2A(k - floor_top);
2098
2099                         /* Redraw if needed */
2100                         if (command_see) get_item_label = show_floor(menu_line, p_ptr->y, p_ptr->x, &min_width);
2101                 }
2102
2103                 /* Viewing p_ptr->inventory_list */
2104                 if (command_wrk == (USE_INVEN))
2105                 {
2106                         /* Begin the prompt */
2107                         sprintf(out_val, _("持ち物:", "Inven:"));
2108
2109                         if (!use_menu)
2110                         {
2111                                 /* Build the prompt */
2112                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2113                                         index_to_label(i1), index_to_label(i2));
2114
2115                                 /* Append */
2116                                 strcat(out_val, tmp_val);
2117                         }
2118
2119                         /* Indicate ability to "view" */
2120                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2121
2122                         /* Append */
2123                         if (allow_equip)
2124                         {
2125                                 if (!use_menu)
2126                                         strcat(out_val, _(" '/' 装備品,", " / for Equip,"));
2127                                 else if (allow_floor)
2128                                         strcat(out_val, _(" '6' 装備品,", " 6 for Equip,"));
2129                                 else
2130                                         strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
2131                         }
2132
2133                         /* Append */
2134                         if (allow_floor)
2135                         {
2136                                 if (!use_menu)
2137                                         strcat(out_val, _(" '-'床上,", " - for floor,"));
2138                                 else if (allow_equip)
2139                                         strcat(out_val, _(" '4' 床上,", " 4 for floor,"));
2140                                 else
2141                                         strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
2142                         }
2143                 }
2144
2145                 /* Viewing equipment */
2146                 else if (command_wrk == (USE_EQUIP))
2147                 {
2148                         /* Begin the prompt */
2149                         sprintf(out_val, _("装備品:", "Equip:"));
2150
2151                         if (!use_menu)
2152                         {
2153                                 /* Build the prompt */
2154                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
2155                                         index_to_label(e1), index_to_label(e2));
2156
2157                                 /* Append */
2158                                 strcat(out_val, tmp_val);
2159                         }
2160
2161                         /* Indicate ability to "view" */
2162                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2163
2164                         /* Append */
2165                         if (allow_inven)
2166                         {
2167                                 if (!use_menu)
2168                                         strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
2169                                 else if (allow_floor)
2170                                         strcat(out_val, _(" '4' 持ち物,", " 4 for Inven,"));
2171                                 else
2172                                         strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
2173                         }
2174
2175                         /* Append */
2176                         if (allow_floor)
2177                         {
2178                                 if (!use_menu)
2179                                         strcat(out_val, _(" '-'床上,", " - for floor,"));
2180                                 else if (allow_inven)
2181                                         strcat(out_val, _(" '6' 床上,", " 6 for floor,"));
2182                                 else
2183                                         strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
2184                         }
2185                 }
2186
2187                 /* Viewing floor */
2188                 else if (command_wrk == (USE_FLOOR))
2189                 {
2190                         /* Begin the prompt */
2191                         sprintf(out_val, _("床上:", "Floor:"));
2192
2193                         if (!use_menu)
2194                         {
2195                                 /* Build the prompt */
2196                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
2197
2198                                 /* Append */
2199                                 strcat(out_val, tmp_val);
2200                         }
2201
2202                         /* Indicate ability to "view" */
2203                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
2204
2205                         if (use_menu)
2206                         {
2207                                 if (allow_inven && allow_equip)
2208                                 {
2209                                         strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
2210                                 }
2211                                 else if (allow_inven)
2212                                 {
2213                                         strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
2214                                 }
2215                                 else if (allow_equip)
2216                                 {
2217                                         strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
2218                                 }
2219                         }
2220                         /* Append */
2221                         else if (allow_inven)
2222                         {
2223                                 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
2224                         }
2225                         else if (allow_equip)
2226                         {
2227                                 strcat(out_val, _(" '/'装備品,", " / for Equip,"));
2228                         }
2229
2230                         /* Append */
2231                         if (command_see && !use_menu)
2232                         {
2233                                 strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
2234                         }
2235                 }
2236
2237                 /* Append */
2238                 if (force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
2239
2240                 /* Finish the prompt */
2241                 strcat(out_val, " ESC");
2242
2243                 /* Build the prompt */
2244                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
2245
2246                 /* Show the prompt */
2247                 prt(tmp_val, 0, 0);
2248
2249                 /* Get a key */
2250                 which = inkey();
2251
2252                 if (use_menu)
2253                 {
2254                         int max_line = 1;
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);
2258                         switch (which)
2259                         {
2260                         case ESCAPE:
2261                         case 'z':
2262                         case 'Z':
2263                         case '0':
2264                         {
2265                                 done = TRUE;
2266                                 break;
2267                         }
2268
2269                         case '8':
2270                         case 'k':
2271                         case 'K':
2272                         {
2273                                 menu_line += (max_line - 1);
2274                                 break;
2275                         }
2276
2277                         case '2':
2278                         case 'j':
2279                         case 'J':
2280                         {
2281                                 menu_line++;
2282                                 break;
2283                         }
2284
2285                         case '4':
2286                         case 'h':
2287                         case 'H':
2288                         {
2289                                 /* Verify legality */
2290                                 if (command_wrk == (USE_INVEN))
2291                                 {
2292                                         if (allow_floor) command_wrk = USE_FLOOR;
2293                                         else if (allow_equip) command_wrk = USE_EQUIP;
2294                                         else
2295                                         {
2296                                                 bell();
2297                                                 break;
2298                                         }
2299                                 }
2300                                 else if (command_wrk == (USE_EQUIP))
2301                                 {
2302                                         if (allow_inven) command_wrk = USE_INVEN;
2303                                         else if (allow_floor) command_wrk = USE_FLOOR;
2304                                         else
2305                                         {
2306                                                 bell();
2307                                                 break;
2308                                         }
2309                                 }
2310                                 else if (command_wrk == (USE_FLOOR))
2311                                 {
2312                                         if (allow_equip) command_wrk = USE_EQUIP;
2313                                         else if (allow_inven) command_wrk = USE_INVEN;
2314                                         else
2315                                         {
2316                                                 bell();
2317                                                 break;
2318                                         }
2319                                 }
2320                                 else
2321                                 {
2322                                         bell();
2323                                         break;
2324                                 }
2325
2326                                 /* Hack -- Fix screen */
2327                                 if (command_see)
2328                                 {
2329                                         screen_load();
2330                                         screen_save();
2331                                 }
2332
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;
2338
2339                                 /* Need to redraw */
2340                                 break;
2341                         }
2342
2343                         case '6':
2344                         case 'l':
2345                         case 'L':
2346                         {
2347                                 /* Verify legality */
2348                                 if (command_wrk == (USE_INVEN))
2349                                 {
2350                                         if (allow_equip) command_wrk = USE_EQUIP;
2351                                         else if (allow_floor) command_wrk = USE_FLOOR;
2352                                         else
2353                                         {
2354                                                 bell();
2355                                                 break;
2356                                         }
2357                                 }
2358                                 else if (command_wrk == (USE_EQUIP))
2359                                 {
2360                                         if (allow_floor) command_wrk = USE_FLOOR;
2361                                         else if (allow_inven) command_wrk = USE_INVEN;
2362                                         else
2363                                         {
2364                                                 bell();
2365                                                 break;
2366                                         }
2367                                 }
2368                                 else if (command_wrk == (USE_FLOOR))
2369                                 {
2370                                         if (allow_inven) command_wrk = USE_INVEN;
2371                                         else if (allow_equip) command_wrk = USE_EQUIP;
2372                                         else
2373                                         {
2374                                                 bell();
2375                                                 break;
2376                                         }
2377                                 }
2378                                 else
2379                                 {
2380                                         bell();
2381                                         break;
2382                                 }
2383
2384                                 /* Hack -- Fix screen */
2385                                 if (command_see)
2386                                 {
2387                                         screen_load();
2388                                         screen_save();
2389                                 }
2390
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;
2396
2397                                 /* Need to redraw */
2398                                 break;
2399                         }
2400
2401                         case 'x':
2402                         case 'X':
2403                         case '\r':
2404                         case '\n':
2405                         {
2406                                 if (command_wrk == USE_FLOOR)
2407                                 {
2408                                         /* Special index */
2409                                         (*cp) = -get_item_label;
2410                                 }
2411                                 else
2412                                 {
2413                                         /* Validate the item */
2414                                         if (!get_item_okay(get_item_label))
2415                                         {
2416                                                 bell();
2417                                                 break;
2418                                         }
2419
2420                                         /* Allow player to "refuse" certain actions */
2421                                         if (!get_item_allow(get_item_label))
2422                                         {
2423                                                 done = TRUE;
2424                                                 break;
2425                                         }
2426
2427                                         /* Accept that choice */
2428                                         (*cp) = get_item_label;
2429                                 }
2430
2431                                 item = TRUE;
2432                                 done = TRUE;
2433                                 break;
2434                         }
2435                         case 'w':
2436                         {
2437                                 if (force) {
2438                                         *cp = INVEN_FORCE;
2439                                         item = TRUE;
2440                                         done = TRUE;
2441                                         break;
2442                                 }
2443                         }
2444                         }
2445                         if (menu_line > max_line) menu_line -= max_line;
2446                 }
2447                 else
2448                 {
2449                         /* Parse it */
2450                         switch (which)
2451                         {
2452                         case ESCAPE:
2453                         {
2454                                 done = TRUE;
2455                                 break;
2456                         }
2457
2458                         case '*':
2459                         case '?':
2460                         case ' ':
2461                         {
2462                                 /* Hide the list */
2463                                 if (command_see)
2464                                 {
2465                                         /* Flip flag */
2466                                         command_see = FALSE;
2467                                         screen_load();
2468                                 }
2469
2470                                 /* Show the list */
2471                                 else
2472                                 {
2473                                         screen_save();
2474
2475                                         /* Flip flag */
2476                                         command_see = TRUE;
2477                                 }
2478                                 break;
2479                         }
2480
2481                         case '\n':
2482                         case '\r':
2483                         case '+':
2484                         {
2485                                 int i;
2486                                 OBJECT_IDX o_idx;
2487                                 grid_type *g_ptr = &current_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
2488
2489                                 if (command_wrk != (USE_FLOOR)) break;
2490
2491                                 /* Get the object being moved. */
2492                                 o_idx = g_ptr->o_idx;
2493
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;
2496
2497                                 /* Remove the first object from the list. */
2498                                 excise_object_idx(o_idx);
2499
2500                                 /* Find end of the list. */
2501                                 i = g_ptr->o_idx;
2502                                 while (current_floor_ptr->o_list[i].next_o_idx)
2503                                         i = current_floor_ptr->o_list[i].next_o_idx;
2504
2505                                 /* Add after the last object. */
2506                                 current_floor_ptr->o_list[i].next_o_idx = o_idx;
2507
2508                                 /* Re-scan floor list */
2509                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2510
2511                                 /* Hack -- Fix screen */
2512                                 if (command_see)
2513                                 {
2514                                         screen_load();
2515                                         screen_save();
2516                                 }
2517
2518                                 break;
2519                         }
2520
2521                         case '/':
2522                         {
2523                                 if (command_wrk == (USE_INVEN))
2524                                 {
2525                                         if (!allow_equip)
2526                                         {
2527                                                 bell();
2528                                                 break;
2529                                         }
2530                                         command_wrk = (USE_EQUIP);
2531                                 }
2532                                 else if (command_wrk == (USE_EQUIP))
2533                                 {
2534                                         if (!allow_inven)
2535                                         {
2536                                                 bell();
2537                                                 break;
2538                                         }
2539                                         command_wrk = (USE_INVEN);
2540                                 }
2541                                 else if (command_wrk == (USE_FLOOR))
2542                                 {
2543                                         if (allow_inven)
2544                                         {
2545                                                 command_wrk = (USE_INVEN);
2546                                         }
2547                                         else if (allow_equip)
2548                                         {
2549                                                 command_wrk = (USE_EQUIP);
2550                                         }
2551                                         else
2552                                         {
2553                                                 bell();
2554                                                 break;
2555                                         }
2556                                 }
2557
2558                                 /* Hack -- Fix screen */
2559                                 if (command_see)
2560                                 {
2561                                         screen_load();
2562                                         screen_save();
2563                                 }
2564
2565                                 /* Need to redraw */
2566                                 break;
2567                         }
2568
2569                         case '-':
2570                         {
2571                                 if (!allow_floor)
2572                                 {
2573                                         bell();
2574                                         break;
2575                                 }
2576
2577                                 /*
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
2582                                  * is FALSE.
2583                                  */
2584                                 if (floor_num == 1)
2585                                 {
2586                                         if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag))
2587                                         {
2588                                                 /* Special index */
2589                                                 k = 0 - floor_list[0];
2590
2591                                                 /* Allow player to "refuse" certain actions */
2592                                                 if (!get_item_allow(k))
2593                                                 {
2594                                                         done = TRUE;
2595                                                         break;
2596                                                 }
2597
2598                                                 /* Accept that choice */
2599                                                 (*cp) = k;
2600                                                 item = TRUE;
2601                                                 done = TRUE;
2602
2603                                                 break;
2604                                         }
2605                                 }
2606
2607                                 /* Hack -- Fix screen */
2608                                 if (command_see)
2609                                 {
2610                                         screen_load();
2611                                         screen_save();
2612                                 }
2613
2614                                 command_wrk = (USE_FLOOR);
2615
2616                                 break;
2617                         }
2618
2619                         case '0':
2620                         case '1': case '2': case '3':
2621                         case '4': case '5': case '6':
2622                         case '7': case '8': case '9':
2623                         {
2624                                 if (command_wrk != USE_FLOOR)
2625                                 {
2626                                         /* Look up the tag */
2627                                         if (!get_tag(&k, which, command_wrk, tval))
2628                                         {
2629                                                 bell();
2630                                                 break;
2631                                         }
2632
2633                                         /* Hack -- Validate the item */
2634                                         if ((k < INVEN_RARM) ? !inven : !equip)
2635                                         {
2636                                                 bell();
2637                                                 break;
2638                                         }
2639
2640                                         /* Validate the item */
2641                                         if (!get_item_okay(k))
2642                                         {
2643                                                 bell();
2644                                                 break;
2645                                         }
2646                                 }
2647                                 else
2648                                 {
2649                                         /* Look up the alphabetical tag */
2650                                         if (get_tag_floor(&k, which, floor_list, floor_num))
2651                                         {
2652                                                 /* Special index */
2653                                                 k = 0 - floor_list[k];
2654                                         }
2655                                         else
2656                                         {
2657                                                 bell();
2658                                                 break;
2659                                         }
2660                                 }
2661
2662                                 /* Allow player to "refuse" certain actions */
2663                                 if (!get_item_allow(k))
2664                                 {
2665                                         done = TRUE;
2666                                         break;
2667                                 }
2668
2669                                 /* Accept that choice */
2670                                 (*cp) = k;
2671                                 item = TRUE;
2672                                 done = TRUE;
2673                                 cur_tag = which;
2674                                 break;
2675                         }
2676
2677 #if 0
2678                         case '\n':
2679                         case '\r':
2680                         {
2681                                 /* Choose "default" p_ptr->inventory_list item */
2682                                 if (command_wrk == (USE_INVEN))
2683                                 {
2684                                         k = ((i1 == i2) ? i1 : -1);
2685                                 }
2686
2687                                 /* Choose "default" equipment item */
2688                                 else if (command_wrk == (USE_EQUIP))
2689                                 {
2690                                         k = ((e1 == e2) ? e1 : -1);
2691                                 }
2692
2693                                 /* Choose "default" floor item */
2694                                 else if (command_wrk == (USE_FLOOR))
2695                                 {
2696                                         if (floor_num == 1)
2697                                         {
2698                                                 /* Special index */
2699                                                 k = 0 - floor_list[0];
2700
2701                                                 /* Allow player to "refuse" certain actions */
2702                                                 if (!get_item_allow(k))
2703                                                 {
2704                                                         done = TRUE;
2705                                                         break;
2706                                                 }
2707
2708                                                 /* Accept that choice */
2709                                                 (*cp) = k;
2710                                                 item = TRUE;
2711                                                 done = TRUE;
2712                                         }
2713                                         break;
2714                                 }
2715
2716                                 /* Validate the item */
2717                                 if (!get_item_okay(k))
2718                                 {
2719                                         bell();
2720                                         break;
2721                                 }
2722
2723                                 /* Allow player to "refuse" certain actions */
2724                                 if (!get_item_allow(k))
2725                                 {
2726                                         done = TRUE;
2727                                         break;
2728                                 }
2729
2730                                 /* Accept that choice */
2731                                 (*cp) = k;
2732                                 item = TRUE;
2733                                 done = TRUE;
2734                                 break;
2735                         }
2736 #endif
2737
2738                         case 'w':
2739                         {
2740                                 if (force) {
2741                                         *cp = INVEN_FORCE;
2742                                         item = TRUE;
2743                                         done = TRUE;
2744                                         break;
2745                                 }
2746
2747                                 /* Fall through */
2748                         }
2749
2750                         default:
2751                         {
2752                                 int ver;
2753
2754                                 if (command_wrk != USE_FLOOR)
2755                                 {
2756                                         bool not_found = FALSE;
2757
2758                                         /* Look up the alphabetical tag */
2759                                         if (!get_tag(&k, which, command_wrk, tval))
2760                                         {
2761                                                 not_found = TRUE;
2762                                         }
2763
2764                                         /* Hack -- Validate the item */
2765                                         else if ((k < INVEN_RARM) ? !inven : !equip)
2766                                         {
2767                                                 not_found = TRUE;
2768                                         }
2769
2770                                         /* Validate the item */
2771                                         else if (!get_item_okay(k))
2772                                         {
2773                                                 not_found = TRUE;
2774                                         }
2775
2776                                         if (!not_found)
2777                                         {
2778                                                 /* Accept that choice */
2779                                                 (*cp) = k;
2780                                                 item = TRUE;
2781                                                 done = TRUE;
2782                                                 cur_tag = which;
2783                                                 break;
2784                                         }
2785                                 }
2786                                 else
2787                                 {
2788                                         /* Look up the alphabetical tag */
2789                                         if (get_tag_floor(&k, which, floor_list, floor_num))
2790                                         {
2791                                                 /* Special index */
2792                                                 k = 0 - floor_list[k];
2793
2794                                                 /* Accept that choice */
2795                                                 (*cp) = k;
2796                                                 item = TRUE;
2797                                                 done = TRUE;
2798                                                 cur_tag = which;
2799                                                 break;
2800                                         }
2801                                 }
2802
2803                                 /* Extract "query" setting */
2804                                 ver = isupper(which);
2805                                 which = (char)tolower(which);
2806
2807                                 /* Convert letter to p_ptr->inventory_list index */
2808                                 if (command_wrk == (USE_INVEN))
2809                                 {
2810                                         if (which == '(') k = i1;
2811                                         else if (which == ')') k = i2;
2812                                         else k = label_to_inven(which);
2813                                 }
2814
2815                                 /* Convert letter to equipment index */
2816                                 else if (command_wrk == (USE_EQUIP))
2817                                 {
2818                                         if (which == '(') k = e1;
2819                                         else if (which == ')') k = e2;
2820                                         else k = label_to_equip(which);
2821                                 }
2822
2823                                 /* Convert letter to floor index */
2824                                 else if (command_wrk == USE_FLOOR)
2825                                 {
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)
2830                                         {
2831                                                 bell();
2832                                                 break;
2833                                         }
2834
2835                                         /* Special index */
2836                                         k = 0 - floor_list[k];
2837                                 }
2838
2839                                 /* Validate the item */
2840                                 if ((command_wrk != USE_FLOOR) && !get_item_okay(k))
2841                                 {
2842                                         bell();
2843                                         break;
2844                                 }
2845
2846                                 /* Verify the item */
2847                                 if (ver && !verify(_("本当に", "Try"), k))
2848                                 {
2849                                         done = TRUE;
2850                                         break;
2851                                 }
2852
2853                                 /* Allow player to "refuse" certain actions */
2854                                 if (!get_item_allow(k))
2855                                 {
2856                                         done = TRUE;
2857                                         break;
2858                                 }
2859
2860                                 /* Accept that choice */
2861                                 (*cp) = k;
2862                                 item = TRUE;
2863                                 done = TRUE;
2864                                 break;
2865                         }
2866                         }
2867                 }
2868         }
2869
2870         /* Fix the screen if necessary */
2871         if (command_see)
2872         {
2873                 screen_load();
2874
2875                 /* Hack -- Cancel "display" */
2876                 command_see = FALSE;
2877         }
2878
2879
2880         /* Forget the tval restriction */
2881         tval = 0;
2882
2883         /* Forget the item_tester_hook restriction */
2884         item_tester_hook = NULL;
2885
2886
2887         /* Clean up  'show choices' */
2888         /* Toggle again if needed */
2889         if (toggle) toggle_inven_equip();
2890
2891         p_ptr->window |= (PW_INVEN | PW_EQUIP);
2892         handle_stuff();
2893
2894         /* Clear the prompt line */
2895         prt("", 0, 0);
2896
2897         /* Warning if needed */
2898         if (oops && str) msg_print(str);
2899
2900         if (item)
2901         {
2902                 repeat_push(*cp);
2903                 if (command_cmd) prev_tag = cur_tag;
2904                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2905         }
2906         return (item);
2907 }
2908
2909 /*!
2910  * @brief 床上のアイテムを拾う選択用サブルーチン
2911  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。
2912  */
2913 static bool py_pickup_floor_aux(void)
2914 {
2915         OBJECT_IDX this_o_idx;
2916         concptr q, s;
2917         OBJECT_IDX item;
2918
2919         /* Restrict the choices */
2920         item_tester_hook = inven_carry_okay;
2921
2922         /* Get an object */
2923         q = _("どれを拾いますか?", "Get which item? ");
2924         s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
2925
2926         if (choose_object(&item, q, s, (USE_FLOOR)))
2927         {
2928                 this_o_idx = 0 - item;
2929         }
2930         else
2931         {
2932                 return (FALSE);
2933         }
2934
2935         /* Pick up the object */
2936         py_pickup_aux(this_o_idx);
2937
2938         return (TRUE);
2939 }
2940
2941 /*!
2942  * @brief 床上のアイテムを拾うメイン処理
2943  * @param pickup FALSEなら金銭の自動拾いのみを行う/ FALSE then only gold will be picked up
2944  * @return なし
2945  * @details
2946  * This is called by py_pickup() when easy_floor is TRUE.
2947  */
2948 void py_pickup_floor(bool pickup)
2949 {
2950         OBJECT_IDX this_o_idx, next_o_idx = 0;
2951
2952         GAME_TEXT o_name[MAX_NLEN];
2953         object_type *o_ptr;
2954
2955         int floor_num = 0;
2956         OBJECT_IDX floor_o_idx = 0;
2957
2958         int can_pickup = 0;
2959
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)
2962         {
2963                 /* Access the object */
2964                 o_ptr = &current_floor_ptr->o_list[this_o_idx];
2965
2966                 object_desc(o_name, o_ptr, 0);
2967
2968                 /* Access the next object */
2969                 next_o_idx = o_ptr->next_o_idx;
2970
2971                 disturb(FALSE, FALSE);
2972
2973                 /* Pick up gold */
2974                 if (o_ptr->tval == TV_GOLD)
2975                 {
2976 #ifdef JP
2977                         msg_format(" $%ld の価値がある%sを見つけた。",
2978                                 (long)o_ptr->pval, o_name);
2979 #else
2980                         msg_format("You have found %ld gold pieces worth of %s.",
2981                                 (long)o_ptr->pval, o_name);
2982 #endif
2983
2984                         /* Collect the gold */
2985                         p_ptr->au += o_ptr->pval;
2986
2987                         /* Redraw gold */
2988                         p_ptr->redraw |= (PR_GOLD);
2989
2990                         p_ptr->window |= (PW_PLAYER);
2991
2992                         /* Delete the gold */
2993                         delete_object_idx(this_o_idx);
2994
2995                         /* Check the next object */
2996                         continue;
2997                 }
2998                 else if (o_ptr->marked & OM_NOMSG)
2999                 {
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);
3003                         continue;
3004                 }
3005
3006                 /* Count non-gold objects that can be picked up. */
3007                 if (inven_carry_okay(o_ptr))
3008                 {
3009                         can_pickup++;
3010                 }
3011
3012                 /* Count non-gold objects */
3013                 floor_num++;
3014
3015                 /* Remember this index */
3016                 floor_o_idx = this_o_idx;
3017         }
3018
3019         /* There are no non-gold objects */
3020         if (!floor_num)
3021                 return;
3022
3023         /* Mention the number of objects */
3024         if (!pickup)
3025         {
3026                 /* One object */
3027                 if (floor_num == 1)
3028                 {
3029                         /* Access the object */
3030                         o_ptr = &current_floor_ptr->o_list[floor_o_idx];
3031
3032 #ifdef ALLOW_EASY_SENSE
3033
3034                         /* Option: Make object sensing easy */
3035                         if (easy_sense)
3036                         {
3037                                 /* Sense the object */
3038                                 (void)sense_object(o_ptr);
3039                         }
3040
3041 #endif /* ALLOW_EASY_SENSE */
3042
3043                         object_desc(o_name, o_ptr, 0);
3044
3045                         msg_format(_("%sがある。", "You see %s."), o_name);
3046                 }
3047
3048                 /* Multiple objects */
3049                 else
3050                 {
3051                         msg_format(_("%d 個のアイテムの山がある。", "You see a pile of %d items."), floor_num);
3052                 }
3053
3054                 return;
3055         }
3056
3057         /* The player has no room for anything on the floor. */
3058         if (!can_pickup)
3059         {
3060                 /* One object */
3061                 if (floor_num == 1)
3062                 {
3063                         /* Access the object */
3064                         o_ptr = &current_floor_ptr->o_list[floor_o_idx];
3065
3066 #ifdef ALLOW_EASY_SENSE
3067
3068                         /* Option: Make object sensing easy */
3069                         if (easy_sense)
3070                         {
3071                                 /* Sense the object */
3072                                 (void)sense_object(o_ptr);
3073                         }
3074
3075 #endif /* ALLOW_EASY_SENSE */
3076
3077                         object_desc(o_name, o_ptr, 0);
3078
3079                         msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
3080                 }
3081
3082                 /* Multiple objects */
3083                 else
3084                 {
3085                         msg_print(_("ザックには床にあるどのアイテムも入らない。", "You have no room for any of the objects on the floor."));
3086
3087                 }
3088
3089                 return;
3090         }
3091
3092         /* One object */
3093         if (floor_num == 1)
3094         {
3095                 /* Hack -- query every object */
3096                 if (carry_query_flag)
3097                 {
3098                         char out_val[MAX_NLEN + 20];
3099
3100                         /* Access the object */
3101                         o_ptr = &current_floor_ptr->o_list[floor_o_idx];
3102
3103 #ifdef ALLOW_EASY_SENSE
3104
3105                         /* Option: Make object sensing easy */
3106                         if (easy_sense)
3107                         {
3108                                 /* Sense the object */
3109                                 (void)sense_object(o_ptr);
3110                         }
3111
3112 #endif /* ALLOW_EASY_SENSE */
3113
3114                         object_desc(o_name, o_ptr, 0);
3115
3116                         /* Build a prompt */
3117                         (void)sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
3118
3119                         /* Ask the user to confirm */
3120                         if (!get_check(out_val))
3121                         {
3122                                 return;
3123                         }
3124                 }
3125
3126                 /* Access the object */
3127                 o_ptr = &current_floor_ptr->o_list[floor_o_idx];
3128
3129 #ifdef ALLOW_EASY_SENSE
3130
3131                 /* Option: Make object sensing easy */
3132                 if (easy_sense)
3133                 {
3134                         /* Sense the object */
3135                         (void)sense_object(o_ptr);
3136                 }
3137
3138 #endif /* ALLOW_EASY_SENSE */
3139
3140                 /* Pick up the object */
3141                 py_pickup_aux(floor_o_idx);
3142         }
3143
3144         /* Allow the user to choose an object */
3145         else
3146         {
3147                 while (can_pickup--)
3148                 {
3149                         if (!py_pickup_floor_aux()) break;
3150                 }
3151         }
3152 }
3153
3154
3155
3156 /*!
3157  * @brief 所持アイテム一覧を表示する /
3158  * Choice window "shadow" of the "show_inven()" function
3159  * @return なし
3160  */
3161 void display_inven(OBJECT_TYPE_VALUE tval)
3162 {
3163         register int i, n, z = 0;
3164         object_type *o_ptr;
3165         TERM_COLOR attr = TERM_WHITE;
3166         char tmp_val[80];
3167         GAME_TEXT o_name[MAX_NLEN];
3168         TERM_LEN wid, hgt;
3169
3170         Term_get_size(&wid, &hgt);
3171
3172         for (i = 0; i < INVEN_PACK; i++)
3173         {
3174                 o_ptr = &p_ptr->inventory_list[i];
3175                 if (!o_ptr->k_idx) continue;
3176                 z = i + 1;
3177         }
3178
3179         for (i = 0; i < z; i++)
3180         {
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))
3184                 {
3185                         tmp_val[0] = index_to_label(i);
3186                         tmp_val[1] = ')';
3187                 }
3188
3189                 Term_putstr(0, i, 3, TERM_WHITE, tmp_val);
3190                 object_desc(o_name, o_ptr, 0);
3191                 n = strlen(o_name);
3192                 attr = tval_to_attr[o_ptr->tval % 128];
3193                 if (o_ptr->timeout)
3194                 {
3195                         attr = TERM_L_DARK;
3196                 }
3197
3198                 Term_putstr(3, i, n, attr, o_name);
3199                 Term_erase(3 + n, i, 255);
3200
3201                 if (show_weights)
3202                 {
3203                         int wgt = o_ptr->weight * o_ptr->number;
3204 #ifdef JP
3205                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
3206 #else
3207                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
3208 #endif
3209                         prt(tmp_val, i, wid - 9);
3210                 }
3211         }
3212
3213         for (i = z; i < hgt; i++)
3214         {
3215                 Term_erase(0, i, 255);
3216         }
3217 }
3218
3219
3220 /*!
3221  * @brief 装備アイテムの表示を行う /
3222  * Display the equipment.
3223  * @param target_item アイテムの選択処理を行うか否か。
3224  * @return 選択したアイテムのタグ
3225  */
3226 COMMAND_CODE show_equip(int target_item, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
3227 {
3228         COMMAND_CODE i;
3229         int j, k, l;
3230         int             col, cur_col, len;
3231         object_type *o_ptr;
3232         char            tmp_val[80];
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;
3238         TERM_LEN wid, hgt;
3239         char            equip_label[52 + 1];
3240
3241         /* Starting column */
3242         col = command_gap;
3243
3244         Term_get_size(&wid, &hgt);
3245
3246         /* Maximal length */
3247         len = wid - col - 1;
3248
3249
3250         /* Scan the equipment list */
3251         for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
3252         {
3253                 o_ptr = &p_ptr->inventory_list[i];
3254
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;
3259
3260                 object_desc(o_name, o_ptr, 0);
3261
3262                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
3263                 {
3264                         (void)strcpy(out_desc[k], _("(武器を両手持ち)", "(wielding with two-hands)"));
3265                         out_color[k] = TERM_WHITE;
3266                 }
3267                 else
3268                 {
3269                         (void)strcpy(out_desc[k], o_name);
3270                         out_color[k] = tval_to_attr[o_ptr->tval % 128];
3271                 }
3272
3273                 out_index[k] = i;
3274                 /* Grey out charging items */
3275                 if (o_ptr->timeout)
3276                 {
3277                         out_color[k] = TERM_L_DARK;
3278                 }
3279
3280                 /* Extract the maximal length (see below) */
3281 #ifdef JP
3282                 l = strlen(out_desc[k]) + (2 + 1);
3283 #else
3284                 l = strlen(out_desc[k]) + (2 + 3);
3285 #endif
3286
3287
3288                 /* Increase length for labels (if needed) */
3289 #ifdef JP
3290                 if (show_labels) l += (7 + 2);
3291 #else
3292                 if (show_labels) l += (14 + 2);
3293 #endif
3294
3295
3296                 /* Increase length for weight (if needed) */
3297                 if (show_weights) l += 9;
3298
3299                 if (show_item_graph) l += 2;
3300
3301                 /* Maintain the max-length */
3302                 if (l > len) len = l;
3303
3304                 /* Advance the entry */
3305                 k++;
3306         }
3307
3308         /* Hack -- Find a column to start in */
3309 #ifdef JP
3310         col = (len > wid - 6) ? 0 : (wid - len - 1);
3311 #else
3312         col = (len > wid - 4) ? 0 : (wid - len - 1);
3313 #endif
3314
3315         prepare_label_string(equip_label, USE_EQUIP, tval);
3316
3317         /* Output each entry */
3318         for (j = 0; j < k; j++)
3319         {
3320                 i = out_index[j];
3321                 o_ptr = &p_ptr->inventory_list[i];
3322
3323                 /* Clear the line */
3324                 prt("", j + 1, col ? col - 2 : col);
3325
3326                 if (use_menu && target_item)
3327                 {
3328                         if (j == (target_item - 1))
3329                         {
3330                                 strcpy(tmp_val, _("》", "> "));
3331                                 target_item_label = i;
3332                         }
3333                         else strcpy(tmp_val, "  ");
3334                 }
3335                 else if (i >= INVEN_RARM)
3336                 {
3337                         /* Prepare an index --(-- */
3338                         sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
3339                 }
3340                 else
3341                 {
3342                         /* Prepare an index --(-- */
3343                         sprintf(tmp_val, "%c)", index_to_label(i));
3344                 }
3345
3346                 /* Clear the line with the (possibly indented) index */
3347                 put_str(tmp_val, j + 1, col);
3348
3349                 cur_col = col + 3;
3350
3351                 /* Display graphics for object, if desired */
3352                 if (show_item_graph)
3353                 {
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++;
3358
3359                         cur_col += 2;
3360                 }
3361
3362                 /* Use labels */
3363                 if (show_labels)
3364                 {
3365                         /* Mention the use */
3366                         (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
3367
3368                         put_str(tmp_val, j + 1, cur_col);
3369
3370                         /* Display the entry itself */
3371                         c_put_str(out_color[j], out_desc[j], j + 1, _(cur_col + 9, cur_col + 16));
3372                 }
3373
3374                 /* No labels */
3375                 else
3376                 {
3377                         /* Display the entry itself */
3378                         c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
3379                 }
3380
3381                 /* Display the weight if needed */
3382                 if (show_weights)
3383                 {
3384                         int wgt = o_ptr->weight * o_ptr->number;
3385 #ifdef JP
3386                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
3387 #else
3388                         (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
3389 #endif
3390
3391                         prt(tmp_val, j + 1, wid - 9);
3392                 }
3393         }
3394
3395         /* Make a "shadow" below the list (only if needed) */
3396         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
3397
3398         /* Save the new column */
3399         command_gap = col;
3400
3401         return target_item_label;
3402 }