OSDN Git Service

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