OSDN Git Service

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