OSDN Git Service

ea5a9ae3d24feb8a9e260337b90ad9e49dd53a3f
[hengbandforosx/hengbandosx.git] / src / knowledge / knowledge-autopick.cpp
1 /*!
2  * @brief 自動拾いの登録状況を表示する
3  * @date 2020/04/23
4  * @author Hourier
5  */
6
7 #include "knowledge/knowledge-autopick.h"
8 #include "autopick/autopick-entry.h"
9 #include "autopick/autopick-methods-table.h"
10 #include "autopick/autopick-reader-writer.h"
11 #include "autopick/autopick-util.h"
12 #include "core/asking-player.h"
13 #include "core/show-file.h"
14 #include "io-dump/dump-util.h"
15 #include "system/player-type-definition.h"
16 #include "util/angband-files.h"
17
18 /*!
19  * @brief 自動拾い設定ファイルをロードするコマンドのメインルーチン /
20  * @param player_ptr プレイヤーへの参照ポインタ
21  */
22 void do_cmd_reload_autopick(PlayerType *player_ptr)
23 {
24     if (!get_check(_("自動拾い設定ファイルをロードしますか? ", "Reload auto-pick preference file? "))) {
25         return;
26     }
27
28     autopick_load_pref(player_ptr, true);
29 }
30
31 /*
32  * Check the status of "autopick"
33  */
34 void do_cmd_knowledge_autopick(PlayerType *player_ptr)
35 {
36     FILE *fff = nullptr;
37     GAME_TEXT file_name[FILE_NAME_SIZE];
38     if (!open_temporary_file(&fff, file_name)) {
39         return;
40     }
41
42     if (autopick_list.empty()) {
43         fprintf(fff, _("自動破壊/拾いには何も登録されていません。", "No preference for auto picker/destroyer."));
44     } else {
45         fprintf(fff, _("   自動拾い/破壊には現在 %d行登録されています。\n\n", "   There are %d registered lines for auto picker/destroyer.\n\n"),
46             static_cast<int>(autopick_list.size()));
47     }
48
49     for (auto &item : autopick_list) {
50         concptr tmp;
51         byte act = item.action;
52         if (act & DONT_AUTOPICK) {
53             tmp = _("放置", "Leave");
54         } else if (act & DO_AUTODESTROY) {
55             tmp = _("破壊", "Destroy");
56         } else if (act & DO_AUTOPICK) {
57             tmp = _("拾う", "Pickup");
58         } else {
59             tmp = _("確認", "Query");
60         }
61
62         if (act & DO_DISPLAY) {
63             fprintf(fff, "%11s", format("[%s]", tmp).data());
64         } else {
65             fprintf(fff, "%11s", format("(%s)", tmp).data());
66         }
67
68         tmp = autopick_line_from_entry(&item);
69         fprintf(fff, " %s", tmp);
70         string_free(tmp);
71         fprintf(fff, "\n");
72     }
73
74     angband_fclose(fff);
75
76     (void)show_file(player_ptr, true, file_name, _("自動拾い/破壊 設定リスト", "Auto-picker/Destroyer"), 0, 0);
77     fd_kill(file_name);
78 }