OSDN Git Service

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