OSDN Git Service

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