OSDN Git Service

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