OSDN Git Service

[Feature] #2744 日本語版の羊皮紙を追加し、読めるようにコードを拡張した
[hengbandforosx/hengbandosx.git] / src / object-use / read / parchment-read-executor.cpp
1 /*
2  * @brief 読むことができるアイテム群の内、中つ国ガイドを読んだ時の効果や処理を記述する.
3  * @date 2022/02/26
4  * @author Hourier
5  */
6
7 #include "object-use/read/parchment-read-executor.h"
8 #include "core/show-file.h"
9 #include "flavor/flavor-describer.h"
10 #include "flavor/object-flavor-types.h"
11 #include "io/files-util.h"
12 #include "system/angband.h"
13 #include "system/item-entity.h"
14 #include "system/player-type-definition.h"
15 #include "term/screen-processor.h"
16 #include "util/angband-files.h"
17 #include <iomanip>
18 #include <sstream>
19
20 ParchmentReadExecutor::ParchmentReadExecutor(PlayerType *player_ptr, ItemEntity *o_ptr)
21     : player_ptr(player_ptr)
22     , o_ptr(o_ptr)
23 {
24 }
25
26 bool ParchmentReadExecutor::is_identified() const
27 {
28     return false;
29 }
30
31 bool ParchmentReadExecutor::read()
32 {
33     screen_save();
34     std::stringstream ss;
35     ss << "book-" << std::setfill('0') << std::right << std::setw(3) << this->o_ptr->bi_key.sval().value();
36     ss << "_" << _("jp", "en") << ".txt";
37     const auto item_name = describe_flavor(this->player_ptr, this->o_ptr, OD_NAME_ONLY);
38     auto path = path_build(ANGBAND_DIR_FILE, "books");
39     path.append(ss.str());
40     const auto &filename = path.string();
41     (void)show_file(this->player_ptr, true, filename.data(), item_name.data(), 0, 0);
42     screen_load();
43     return false;
44 }