OSDN Git Service

Merge remote-tracking branch 'remotes/origin/feature/Fix-English-Bugs' into develop
[hengbandforosx/hengbandosx.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  * 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))
37         return;
38
39     if (!max_autopick) {
40         fprintf(fff, _("自動破壊/拾いには何も登録されていません。", "No preference for auto picker/destroyer."));
41     } else {
42         fprintf(fff, _("   自動拾い/破壊には現在 %d行登録されています。\n\n", "   There are %d registered lines for auto picker/destroyer.\n\n"), max_autopick);
43     }
44
45     for (int k = 0; k < max_autopick; k++) {
46         concptr tmp;
47         byte act = autopick_list[k].action;
48         if (act & DONT_AUTOPICK) {
49             tmp = _("放置", "Leave");
50         } else if (act & DO_AUTODESTROY) {
51             tmp = _("破壊", "Destroy");
52         } else if (act & DO_AUTOPICK) {
53             tmp = _("拾う", "Pickup");
54         } else {
55             tmp = _("確認", "Query");
56         }
57
58         if (act & DO_DISPLAY)
59             fprintf(fff, "%11s", format("[%s]", tmp));
60         else
61             fprintf(fff, "%11s", format("(%s)", tmp));
62
63         tmp = autopick_line_from_entry(&autopick_list[k]);
64         fprintf(fff, " %s", tmp);
65         string_free(tmp);
66         fprintf(fff, "\n");
67     }
68
69     angband_fclose(fff);
70
71     (void)show_file(creature_ptr, TRUE, file_name, _("自動拾い/破壊 設定リスト", "Auto-picker/Destroyer"), 0, 0);
72     fd_kill(file_name);
73 }