1 #include "view/display-inventory.h"
2 #include "flavor/flavor-describer.h"
3 #include "game-option/special-options.h"
4 #include "game-option/text-display-options.h"
5 #include "inventory/inventory-slot-types.h"
6 #include "inventory/inventory-util.h"
7 #include "io/input-key-requester.h"
8 #include "object/item-tester-hooker.h"
9 #include "object/item-use-flags.h"
10 #include "object/object-info.h"
11 #include "object/object-kind.h"
12 #include "system/object-type-definition.h"
13 #include "term/gameterm.h"
14 #include "term/screen-processor.h"
15 #include "term/term-color-types.h"
18 * @brief 所持アイテムの表示を行う /
19 * Display the inventory.
20 * @param target_item アイテムの選択処理を行うか否か。
23 * Hack -- do not display "trailing" empty slots
25 COMMAND_CODE show_inventory(player_type *owner_ptr, int target_item, BIT_FLAGS mode, tval_type tval)
30 GAME_TEXT o_name[MAX_NLEN];
32 COMMAND_CODE out_index[23];
33 TERM_COLOR out_color[23];
34 char out_desc[23][MAX_NLEN];
35 COMMAND_CODE target_item_label = 0;
36 char inven_label[52 + 1];
38 int col = command_gap;
40 term_get_size(&wid, &hgt);
41 int len = wid - col - 1;
42 for (i = 0; i < INVEN_PACK; i++) {
43 o_ptr = &owner_ptr->inventory_list[i];
50 prepare_label_string(owner_ptr, inven_label, USE_INVEN, tval);
51 for (k = 0, i = 0; i < z; i++) {
52 o_ptr = &owner_ptr->inventory_list[i];
53 if (!item_tester_okay(owner_ptr, o_ptr, tval) && !(mode & USE_FULL))
56 describe_flavor(owner_ptr, o_name, o_ptr, 0);
58 out_color[k] = tval_to_attr[o_ptr->tval % 128];
60 out_color[k] = TERM_L_DARK;
62 (void)strcpy(out_desc[k], o_name);
63 l = strlen(out_desc[k]) + 5;
67 if (show_item_graph) {
79 col = (len > wid - 4) ? 0 : (wid - len - 1);
82 for (j = 0; j < k; j++) {
84 o_ptr = &owner_ptr->inventory_list[i];
85 prt("", j + 1, col ? col - 2 : col);
86 if (use_menu && target_item) {
87 if (j == (target_item - 1)) {
88 strcpy(tmp_val, _("》", "> "));
89 target_item_label = i;
92 } else if (i <= INVEN_PACK)
93 sprintf(tmp_val, "%c)", inven_label[i]);
95 sprintf(tmp_val, "%c)", index_to_label(i));
97 put_str(tmp_val, j + 1, col);
99 if (show_item_graph) {
100 TERM_COLOR a = object_attr(o_ptr);
101 SYMBOL_CODE c = object_char(o_ptr);
102 term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
109 c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
111 int wgt = o_ptr->weight * o_ptr->number;
112 (void)sprintf(tmp_val, _("%3d.%1d kg", "%3d.%1d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
113 prt(tmp_val, j + 1, wid - 9);
118 prt("", j + 1, col ? col - 2 : col);
121 return target_item_label;
125 * @brief 所持アイテム一覧を表示する /
126 * Choice window "shadow" of the "show_inven()" function
129 void display_inventory(player_type *owner_ptr, tval_type tval)
131 register int i, n, z = 0;
133 TERM_COLOR attr = TERM_WHITE;
135 GAME_TEXT o_name[MAX_NLEN];
138 if (!owner_ptr || !owner_ptr->inventory_list)
141 term_get_size(&wid, &hgt);
142 for (i = 0; i < INVEN_PACK; i++) {
143 o_ptr = &owner_ptr->inventory_list[i];
149 for (i = 0; i < z; i++) {
150 o_ptr = &owner_ptr->inventory_list[i];
151 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
152 if (item_tester_okay(owner_ptr, o_ptr, tval)) {
153 tmp_val[0] = index_to_label(i);
157 term_putstr(0, i, 3, TERM_WHITE, tmp_val);
158 describe_flavor(owner_ptr, o_name, o_ptr, 0);
160 attr = tval_to_attr[o_ptr->tval % 128];
161 if (o_ptr->timeout) {
165 term_putstr(3, i, n, attr, o_name);
166 term_erase(3 + n, i, 255);
169 int wgt = o_ptr->weight * o_ptr->number;
170 sprintf(tmp_val, _("%3d.%1d kg", "%3d.%1d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
171 prt(tmp_val, i, wid - 9);
175 for (i = z; i < hgt; i++)
176 term_erase(0, i, 255);