OSDN Git Service

Merge pull request #3532 from sikabane-works/release/3.0.0.87-alpha
[hengbandforosx/hengbandosx.git] / src / view / display-store.cpp
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 "locale/japanese.h"
7 #include "object-enchant/special-object-flags.h"
8 #include "object/object-info.h"
9 #include "player/race-info-table.h"
10 #include "store/pricing.h"
11 #include "store/store-owners.h"
12 #include "store/store-util.h"
13 #include "store/store.h" //!< @todo 相互依存している、こっちは残す?.
14 #include "system/baseitem-info.h"
15 #include "system/item-entity.h"
16 #include "system/player-type-definition.h"
17 #include "system/terrain-type-definition.h"
18 #include "term/gameterm.h"
19 #include "term/screen-processor.h"
20 #include "term/z-form.h"
21 #include "util/enum-converter.h"
22 #include "util/int-char-converter.h"
23
24 /*!
25  * @brief プレイヤーの所持金を表示する /
26  * Displays players gold                                        -RAK-
27  * @param player_ptr プレイヤーへの参照ポインタ
28  * @details
29  */
30 void store_prt_gold(PlayerType *player_ptr)
31 {
32     prt(_("手持ちのお金: ", "Gold Remaining: "), 19 + xtra_stock, 53);
33     prt(format("%9ld", (long)player_ptr->au), 19 + xtra_stock, 68);
34 }
35
36 /*!
37  * @brief 店の商品リストを再表示する /
38  * Re-displays a single store entry
39  * @param player_ptr プレイヤーへの参照ポインタ
40  * @param pos 表示行
41  */
42 void display_entry(PlayerType *player_ptr, int pos, StoreSaleType store_num)
43 {
44     ItemEntity *o_ptr;
45     o_ptr = &st_ptr->stock[pos];
46     int i = (pos % store_bottom);
47
48     /* Label it, clear the line --(-- */
49     prt(format("%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i))), i + 6, 0);
50
51     int cur_col = 3;
52     if (show_item_graph) {
53         const auto a = o_ptr->get_color();
54         const auto c = o_ptr->get_symbol();
55
56         term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
57         if (use_bigtile) {
58             cur_col++;
59         }
60
61         cur_col += 2;
62     }
63
64     /* Describe an item in the home */
65     int maxwid = 75;
66     if ((store_num == StoreSaleType::HOME) || (store_num == StoreSaleType::MUSEUM)) {
67         if (show_weights) {
68             maxwid -= 10;
69         }
70
71         const auto item_name = describe_flavor(player_ptr, o_ptr, 0, maxwid);
72         c_put_str(tval_to_attr[enum2i(o_ptr->bi_key.tval())], item_name, i + 6, cur_col);
73
74         if (show_weights) {
75             WEIGHT wgt = o_ptr->weight;
76             put_str(format(_("%3d.%1d kg", "%3d.%d lb"), _(lb_to_kg_integer(wgt), wgt / 10), _(lb_to_kg_fraction(wgt), wgt % 10)), i + 6, _(67, 68));
77         }
78
79         return;
80     }
81
82     maxwid = 65;
83     if (show_weights) {
84         maxwid -= 7;
85     }
86
87     const auto item_name = describe_flavor(player_ptr, o_ptr, 0, maxwid);
88     c_put_str(tval_to_attr[enum2i(o_ptr->bi_key.tval())], item_name, i + 6, cur_col);
89
90     if (show_weights) {
91         int wgt = o_ptr->weight;
92         put_str(format("%3d.%1d", _(lb_to_kg_integer(wgt), wgt / 10), _(lb_to_kg_fraction(wgt), wgt % 10)), i + 6, _(60, 61));
93     }
94
95     const auto price = price_item(player_ptr, o_ptr, ot_ptr->inflate, false, store_num);
96     put_str(format("%9ld  ", (long)price), i + 6, 68);
97 }
98
99 /*!
100  * @brief 店の商品リストを表示する /
101  * Displays a store's inventory -RAK-
102  * @param player_ptr プレイヤーへの参照ポインタ
103  * @details
104  * All prices are listed as "per individual object".  -BEN-
105  */
106 void display_store_inventory(PlayerType *player_ptr, StoreSaleType store_num)
107 {
108     int k;
109     for (k = 0; k < store_bottom; k++) {
110         if (store_top + k >= st_ptr->stock_num) {
111             break;
112         }
113
114         display_entry(player_ptr, store_top + k, store_num);
115     }
116
117     for (int i = k; i < store_bottom + 1; i++) {
118         prt("", i + 6, 0);
119     }
120
121     put_str(_("          ", "        "), 5, _(20, 22));
122     if (st_ptr->stock_num > store_bottom) {
123         prt(_("-続く-", "-more-"), k + 6, 3);
124         put_str(format(_("(%dページ)  ", "(Page %d)  "), store_top / store_bottom + 1), 5, _(20, 22));
125     }
126
127     if (store_num == StoreSaleType::HOME || store_num == StoreSaleType::MUSEUM) {
128         k = st_ptr->stock_size;
129         if (store_num == StoreSaleType::HOME && !powerup_home) {
130             k /= 10;
131         }
132
133         put_str(format(_("アイテム数:  %4d/%4d", "Objects:  %4d/%4d"), st_ptr->stock_num, k), 19 + xtra_stock, _(27, 30));
134     }
135 }
136
137 /*!
138  * @brief 店舗情報全体を表示するメインルーチン /
139  * Displays store (after clearing screen)               -RAK-
140  * @param player_ptr プレイヤーへの参照ポインタ
141  * @details
142  */
143 void display_store(PlayerType *player_ptr, StoreSaleType store_num)
144 {
145     term_clear();
146     if (store_num == StoreSaleType::HOME) {
147         put_str(_("我が家", "Your Home"), 3, 31);
148         put_str(_("アイテムの一覧", "Item Description"), 5, 4);
149         if (show_weights) {
150             put_str(_("  重さ", "Weight"), 5, 70);
151         }
152
153         store_prt_gold(player_ptr);
154         display_store_inventory(player_ptr, store_num);
155         return;
156     }
157
158     if (store_num == StoreSaleType::MUSEUM) {
159         put_str(_("博物館", "Museum"), 3, 31);
160         put_str(_("アイテムの一覧", "Item Description"), 5, 4);
161         if (show_weights) {
162             put_str(_("  重さ", "Weight"), 5, 70);
163         }
164
165         store_prt_gold(player_ptr);
166         display_store_inventory(player_ptr, store_num);
167         return;
168     }
169
170     concptr store_name = terrains_info[cur_store_feat].name.data();
171     concptr owner_name = (ot_ptr->owner_name);
172     concptr race_name = race_info[enum2i(ot_ptr->owner_race)].title;
173     put_str(format("%s (%s)", owner_name, race_name), 3, 10);
174
175     prt(format("%s (%ld)", store_name, (long)(ot_ptr->max_cost)), 3, 50);
176
177     put_str(_("商品の一覧", "Item Description"), 5, 5);
178     if (show_weights) {
179         put_str(_("  重さ", "Weight"), 5, 60);
180     }
181
182     put_str(_(" 価格", "Price"), 5, 72);
183     store_prt_gold(player_ptr);
184     display_store_inventory(player_ptr, store_num);
185 }