OSDN Git Service

Reworded English description of the sniper's SP_PIERCE ability.
[hengband/hengband.git] / src / window / main-window-equipments.c
1 #include "window/main-window-equipments.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-describer.h"
6 #include "inventory/inventory-slot-types.h"
7 #include "inventory/inventory-util.h"
8 #include "io/input-key-requester.h"
9 #include "object/item-tester-hooker.h"
10 #include "object/item-use-flags.h"
11 #include "object/object-info.h"
12 #include "object/object-kind.h"
13 #include "system/object-type-definition.h"
14 #include "term/gameterm.h"
15 #include "term/screen-processor.h"
16 #include "term/term-color-types.h"
17 #include "player/player-status-flags.h"
18
19 /*!
20  * @brief メインウィンドウの右上に装備アイテムの表示させる
21  * Display the equipment.
22  * @param target_item アイテムの選択処理を行うか否か。
23  * @return 選択したアイテムのタグ
24  */
25 COMMAND_CODE show_equipment(player_type *owner_ptr, int target_item, BIT_FLAGS mode, tval_type tval)
26 {
27     COMMAND_CODE i;
28     int j, k, l;
29     object_type *o_ptr;
30     char tmp_val[80];
31     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     TERM_LEN wid, hgt;
37     char equip_label[52 + 1];
38     int col = command_gap;
39     term_get_size(&wid, &hgt);
40     int len = wid - col - 1;
41     for (k = 0, i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
42         o_ptr = &owner_ptr->inventory_list[i];
43         if (!(owner_ptr->select_ring_slot ? is_ring_slot(i) : item_tester_okay(owner_ptr, o_ptr, tval) || (mode & USE_FULL))
44             && (!((((i == INVEN_MAIN_HAND) && can_attack_with_sub_hand(owner_ptr)) || ((i == INVEN_SUB_HAND) && can_attack_with_main_hand(owner_ptr)))
45                     && has_two_handed_weapons(owner_ptr))
46                 || (mode & IGNORE_BOTHHAND_SLOT)))
47             continue;
48
49         describe_flavor(owner_ptr, o_name, o_ptr, 0);
50         if ((((i == INVEN_MAIN_HAND) && can_attack_with_sub_hand(owner_ptr)) || ((i == INVEN_SUB_HAND) && can_attack_with_main_hand(owner_ptr)))
51             && has_two_handed_weapons(owner_ptr)) {
52             (void)strcpy(out_desc[k], _("(武器を両手持ち)", "(wielding with two-hands)"));
53             out_color[k] = TERM_WHITE;
54         } else {
55             (void)strcpy(out_desc[k], o_name);
56             out_color[k] = tval_to_attr[o_ptr->tval % 128];
57         }
58
59         out_index[k] = i;
60         if (o_ptr->timeout)
61             out_color[k] = TERM_L_DARK;
62         l = strlen(out_desc[k]) + (2 + _(1, 3));
63
64         if (show_labels)
65             l += (_(7, 14) + 2);
66
67         if (show_weights)
68             l += 9;
69
70         if (show_item_graph)
71             l += 2;
72
73         if (l > len)
74             len = l;
75
76         k++;
77     }
78
79     col = (len > wid - _(6, 4)) ? 0 : (wid - len - 1);
80     prepare_label_string(owner_ptr, equip_label, USE_EQUIP, tval);
81     for (j = 0; j < k; j++) {
82         i = out_index[j];
83         o_ptr = &owner_ptr->inventory_list[i];
84         prt("", j + 1, col ? col - 2 : col);
85         if (use_menu && target_item) {
86             if (j == (target_item - 1)) {
87                 strcpy(tmp_val, _("》", "> "));
88                 target_item_label = i;
89             } else
90                 strcpy(tmp_val, "  ");
91         } else if (i >= INVEN_MAIN_HAND)
92             sprintf(tmp_val, "%c)", equip_label[i - INVEN_MAIN_HAND]);
93         else
94             sprintf(tmp_val, "%c)", index_to_label(i));
95
96         put_str(tmp_val, j + 1, col);
97         int cur_col = col + 3;
98         if (show_item_graph) {
99             TERM_COLOR a = object_attr(o_ptr);
100             SYMBOL_CODE c = object_char(o_ptr);
101             term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
102             if (use_bigtile)
103                 cur_col++;
104
105             cur_col += 2;
106         }
107
108         if (show_labels) {
109             (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(owner_ptr, i));
110             put_str(tmp_val, j + 1, cur_col);
111             c_put_str(out_color[j], out_desc[j], j + 1, _(cur_col + 9, cur_col + 16));
112         } else
113             c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
114
115         if (!show_weights)
116             continue;
117
118         int wgt = o_ptr->weight * o_ptr->number;
119         (void)sprintf(tmp_val, _("%3d.%1d kg", "%3d.%d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
120         prt(tmp_val, j + 1, wid - 9);
121     }
122
123     if (j && (j < 23))
124         prt("", j + 1, col ? col - 2 : col);
125
126     command_gap = col;
127     return target_item_label;
128 }