OSDN Git Service

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