OSDN Git Service

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