OSDN Git Service

Merge pull request #1176 from sikabane-works/release/3.0.0Alpha25
[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 creature_ptr プレーヤーへの参照ポインタ
21  */
22 void do_cmd_reload_autopick(player_type *creature_ptr)
23 {
24     if (!get_check(_("自動拾い設定ファイルをロードしますか? ", "Reload auto-pick preference file? ")))
25         return;
26
27     autopick_load_pref(creature_ptr, true);
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))
38         return;
39
40     if (!max_autopick) {
41         fprintf(fff, _("自動破壊/拾いには何も登録されていません。", "No preference for auto picker/destroyer."));
42     } else {
43         fprintf(fff, _("   自動拾い/破壊には現在 %d行登録されています。\n\n", "   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         concptr tmp;
48         byte act = autopick_list[k].action;
49         if (act & DONT_AUTOPICK) {
50             tmp = _("放置", "Leave");
51         } else if (act & DO_AUTODESTROY) {
52             tmp = _("破壊", "Destroy");
53         } else if (act & DO_AUTOPICK) {
54             tmp = _("拾う", "Pickup");
55         } else {
56             tmp = _("確認", "Query");
57         }
58
59         if (act & DO_DISPLAY)
60             fprintf(fff, "%11s", format("[%s]", tmp));
61         else
62             fprintf(fff, "%11s", format("(%s)", tmp));
63
64         tmp = autopick_line_from_entry(&autopick_list[k]);
65         fprintf(fff, " %s", tmp);
66         string_free(tmp);
67         fprintf(fff, "\n");
68     }
69
70     angband_fclose(fff);
71
72     (void)show_file(creature_ptr, true, file_name, _("自動拾い/破壊 設定リスト", "Auto-picker/Destroyer"), 0, 0);
73     fd_kill(file_name);
74 }