OSDN Git Service

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