• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisionec136293305be7db53bc9ab5c92c41b8f13624c7 (tree)
Zeit2020-03-22 14:28:05
AutorHourier <hourier@user...>
CommiterHourier

Log Message

[Refactor] #40236 Separated cmd-macro.c/h from cmd-dump.c

Ändern Zusammenfassung

Diff

--- a/Hengband_vcs2017/Hengband/Hengband.vcxproj
+++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj
@@ -164,6 +164,7 @@
164164 <ClCompile Include="..\..\src\cmd\cmd-help.c" />
165165 <ClCompile Include="..\..\src\cmd\cmd-hissatsu.c" />
166166 <ClCompile Include="..\..\src\cmd\cmd-item.c" />
167+ <ClCompile Include="..\..\src\cmd\cmd-macro.c" />
167168 <ClCompile Include="..\..\src\cmd\cmd-magiceat.c" />
168169 <ClCompile Include="..\..\src\cmd\cmd-mane.c" />
169170 <ClCompile Include="..\..\src\cmd\cmd-pet.c" />
@@ -342,6 +343,7 @@
342343 <ClInclude Include="..\..\src\cmd\cmd-help.h" />
343344 <ClInclude Include="..\..\src\cmd\cmd-hissatsu.h" />
344345 <ClInclude Include="..\..\src\cmd\cmd-item.h" />
346+ <ClInclude Include="..\..\src\cmd\cmd-macro.h" />
345347 <ClInclude Include="..\..\src\cmd\cmd-magiceat.h" />
346348 <ClInclude Include="..\..\src\cmd\cmd-mane.h" />
347349 <ClInclude Include="..\..\src\cmd\cmd-pet.h" />
--- a/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
+++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
@@ -523,6 +523,9 @@
523523 <ClCompile Include="..\..\src\cmd\object-group-table.c">
524524 <Filter>cmd</Filter>
525525 </ClCompile>
526+ <ClCompile Include="..\..\src\cmd\cmd-macro.c">
527+ <Filter>cmd</Filter>
528+ </ClCompile>
526529 </ItemGroup>
527530 <ItemGroup>
528531 <ClInclude Include="..\..\src\gamevalue.h" />
@@ -1028,6 +1031,9 @@
10281031 <ClInclude Include="..\..\src\cmd\object-group-table.h">
10291032 <Filter>cmd</Filter>
10301033 </ClInclude>
1034+ <ClInclude Include="..\..\src\cmd\cmd-macro.h">
1035+ <Filter>cmd</Filter>
1036+ </ClInclude>
10311037 </ItemGroup>
10321038 <ItemGroup>
10331039 <None Include="..\..\src\wall.bmp" />
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -141,6 +141,7 @@ hengband_SOURCES = \
141141 cmd/cmd-gameoption.c cmd/cmd-gameoption.h cmd/cmd-help.c cmd/cmd-help.h \
142142 cmd/cmd-hissatsu.c cmd/cmd-hissatsu.h cmd/cmd-item.c cmd/cmd-item.h \
143143 cmd/cmd-magiceat.c cmd/cmd-magiceat.h cmd/cmd-mane.c cmd/cmd-mane.h \
144+ cmd/cmd-macro.c cmd/cmd-macro.h \
144145 cmd/cmd-pet.c cmd/cmd-pet.h cmd/cmd-quaff.c cmd/cmd-quaff.h \
145146 cmd/cmd-read.c cmd/cmd-read.h cmd/cmd-save.c cmd/cmd-save.h \
146147 cmd/cmd-smith.c cmd/cmd-smith.h cmd/cmd-spell.c cmd/cmd-spell.h \
--- a/src/cmd/cmd-dump.c
+++ b/src/cmd/cmd-dump.c
@@ -63,7 +63,6 @@
6363 #include "monster-status.h"
6464 #include "view-mainwindow.h"
6565 #include "dungeon-file.h"
66-#include "io/read-pref-file.h"
6766 #include "io/interpret-pref-file.h"
6867 #include "files.h"
6968 #include "spells.h"
@@ -564,324 +563,6 @@ void do_cmd_reload_autopick(player_type *creature_ptr)
564563
565564
566565 /*!
567- * @brief マクロ情報をprefファイルに保存する /
568- * @param fname ファイル名
569- * @return なし
570- */
571-static void macro_dump(concptr fname)
572-{
573- static concptr mark = "Macro Dump";
574- char buf[1024];
575- path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
576- FILE_TYPE(FILE_TYPE_TEXT);
577- if (!open_auto_dump(buf, mark)) return;
578-
579- auto_dump_printf(_("\n# 自動マクロセーブ\n\n", "\n# Automatic macro dump\n\n"));
580- for (int i = 0; i < macro__num; i++)
581- {
582- ascii_to_text(buf, macro__act[i]);
583- auto_dump_printf("A:%s\n", buf);
584- ascii_to_text(buf, macro__pat[i]);
585- auto_dump_printf("P:%s\n", buf);
586- auto_dump_printf("\n");
587- }
588-
589- close_auto_dump();
590-}
591-
592-
593-/*!
594- * @brief マクロのトリガーキーを取得する /
595- * Hack -- ask for a "trigger" (see below)
596- * @param buf キー表記を保管するバッファ
597- * @return なし
598- * @details
599- * <pre>
600- * Note the complex use of the "inkey()" function from "util.c".
601- *
602- * Note that both "flush()" calls are extremely important.
603- * </pre>
604- */
605-static void do_cmd_macro_aux(char *buf)
606-{
607- flush();
608- inkey_base = TRUE;
609- char i = inkey();
610- int n = 0;
611- while (i)
612- {
613- buf[n++] = i;
614- inkey_base = TRUE;
615- inkey_scan = TRUE;
616- i = inkey();
617- }
618-
619- buf[n] = '\0';
620- flush();
621- char tmp[1024];
622- ascii_to_text(tmp, buf);
623- Term_addstr(-1, TERM_WHITE, tmp);
624-}
625-
626-
627-/*!
628- * @brief マクロのキー表記からアスキーコードを得てターミナルに表示する /
629- * Hack -- ask for a keymap "trigger" (see below)
630- * @param buf キー表記を取得するバッファ
631- * @return なし
632- * @details
633- * <pre>
634- * Note that both "flush()" calls are extremely important. This may
635- * no longer be true, since "util.c" is much simpler now.
636- * </pre>
637- */
638-static void do_cmd_macro_aux_keymap(char *buf)
639-{
640- char tmp[1024];
641- flush();
642- buf[0] = inkey();
643- buf[1] = '\0';
644- ascii_to_text(tmp, buf);
645- Term_addstr(-1, TERM_WHITE, tmp);
646- flush();
647-}
648-
649-
650-/*!
651- * @brief キーマップをprefファイルにダンプする /
652- * Hack -- append all keymaps to the given file
653- * @param fname ファイルネーム
654- * @return エラーコード
655- * @details
656- */
657-static errr keymap_dump(concptr fname)
658-{
659- static concptr mark = "Keymap Dump";
660- char key[1024];
661- char buf[1024];
662- BIT_FLAGS mode;
663- if (rogue_like_commands)
664- {
665- mode = KEYMAP_MODE_ROGUE;
666- }
667- else
668- {
669- mode = KEYMAP_MODE_ORIG;
670- }
671-
672- path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
673- FILE_TYPE(FILE_TYPE_TEXT);
674- if (!open_auto_dump(buf, mark)) return -1;
675-
676- auto_dump_printf(_("\n# 自動キー配置セーブ\n\n", "\n# Automatic keymap dump\n\n"));
677- for (int i = 0; i < 256; i++)
678- {
679- concptr act;
680- act = keymap_act[mode][i];
681- if (!act) continue;
682-
683- buf[0] = (char)i;
684- buf[1] = '\0';
685- ascii_to_text(key, buf);
686- ascii_to_text(buf, act);
687- auto_dump_printf("A:%s\n", buf);
688- auto_dump_printf("C:%d:%s\n", mode, key);
689- }
690-
691- close_auto_dump();
692- return 0;
693-}
694-
695-
696-/*!
697- * @brief マクロを設定するコマンドのメインルーチン /
698- * Interact with "macros"
699- * @return なし
700- * @details
701- * <pre>
702- * Note that the macro "action" must be defined before the trigger.
703- *
704- * Could use some helpful instructions on this page.
705- * </pre>
706- */
707-void do_cmd_macros(player_type *creature_ptr)
708-{
709- char tmp[1024];
710- char buf[1024];
711- BIT_FLAGS mode = rogue_like_commands ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG;
712- FILE_TYPE(FILE_TYPE_TEXT);
713- screen_save();
714- while (TRUE)
715- {
716- Term_clear();
717- prt(_("[ マクロの設定 ]", "Interact with Macros"), 2, 0);
718- prt(_("マクロ行動が(もしあれば)下に表示されます:", "Current action (if any) shown below:"), 20, 0);
719- ascii_to_text(buf, macro__buf);
720- prt(buf, 22, 0);
721-
722- prt(_("(1) ユーザー設定ファイルのロード", "(1) Load a user pref file"), 4, 5);
723- prt(_("(2) ファイルにマクロを追加", "(2) Append macros to a file"), 5, 5);
724- prt(_("(3) マクロの確認", "(3) Query a macro"), 6, 5);
725- prt(_("(4) マクロの作成", "(4) Create a macro"), 7, 5);
726- prt(_("(5) マクロの削除", "(5) Remove a macro"), 8, 5);
727- prt(_("(6) ファイルにキー配置を追加", "(6) Append keymaps to a file"), 9, 5);
728- prt(_("(7) キー配置の確認", "(7) Query a keymap"), 10, 5);
729- prt(_("(8) キー配置の作成", "(8) Create a keymap"), 11, 5);
730- prt(_("(9) キー配置の削除", "(9) Remove a keymap"), 12, 5);
731- prt(_("(0) マクロ行動の入力", "(0) Enter a new action"), 13, 5);
732-
733- prt(_("コマンド: ", "Command: "), 16, 0);
734- int i = inkey();
735- if (i == ESCAPE) break;
736-
737- else if (i == '1')
738- {
739- prt(_("コマンド: ユーザー設定ファイルのロード", "Command: Load a user pref file"), 16, 0);
740- prt(_("ファイル: ", "File: "), 18, 0);
741- sprintf(tmp, "%s.prf", creature_ptr->base_name);
742- if (!askfor(tmp, 80)) continue;
743-
744- errr err = process_pref_file(creature_ptr, tmp);
745- if (-2 == err)
746- msg_format(_("標準の設定ファイル'%s'を読み込みました。", "Loaded default '%s'."), tmp);
747- else if (err)
748- msg_format(_("'%s'の読み込みに失敗しました!", "Failed to load '%s'!"), tmp);
749- else
750- msg_format(_("'%s'を読み込みました。", "Loaded '%s'."), tmp);
751- }
752- else if (i == '2')
753- {
754- prt(_("コマンド: マクロをファイルに追加する", "Command: Append macros to a file"), 16, 0);
755- prt(_("ファイル: ", "File: "), 18, 0);
756- sprintf(tmp, "%s.prf", creature_ptr->base_name);
757- if (!askfor(tmp, 80)) continue;
758-
759- macro_dump(tmp);
760- msg_print(_("マクロを追加しました。", "Appended macros."));
761- }
762- else if (i == '3')
763- {
764- prt(_("コマンド: マクロの確認", "Command: Query a macro"), 16, 0);
765- prt(_("トリガーキー: ", "Trigger: "), 18, 0);
766- do_cmd_macro_aux(buf);
767- int k = macro_find_exact(buf);
768- if (k < 0)
769- {
770- msg_print(_("そのキーにはマクロは定義されていません。", "Found no macro."));
771- }
772- else
773- {
774- strcpy(macro__buf, macro__act[k]);
775- ascii_to_text(buf, macro__buf);
776- prt(buf, 22, 0);
777- msg_print(_("マクロを確認しました。", "Found a macro."));
778- }
779- }
780- else if (i == '4')
781- {
782- prt(_("コマンド: マクロの作成", "Command: Create a macro"), 16, 0);
783- prt(_("トリガーキー: ", "Trigger: "), 18, 0);
784- do_cmd_macro_aux(buf);
785- clear_from(20);
786- c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
787- "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
788- prt(_("マクロ行動: ", "Action: "), 20, 0);
789- ascii_to_text(tmp, macro__buf);
790- if (askfor(tmp, 80))
791- {
792- text_to_ascii(macro__buf, tmp);
793- macro_add(buf, macro__buf);
794- msg_print(_("マクロを追加しました。", "Added a macro."));
795- }
796- }
797- else if (i == '5')
798- {
799- prt(_("コマンド: マクロの削除", "Command: Remove a macro"), 16, 0);
800- prt(_("トリガーキー: ", "Trigger: "), 18, 0);
801- do_cmd_macro_aux(buf);
802- macro_add(buf, buf);
803- msg_print(_("マクロを削除しました。", "Removed a macro."));
804- }
805- else if (i == '6')
806- {
807- prt(_("コマンド: キー配置をファイルに追加する", "Command: Append keymaps to a file"), 16, 0);
808- prt(_("ファイル: ", "File: "), 18, 0);
809- sprintf(tmp, "%s.prf", creature_ptr->base_name);
810- if (!askfor(tmp, 80)) continue;
811-
812- (void)keymap_dump(tmp);
813- msg_print(_("キー配置を追加しました。", "Appended keymaps."));
814- }
815- else if (i == '7')
816- {
817- prt(_("コマンド: キー配置の確認", "Command: Query a keymap"), 16, 0);
818- prt(_("押すキー: ", "Keypress: "), 18, 0);
819- do_cmd_macro_aux_keymap(buf);
820- concptr act = keymap_act[mode][(byte)(buf[0])];
821- if (!act)
822- {
823- msg_print(_("キー配置は定義されていません。", "Found no keymap."));
824- }
825- else
826- {
827- strcpy(macro__buf, act);
828- ascii_to_text(buf, macro__buf);
829- prt(buf, 22, 0);
830- msg_print(_("キー配置を確認しました。", "Found a keymap."));
831- }
832- }
833- else if (i == '8')
834- {
835- prt(_("コマンド: キー配置の作成", "Command: Create a keymap"), 16, 0);
836- prt(_("押すキー: ", "Keypress: "), 18, 0);
837- do_cmd_macro_aux_keymap(buf);
838- clear_from(20);
839- c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
840- "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
841- prt(_("行動: ", "Action: "), 20, 0);
842- ascii_to_text(tmp, macro__buf);
843- if (askfor(tmp, 80))
844- {
845- text_to_ascii(macro__buf, tmp);
846- string_free(keymap_act[mode][(byte)(buf[0])]);
847- keymap_act[mode][(byte)(buf[0])] = string_make(macro__buf);
848- msg_print(_("キー配置を追加しました。", "Added a keymap."));
849- }
850- }
851- else if (i == '9')
852- {
853- prt(_("コマンド: キー配置の削除", "Command: Remove a keymap"), 16, 0);
854- prt(_("押すキー: ", "Keypress: "), 18, 0);
855- do_cmd_macro_aux_keymap(buf);
856- string_free(keymap_act[mode][(byte)(buf[0])]);
857- keymap_act[mode][(byte)(buf[0])] = NULL;
858- msg_print(_("キー配置を削除しました。", "Removed a keymap."));
859- }
860- else if (i == '0')
861- {
862- prt(_("コマンド: マクロ行動の入力", "Command: Enter a new action"), 16, 0);
863- clear_from(20);
864- c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
865- "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
866- prt(_("マクロ行動: ", "Action: "), 20, 0);
867- tmp[80] = '\0';
868- if (!askfor(buf, 80)) continue;
869-
870- text_to_ascii(macro__buf, buf);
871- }
872- else
873- {
874- bell();
875- }
876-
877- msg_erase();
878- }
879-
880- screen_load();
881-}
882-
883-
884-/*!
885566 * @brief キャラクタ色の明暗表現
886567 */
887568 static concptr lighting_level_str[F_LIT_MAX] =
--- a/src/cmd/cmd-dump.h
+++ b/src/cmd/cmd-dump.h
@@ -11,7 +11,6 @@ extern void do_cmd_message_one(void);
1111 extern void do_cmd_messages(int num_now);
1212 extern void do_cmd_pref(player_type *creature_ptr);
1313 extern void do_cmd_reload_autopick(player_type *creature_ptr);
14-extern void do_cmd_macros(player_type *creature_ptr);
1514 extern void do_cmd_visuals(player_type *creature_ptr);
1615 extern void do_cmd_colors(player_type *creature_ptr);
1716 extern void do_cmd_note(void);
--- /dev/null
+++ b/src/cmd/cmd-macro.c
@@ -0,0 +1,323 @@
1+#include "angband.h"
2+#include "cmd-macro.h"
3+#include "cmd-gameoption.h"
4+#include "files.h"
5+#include "io/read-pref-file.h"
6+#include "term.h"
7+
8+/*!
9+ * @brief マクロ情報をprefファイルに保存する /
10+ * @param fname ファイル名
11+ * @return なし
12+ */
13+static void macro_dump(concptr fname)
14+{
15+ static concptr mark = "Macro Dump";
16+ char buf[1024];
17+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
18+ FILE_TYPE(FILE_TYPE_TEXT);
19+ if (!open_auto_dump(buf, mark)) return;
20+
21+ auto_dump_printf(_("\n# 自動マクロセーブ\n\n", "\n# Automatic macro dump\n\n"));
22+ for (int i = 0; i < macro__num; i++)
23+ {
24+ ascii_to_text(buf, macro__act[i]);
25+ auto_dump_printf("A:%s\n", buf);
26+ ascii_to_text(buf, macro__pat[i]);
27+ auto_dump_printf("P:%s\n", buf);
28+ auto_dump_printf("\n");
29+ }
30+
31+ close_auto_dump();
32+}
33+
34+
35+/*!
36+ * @brief マクロのトリガーキーを取得する /
37+ * Hack -- ask for a "trigger" (see below)
38+ * @param buf キー表記を保管するバッファ
39+ * @return なし
40+ * @details
41+ * <pre>
42+ * Note the complex use of the "inkey()" function from "util.c".
43+ *
44+ * Note that both "flush()" calls are extremely important.
45+ * </pre>
46+ */
47+static void do_cmd_macro_aux(char *buf)
48+{
49+ flush();
50+ inkey_base = TRUE;
51+ char i = inkey();
52+ int n = 0;
53+ while (i)
54+ {
55+ buf[n++] = i;
56+ inkey_base = TRUE;
57+ inkey_scan = TRUE;
58+ i = inkey();
59+ }
60+
61+ buf[n] = '\0';
62+ flush();
63+ char tmp[1024];
64+ ascii_to_text(tmp, buf);
65+ Term_addstr(-1, TERM_WHITE, tmp);
66+}
67+
68+
69+/*!
70+ * @brief マクロのキー表記からアスキーコードを得てターミナルに表示する /
71+ * Hack -- ask for a keymap "trigger" (see below)
72+ * @param buf キー表記を取得するバッファ
73+ * @return なし
74+ * @details
75+ * <pre>
76+ * Note that both "flush()" calls are extremely important. This may
77+ * no longer be true, since "util.c" is much simpler now.
78+ * </pre>
79+ */
80+static void do_cmd_macro_aux_keymap(char *buf)
81+{
82+ char tmp[1024];
83+ flush();
84+ buf[0] = inkey();
85+ buf[1] = '\0';
86+ ascii_to_text(tmp, buf);
87+ Term_addstr(-1, TERM_WHITE, tmp);
88+ flush();
89+}
90+
91+
92+/*!
93+ * @brief キーマップをprefファイルにダンプする /
94+ * Hack -- append all keymaps to the given file
95+ * @param fname ファイルネーム
96+ * @return エラーコード
97+ * @details
98+ */
99+static errr keymap_dump(concptr fname)
100+{
101+ static concptr mark = "Keymap Dump";
102+ char key[1024];
103+ char buf[1024];
104+ BIT_FLAGS mode;
105+ if (rogue_like_commands)
106+ {
107+ mode = KEYMAP_MODE_ROGUE;
108+ }
109+ else
110+ {
111+ mode = KEYMAP_MODE_ORIG;
112+ }
113+
114+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
115+ FILE_TYPE(FILE_TYPE_TEXT);
116+ if (!open_auto_dump(buf, mark)) return -1;
117+
118+ auto_dump_printf(_("\n# 自動キー配置セーブ\n\n", "\n# Automatic keymap dump\n\n"));
119+ for (int i = 0; i < 256; i++)
120+ {
121+ concptr act;
122+ act = keymap_act[mode][i];
123+ if (!act) continue;
124+
125+ buf[0] = (char)i;
126+ buf[1] = '\0';
127+ ascii_to_text(key, buf);
128+ ascii_to_text(buf, act);
129+ auto_dump_printf("A:%s\n", buf);
130+ auto_dump_printf("C:%d:%s\n", mode, key);
131+ }
132+
133+ close_auto_dump();
134+ return 0;
135+}
136+
137+
138+/*!
139+ * @brief マクロを設定するコマンドのメインルーチン /
140+ * Interact with "macros"
141+ * @return なし
142+ * @details
143+ * <pre>
144+ * Note that the macro "action" must be defined before the trigger.
145+ *
146+ * Could use some helpful instructions on this page.
147+ * </pre>
148+ */
149+void do_cmd_macros(player_type *creature_ptr)
150+{
151+ char tmp[1024];
152+ char buf[1024];
153+ BIT_FLAGS mode = rogue_like_commands ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG;
154+ FILE_TYPE(FILE_TYPE_TEXT);
155+ screen_save();
156+ while (TRUE)
157+ {
158+ Term_clear();
159+ prt(_("[ マクロの設定 ]", "Interact with Macros"), 2, 0);
160+ prt(_("マクロ行動が(もしあれば)下に表示されます:", "Current action (if any) shown below:"), 20, 0);
161+ ascii_to_text(buf, macro__buf);
162+ prt(buf, 22, 0);
163+
164+ prt(_("(1) ユーザー設定ファイルのロード", "(1) Load a user pref file"), 4, 5);
165+ prt(_("(2) ファイルにマクロを追加", "(2) Append macros to a file"), 5, 5);
166+ prt(_("(3) マクロの確認", "(3) Query a macro"), 6, 5);
167+ prt(_("(4) マクロの作成", "(4) Create a macro"), 7, 5);
168+ prt(_("(5) マクロの削除", "(5) Remove a macro"), 8, 5);
169+ prt(_("(6) ファイルにキー配置を追加", "(6) Append keymaps to a file"), 9, 5);
170+ prt(_("(7) キー配置の確認", "(7) Query a keymap"), 10, 5);
171+ prt(_("(8) キー配置の作成", "(8) Create a keymap"), 11, 5);
172+ prt(_("(9) キー配置の削除", "(9) Remove a keymap"), 12, 5);
173+ prt(_("(0) マクロ行動の入力", "(0) Enter a new action"), 13, 5);
174+
175+ prt(_("コマンド: ", "Command: "), 16, 0);
176+ int i = inkey();
177+ if (i == ESCAPE) break;
178+
179+ else if (i == '1')
180+ {
181+ prt(_("コマンド: ユーザー設定ファイルのロード", "Command: Load a user pref file"), 16, 0);
182+ prt(_("ファイル: ", "File: "), 18, 0);
183+ sprintf(tmp, "%s.prf", creature_ptr->base_name);
184+ if (!askfor(tmp, 80)) continue;
185+
186+ errr err = process_pref_file(creature_ptr, tmp);
187+ if (-2 == err)
188+ msg_format(_("標準の設定ファイル'%s'を読み込みました。", "Loaded default '%s'."), tmp);
189+ else if (err)
190+ msg_format(_("'%s'の読み込みに失敗しました!", "Failed to load '%s'!"), tmp);
191+ else
192+ msg_format(_("'%s'を読み込みました。", "Loaded '%s'."), tmp);
193+ }
194+ else if (i == '2')
195+ {
196+ prt(_("コマンド: マクロをファイルに追加する", "Command: Append macros to a file"), 16, 0);
197+ prt(_("ファイル: ", "File: "), 18, 0);
198+ sprintf(tmp, "%s.prf", creature_ptr->base_name);
199+ if (!askfor(tmp, 80)) continue;
200+
201+ macro_dump(tmp);
202+ msg_print(_("マクロを追加しました。", "Appended macros."));
203+ }
204+ else if (i == '3')
205+ {
206+ prt(_("コマンド: マクロの確認", "Command: Query a macro"), 16, 0);
207+ prt(_("トリガーキー: ", "Trigger: "), 18, 0);
208+ do_cmd_macro_aux(buf);
209+ int k = macro_find_exact(buf);
210+ if (k < 0)
211+ {
212+ msg_print(_("そのキーにはマクロは定義されていません。", "Found no macro."));
213+ }
214+ else
215+ {
216+ strcpy(macro__buf, macro__act[k]);
217+ ascii_to_text(buf, macro__buf);
218+ prt(buf, 22, 0);
219+ msg_print(_("マクロを確認しました。", "Found a macro."));
220+ }
221+ }
222+ else if (i == '4')
223+ {
224+ prt(_("コマンド: マクロの作成", "Command: Create a macro"), 16, 0);
225+ prt(_("トリガーキー: ", "Trigger: "), 18, 0);
226+ do_cmd_macro_aux(buf);
227+ clear_from(20);
228+ c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
229+ "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
230+ prt(_("マクロ行動: ", "Action: "), 20, 0);
231+ ascii_to_text(tmp, macro__buf);
232+ if (askfor(tmp, 80))
233+ {
234+ text_to_ascii(macro__buf, tmp);
235+ macro_add(buf, macro__buf);
236+ msg_print(_("マクロを追加しました。", "Added a macro."));
237+ }
238+ }
239+ else if (i == '5')
240+ {
241+ prt(_("コマンド: マクロの削除", "Command: Remove a macro"), 16, 0);
242+ prt(_("トリガーキー: ", "Trigger: "), 18, 0);
243+ do_cmd_macro_aux(buf);
244+ macro_add(buf, buf);
245+ msg_print(_("マクロを削除しました。", "Removed a macro."));
246+ }
247+ else if (i == '6')
248+ {
249+ prt(_("コマンド: キー配置をファイルに追加する", "Command: Append keymaps to a file"), 16, 0);
250+ prt(_("ファイル: ", "File: "), 18, 0);
251+ sprintf(tmp, "%s.prf", creature_ptr->base_name);
252+ if (!askfor(tmp, 80)) continue;
253+
254+ (void)keymap_dump(tmp);
255+ msg_print(_("キー配置を追加しました。", "Appended keymaps."));
256+ }
257+ else if (i == '7')
258+ {
259+ prt(_("コマンド: キー配置の確認", "Command: Query a keymap"), 16, 0);
260+ prt(_("押すキー: ", "Keypress: "), 18, 0);
261+ do_cmd_macro_aux_keymap(buf);
262+ concptr act = keymap_act[mode][(byte)(buf[0])];
263+ if (!act)
264+ {
265+ msg_print(_("キー配置は定義されていません。", "Found no keymap."));
266+ }
267+ else
268+ {
269+ strcpy(macro__buf, act);
270+ ascii_to_text(buf, macro__buf);
271+ prt(buf, 22, 0);
272+ msg_print(_("キー配置を確認しました。", "Found a keymap."));
273+ }
274+ }
275+ else if (i == '8')
276+ {
277+ prt(_("コマンド: キー配置の作成", "Command: Create a keymap"), 16, 0);
278+ prt(_("押すキー: ", "Keypress: "), 18, 0);
279+ do_cmd_macro_aux_keymap(buf);
280+ clear_from(20);
281+ c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
282+ "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
283+ prt(_("行動: ", "Action: "), 20, 0);
284+ ascii_to_text(tmp, macro__buf);
285+ if (askfor(tmp, 80))
286+ {
287+ text_to_ascii(macro__buf, tmp);
288+ string_free(keymap_act[mode][(byte)(buf[0])]);
289+ keymap_act[mode][(byte)(buf[0])] = string_make(macro__buf);
290+ msg_print(_("キー配置を追加しました。", "Added a keymap."));
291+ }
292+ }
293+ else if (i == '9')
294+ {
295+ prt(_("コマンド: キー配置の削除", "Command: Remove a keymap"), 16, 0);
296+ prt(_("押すキー: ", "Keypress: "), 18, 0);
297+ do_cmd_macro_aux_keymap(buf);
298+ string_free(keymap_act[mode][(byte)(buf[0])]);
299+ keymap_act[mode][(byte)(buf[0])] = NULL;
300+ msg_print(_("キー配置を削除しました。", "Removed a keymap."));
301+ }
302+ else if (i == '0')
303+ {
304+ prt(_("コマンド: マクロ行動の入力", "Command: Enter a new action"), 16, 0);
305+ clear_from(20);
306+ c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
307+ "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
308+ prt(_("マクロ行動: ", "Action: "), 20, 0);
309+ tmp[80] = '\0';
310+ if (!askfor(buf, 80)) continue;
311+
312+ text_to_ascii(macro__buf, buf);
313+ }
314+ else
315+ {
316+ bell();
317+ }
318+
319+ msg_erase();
320+ }
321+
322+ screen_load();
323+}
--- /dev/null
+++ b/src/cmd/cmd-macro.h
@@ -0,0 +1,3 @@
1+#pragma once
2+
3+void do_cmd_macros(player_type *creature_ptr);
--- a/src/core.c
+++ b/src/core.c
@@ -31,6 +31,7 @@
3131 #include "cmd/cmd-item.h"
3232 #include "cmd/cmd-magiceat.h"
3333 #include "cmd/cmd-mane.h"
34+#include "cmd/cmd-macro.h"
3435 #include "cmd/cmd-quaff.h"
3536 #include "cmd/cmd-read.h"
3637 #include "cmd/cmd-save.h"
--- a/src/store.c
+++ b/src/store.c
@@ -21,6 +21,7 @@
2121 #include "cmd/cmd-dump.h"
2222 #include "cmd/cmd-help.h"
2323 #include "cmd/cmd-item.h"
24+#include "cmd/cmd-macro.h"
2425 #include "cmd/cmd-smith.h"
2526 #include "cmd/cmd-zapwand.h"
2627 #include "cmd/cmd-magiceat.h"
Show on old repository browser