OSDN Git Service

Merge remote-tracking branch 'remotes/hengbandosx/english-knowledge-edits' into featu...
[hengband/hengband.git] / src / view / display-store.c
1 #include "view/display-store.h"
2 #include "flavor/flavor-describer.h"
3 #include "game-option/birth-options.h"
4 #include "game-option/special-options.h"
5 #include "game-option/text-display-options.h"
6 #include "grid/feature.h"
7 #include "object-enchant/special-object-flags.h"
8 #include "object/object-info.h"
9 #include "object/object-kind.h"
10 #include "player/race-info-table.h"
11 #include "store/pricing.h"
12 #include "store/store-util.h"
13 #include "store/store.h" // todo 相互依存している、こっちは残す?.
14 #include "system/object-type-definition.h"
15 #include "term/gameterm.h"
16 #include "term/screen-processor.h"
17 #include "util/int-char-converter.h"
18
19 /*!
20  * @brief プレイヤーの所持金を表示する /
21  * Displays players gold                                        -RAK-
22  * @param player_ptr プレーヤーへの参照ポインタ
23  * @return なし
24  * @details
25  */
26 void store_prt_gold(player_type *player_ptr)
27 {
28     prt(_("手持ちのお金: ", "Gold Remaining: "), 19 + xtra_stock, 53);
29     char out_val[64];
30     sprintf(out_val, "%9ld", (long)player_ptr->au);
31     prt(out_val, 19 + xtra_stock, 68);
32 }
33
34 /*!
35  * @brief 店の商品リストを再表示する /
36  * Re-displays a single store entry
37  * @param player_ptr プレーヤーへの参照ポインタ
38  * @param pos 表示行
39  * @return なし
40  */
41 void display_entry(player_type *player_ptr, int pos)
42 {
43     object_type *o_ptr;
44     o_ptr = &st_ptr->stock[pos];
45     int i = (pos % store_bottom);
46
47     /* Label it, clear the line --(-- */
48     char out_val[160];
49     (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
50     prt(out_val, i + 6, 0);
51
52     int cur_col = 3;
53     if (show_item_graph) {
54         TERM_COLOR a = object_attr(o_ptr);
55         SYMBOL_CODE c = object_char(o_ptr);
56
57         term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
58         if (use_bigtile)
59             cur_col++;
60
61         cur_col += 2;
62     }
63
64     /* Describe an item in the home */
65     int maxwid = 75;
66     if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) {
67         maxwid = 75;
68         if (show_weights)
69             maxwid -= 10;
70
71         GAME_TEXT o_name[MAX_NLEN];
72         describe_flavor(player_ptr, o_name, o_ptr, 0);
73         o_name[maxwid] = '\0';
74         c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
75         if (show_weights) {
76             WEIGHT wgt = o_ptr->weight;
77             sprintf(out_val, _("%3d.%1d kg", "%3d.%d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
78             put_str(out_val, i + 6, _(67, 68));
79         }
80
81         return;
82     }
83
84     maxwid = 65;
85     if (show_weights)
86         maxwid -= 7;
87
88     GAME_TEXT o_name[MAX_NLEN];
89     describe_flavor(player_ptr, o_name, o_ptr, 0);
90     o_name[maxwid] = '\0';
91     c_put_str(tval_to_attr[o_ptr->tval], o_name, i + 6, cur_col);
92
93     if (show_weights) {
94         int wgt = o_ptr->weight;
95         sprintf(out_val, "%3d.%1d", _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
96         put_str(out_val, i + 6, _(60, 61));
97     }
98
99     s32b x;
100     if (o_ptr->ident & IDENT_FIXED) {
101         x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
102         (void)sprintf(out_val, _("%9ld固", "%9ld F"), (long)x);
103         put_str(out_val, i + 6, 68);
104         return;
105     }
106
107     if (!manual_haggle) {
108         x = price_item(player_ptr, o_ptr, ot_ptr->min_inflate, FALSE);
109         if (!noneedtobargain(x))
110             x += x / 10;
111
112         (void)sprintf(out_val, "%9ld  ", (long)x);
113         put_str(out_val, i + 6, 68);
114         return;
115     }
116
117     x = price_item(player_ptr, o_ptr, ot_ptr->max_inflate, FALSE);
118     (void)sprintf(out_val, "%9ld  ", (long)x);
119     put_str(out_val, i + 6, 68);
120 }
121
122 /*!
123  * @brief 店の商品リストを表示する /
124  * Displays a store's inventory -RAK-
125  * @param player_ptr プレーヤーへの参照ポインタ
126  * @return なし
127  * @details
128  * All prices are listed as "per individual object".  -BEN-
129  */
130 void display_store_inventory(player_type *player_ptr)
131 {
132     int k;
133     for (k = 0; k < store_bottom; k++) {
134         if (store_top + k >= st_ptr->stock_num)
135             break;
136
137         display_entry(player_ptr, store_top + k);
138     }
139
140     for (int i = k; i < store_bottom + 1; i++)
141         prt("", i + 6, 0);
142
143     put_str(_("          ", "        "), 5, _(20, 22));
144     if (st_ptr->stock_num > store_bottom) {
145         prt(_("-続く-", "-more-"), k + 6, 3);
146         put_str(format(_("(%dページ)  ", "(Page %d)  "), store_top / store_bottom + 1), 5, _(20, 22));
147     }
148
149     if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM) {
150         k = st_ptr->stock_size;
151         if (cur_store_num == STORE_HOME && !powerup_home)
152             k /= 10;
153
154         put_str(format(_("アイテム数:  %4d/%4d", "Objects:  %4d/%4d"), st_ptr->stock_num, k), 19 + xtra_stock, _(27, 30));
155     }
156 }
157
158 /*!
159  * @brief 店舗情報全体を表示するメインルーチン /
160  * Displays store (after clearing screen)               -RAK-
161  * @param player_ptr プレーヤーへの参照ポインタ
162  * @return なし
163  * @details
164  */
165 void display_store(player_type *player_ptr)
166 {
167     term_clear();
168     if (cur_store_num == STORE_HOME) {
169         put_str(_("我が家", "Your Home"), 3, 31);
170         put_str(_("アイテムの一覧", "Item Description"), 5, 4);
171         if (show_weights) {
172             put_str(_("  重さ", "Weight"), 5, 70);
173         }
174
175         store_prt_gold(player_ptr);
176         display_store_inventory(player_ptr);
177         return;
178     }
179
180     if (cur_store_num == STORE_MUSEUM) {
181         put_str(_("博物館", "Museum"), 3, 31);
182         put_str(_("アイテムの一覧", "Item Description"), 5, 4);
183         if (show_weights) {
184             put_str(_("  重さ", "Weight"), 5, 70);
185         }
186
187         store_prt_gold(player_ptr);
188         display_store_inventory(player_ptr);
189         return;
190     }
191
192     concptr store_name = (f_name + f_info[cur_store_feat].name);
193     concptr owner_name = (ot_ptr->owner_name);
194     concptr race_name = race_info[ot_ptr->owner_race].title;
195     char buf[80];
196     sprintf(buf, "%s (%s)", owner_name, race_name);
197     put_str(buf, 3, 10);
198
199     sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
200     prt(buf, 3, 50);
201
202     put_str(_("商品の一覧", "Item Description"), 5, 5);
203     if (show_weights)
204         put_str(_("  重さ", "Weight"), 5, 60);
205
206     put_str(_(" 価格", "Price"), 5, 72);
207     store_prt_gold(player_ptr);
208     display_store_inventory(player_ptr);
209 }