OSDN Git Service

[Refactor] #40236 Separated cmd-macro.c/h from cmd-dump.c
authorHourier <hourier@users.sourceforge.jp>
Sun, 22 Mar 2020 05:28:05 +0000 (14:28 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 22 Mar 2020 05:28:05 +0000 (14:28 +0900)
Hengband_vcs2017/Hengband/Hengband.vcxproj
Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd/cmd-dump.c
src/cmd/cmd-dump.h
src/cmd/cmd-macro.c [new file with mode: 0644]
src/cmd/cmd-macro.h [new file with mode: 0644]
src/core.c
src/store.c

index 1ff995c..ecae13f 100644 (file)
     <ClCompile Include="..\..\src\cmd\cmd-help.c" />\r
     <ClCompile Include="..\..\src\cmd\cmd-hissatsu.c" />\r
     <ClCompile Include="..\..\src\cmd\cmd-item.c" />\r
+    <ClCompile Include="..\..\src\cmd\cmd-macro.c" />\r
     <ClCompile Include="..\..\src\cmd\cmd-magiceat.c" />\r
     <ClCompile Include="..\..\src\cmd\cmd-mane.c" />\r
     <ClCompile Include="..\..\src\cmd\cmd-pet.c" />\r
     <ClInclude Include="..\..\src\cmd\cmd-help.h" />\r
     <ClInclude Include="..\..\src\cmd\cmd-hissatsu.h" />\r
     <ClInclude Include="..\..\src\cmd\cmd-item.h" />\r
+    <ClInclude Include="..\..\src\cmd\cmd-macro.h" />\r
     <ClInclude Include="..\..\src\cmd\cmd-magiceat.h" />\r
     <ClInclude Include="..\..\src\cmd\cmd-mane.h" />\r
     <ClInclude Include="..\..\src\cmd\cmd-pet.h" />\r
index 95106bf..3b2abc9 100644 (file)
     <ClCompile Include="..\..\src\cmd\object-group-table.c">
       <Filter>cmd</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\cmd\cmd-macro.c">
+      <Filter>cmd</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\cmd\object-group-table.h">
       <Filter>cmd</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\cmd\cmd-macro.h">
+      <Filter>cmd</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 0746903..e5919bc 100644 (file)
@@ -141,6 +141,7 @@ hengband_SOURCES = \
        cmd/cmd-gameoption.c cmd/cmd-gameoption.h cmd/cmd-help.c cmd/cmd-help.h \
        cmd/cmd-hissatsu.c cmd/cmd-hissatsu.h cmd/cmd-item.c cmd/cmd-item.h \
        cmd/cmd-magiceat.c cmd/cmd-magiceat.h cmd/cmd-mane.c cmd/cmd-mane.h \
+       cmd/cmd-macro.c cmd/cmd-macro.h \
        cmd/cmd-pet.c cmd/cmd-pet.h cmd/cmd-quaff.c cmd/cmd-quaff.h \
        cmd/cmd-read.c cmd/cmd-read.h cmd/cmd-save.c cmd/cmd-save.h \
        cmd/cmd-smith.c cmd/cmd-smith.h cmd/cmd-spell.c cmd/cmd-spell.h \
index 9533263..8c25d09 100644 (file)
@@ -63,7 +63,6 @@
 #include "monster-status.h"
 #include "view-mainwindow.h"
 #include "dungeon-file.h"
-#include "io/read-pref-file.h"
 #include "io/interpret-pref-file.h"
 #include "files.h"
 #include "spells.h"
@@ -564,324 +563,6 @@ void do_cmd_reload_autopick(player_type *creature_ptr)
 
 
 /*!
- * @brief マクロ情報をprefファイルに保存する /
- * @param fname ファイル名
- * @return なし
- */
-static void macro_dump(concptr fname)
-{
-       static concptr mark = "Macro Dump";
-       char buf[1024];
-       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
-       FILE_TYPE(FILE_TYPE_TEXT);
-       if (!open_auto_dump(buf, mark)) return;
-
-       auto_dump_printf(_("\n# 自動マクロセーブ\n\n", "\n# Automatic macro dump\n\n"));
-       for (int i = 0; i < macro__num; i++)
-       {
-               ascii_to_text(buf, macro__act[i]);
-               auto_dump_printf("A:%s\n", buf);
-               ascii_to_text(buf, macro__pat[i]);
-               auto_dump_printf("P:%s\n", buf);
-               auto_dump_printf("\n");
-       }
-
-       close_auto_dump();
-}
-
-
-/*!
- * @brief マクロのトリガーキーを取得する /
- * Hack -- ask for a "trigger" (see below)
- * @param buf キー表記を保管するバッファ
- * @return なし
- * @details
- * <pre>
- * Note the complex use of the "inkey()" function from "util.c".
- *
- * Note that both "flush()" calls are extremely important.
- * </pre>
- */
-static void do_cmd_macro_aux(char *buf)
-{
-       flush();
-       inkey_base = TRUE;
-       char i = inkey();
-       int n = 0;
-       while (i)
-       {
-               buf[n++] = i;
-               inkey_base = TRUE;
-               inkey_scan = TRUE;
-               i = inkey();
-       }
-
-       buf[n] = '\0';
-       flush();
-       char tmp[1024];
-       ascii_to_text(tmp, buf);
-       Term_addstr(-1, TERM_WHITE, tmp);
-}
-
-
-/*!
- * @brief マクロのキー表記からアスキーコードを得てターミナルに表示する /
- * Hack -- ask for a keymap "trigger" (see below)
- * @param buf キー表記を取得するバッファ
- * @return なし
- * @details
- * <pre>
- * Note that both "flush()" calls are extremely important.  This may
- * no longer be true, since "util.c" is much simpler now.
- * </pre>
- */
-static void do_cmd_macro_aux_keymap(char *buf)
-{
-       char tmp[1024];
-       flush();
-       buf[0] = inkey();
-       buf[1] = '\0';
-       ascii_to_text(tmp, buf);
-       Term_addstr(-1, TERM_WHITE, tmp);
-       flush();
-}
-
-
-/*!
- * @brief キーマップをprefファイルにダンプする /
- * Hack -- append all keymaps to the given file
- * @param fname ファイルネーム
- * @return エラーコード
- * @details
- */
-static errr keymap_dump(concptr fname)
-{
-       static concptr mark = "Keymap Dump";
-       char key[1024];
-       char buf[1024];
-       BIT_FLAGS mode;
-       if (rogue_like_commands)
-       {
-               mode = KEYMAP_MODE_ROGUE;
-       }
-       else
-       {
-               mode = KEYMAP_MODE_ORIG;
-       }
-
-       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
-       FILE_TYPE(FILE_TYPE_TEXT);
-       if (!open_auto_dump(buf, mark)) return -1;
-
-       auto_dump_printf(_("\n# 自動キー配置セーブ\n\n", "\n# Automatic keymap dump\n\n"));
-       for (int i = 0; i < 256; i++)
-       {
-               concptr act;
-               act = keymap_act[mode][i];
-               if (!act) continue;
-
-               buf[0] = (char)i;
-               buf[1] = '\0';
-               ascii_to_text(key, buf);
-               ascii_to_text(buf, act);
-               auto_dump_printf("A:%s\n", buf);
-               auto_dump_printf("C:%d:%s\n", mode, key);
-       }
-
-       close_auto_dump();
-       return 0;
-}
-
-
-/*!
- * @brief マクロを設定するコマンドのメインルーチン /
- * Interact with "macros"
- * @return なし
- * @details
- * <pre>
- * Note that the macro "action" must be defined before the trigger.
- *
- * Could use some helpful instructions on this page.
- * </pre>
- */
-void do_cmd_macros(player_type *creature_ptr)
-{
-       char tmp[1024];
-       char buf[1024];
-       BIT_FLAGS mode = rogue_like_commands ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG;
-       FILE_TYPE(FILE_TYPE_TEXT);
-       screen_save();
-       while (TRUE)
-       {
-               Term_clear();
-               prt(_("[ マクロの設定 ]", "Interact with Macros"), 2, 0);
-               prt(_("マクロ行動が(もしあれば)下に表示されます:", "Current action (if any) shown below:"), 20, 0);
-               ascii_to_text(buf, macro__buf);
-               prt(buf, 22, 0);
-
-               prt(_("(1) ユーザー設定ファイルのロード", "(1) Load a user pref file"), 4, 5);
-               prt(_("(2) ファイルにマクロを追加", "(2) Append macros to a file"), 5, 5);
-               prt(_("(3) マクロの確認", "(3) Query a macro"), 6, 5);
-               prt(_("(4) マクロの作成", "(4) Create a macro"), 7, 5);
-               prt(_("(5) マクロの削除", "(5) Remove a macro"), 8, 5);
-               prt(_("(6) ファイルにキー配置を追加", "(6) Append keymaps to a file"), 9, 5);
-               prt(_("(7) キー配置の確認", "(7) Query a keymap"), 10, 5);
-               prt(_("(8) キー配置の作成", "(8) Create a keymap"), 11, 5);
-               prt(_("(9) キー配置の削除", "(9) Remove a keymap"), 12, 5);
-               prt(_("(0) マクロ行動の入力", "(0) Enter a new action"), 13, 5);
-
-               prt(_("コマンド: ", "Command: "), 16, 0);
-               int i = inkey();
-               if (i == ESCAPE) break;
-
-               else if (i == '1')
-               {
-                       prt(_("コマンド: ユーザー設定ファイルのロード", "Command: Load a user pref file"), 16, 0);
-                       prt(_("ファイル: ", "File: "), 18, 0);
-                       sprintf(tmp, "%s.prf", creature_ptr->base_name);
-                       if (!askfor(tmp, 80)) continue;
-
-                       errr err = process_pref_file(creature_ptr, tmp);
-                       if (-2 == err)
-                               msg_format(_("標準の設定ファイル'%s'を読み込みました。", "Loaded default '%s'."), tmp);
-                       else if (err)
-                               msg_format(_("'%s'の読み込みに失敗しました!", "Failed to load '%s'!"), tmp);
-                       else
-                               msg_format(_("'%s'を読み込みました。", "Loaded '%s'."), tmp);
-               }
-               else if (i == '2')
-               {
-                       prt(_("コマンド: マクロをファイルに追加する", "Command: Append macros to a file"), 16, 0);
-                       prt(_("ファイル: ", "File: "), 18, 0);
-                       sprintf(tmp, "%s.prf", creature_ptr->base_name);
-                       if (!askfor(tmp, 80)) continue;
-
-                       macro_dump(tmp);
-                       msg_print(_("マクロを追加しました。", "Appended macros."));
-               }
-               else if (i == '3')
-               {
-                       prt(_("コマンド: マクロの確認", "Command: Query a macro"), 16, 0);
-                       prt(_("トリガーキー: ", "Trigger: "), 18, 0);
-                       do_cmd_macro_aux(buf);
-                       int k = macro_find_exact(buf);
-                       if (k < 0)
-                       {
-                               msg_print(_("そのキーにはマクロは定義されていません。", "Found no macro."));
-                       }
-                       else
-                       {
-                               strcpy(macro__buf, macro__act[k]);
-                               ascii_to_text(buf, macro__buf);
-                               prt(buf, 22, 0);
-                               msg_print(_("マクロを確認しました。", "Found a macro."));
-                       }
-               }
-               else if (i == '4')
-               {
-                       prt(_("コマンド: マクロの作成", "Command: Create a macro"), 16, 0);
-                       prt(_("トリガーキー: ", "Trigger: "), 18, 0);
-                       do_cmd_macro_aux(buf);
-                       clear_from(20);
-                       c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
-                               "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
-                       prt(_("マクロ行動: ", "Action: "), 20, 0);
-                       ascii_to_text(tmp, macro__buf);
-                       if (askfor(tmp, 80))
-                       {
-                               text_to_ascii(macro__buf, tmp);
-                               macro_add(buf, macro__buf);
-                               msg_print(_("マクロを追加しました。", "Added a macro."));
-                       }
-               }
-               else if (i == '5')
-               {
-                       prt(_("コマンド: マクロの削除", "Command: Remove a macro"), 16, 0);
-                       prt(_("トリガーキー: ", "Trigger: "), 18, 0);
-                       do_cmd_macro_aux(buf);
-                       macro_add(buf, buf);
-                       msg_print(_("マクロを削除しました。", "Removed a macro."));
-               }
-               else if (i == '6')
-               {
-                       prt(_("コマンド: キー配置をファイルに追加する", "Command: Append keymaps to a file"), 16, 0);
-                       prt(_("ファイル: ", "File: "), 18, 0);
-                       sprintf(tmp, "%s.prf", creature_ptr->base_name);
-                       if (!askfor(tmp, 80)) continue;
-
-                       (void)keymap_dump(tmp);
-                       msg_print(_("キー配置を追加しました。", "Appended keymaps."));
-               }
-               else if (i == '7')
-               {
-                       prt(_("コマンド: キー配置の確認", "Command: Query a keymap"), 16, 0);
-                       prt(_("押すキー: ", "Keypress: "), 18, 0);
-                       do_cmd_macro_aux_keymap(buf);
-                       concptr act = keymap_act[mode][(byte)(buf[0])];
-                       if (!act)
-                       {
-                               msg_print(_("キー配置は定義されていません。", "Found no keymap."));
-                       }
-                       else
-                       {
-                               strcpy(macro__buf, act);
-                               ascii_to_text(buf, macro__buf);
-                               prt(buf, 22, 0);
-                               msg_print(_("キー配置を確認しました。", "Found a keymap."));
-                       }
-               }
-               else if (i == '8')
-               {
-                       prt(_("コマンド: キー配置の作成", "Command: Create a keymap"), 16, 0);
-                       prt(_("押すキー: ", "Keypress: "), 18, 0);
-                       do_cmd_macro_aux_keymap(buf);
-                       clear_from(20);
-                       c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
-                               "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
-                       prt(_("行動: ", "Action: "), 20, 0);
-                       ascii_to_text(tmp, macro__buf);
-                       if (askfor(tmp, 80))
-                       {
-                               text_to_ascii(macro__buf, tmp);
-                               string_free(keymap_act[mode][(byte)(buf[0])]);
-                               keymap_act[mode][(byte)(buf[0])] = string_make(macro__buf);
-                               msg_print(_("キー配置を追加しました。", "Added a keymap."));
-                       }
-               }
-               else if (i == '9')
-               {
-                       prt(_("コマンド: キー配置の削除", "Command: Remove a keymap"), 16, 0);
-                       prt(_("押すキー: ", "Keypress: "), 18, 0);
-                       do_cmd_macro_aux_keymap(buf);
-                       string_free(keymap_act[mode][(byte)(buf[0])]);
-                       keymap_act[mode][(byte)(buf[0])] = NULL;
-                       msg_print(_("キー配置を削除しました。", "Removed a keymap."));
-               }
-               else if (i == '0')
-               {
-                       prt(_("コマンド: マクロ行動の入力", "Command: Enter a new action"), 16, 0);
-                       clear_from(20);
-                       c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
-                               "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
-                       prt(_("マクロ行動: ", "Action: "), 20, 0);
-                       tmp[80] = '\0';
-                       if (!askfor(buf, 80)) continue;
-
-                       text_to_ascii(macro__buf, buf);
-               }
-               else
-               {
-                       bell();
-               }
-
-               msg_erase();
-       }
-
-       screen_load();
-}
-
-
-/*!
  * @brief キャラクタ色の明暗表現
  */
 static concptr lighting_level_str[F_LIT_MAX] =
index bfab450..76476cb 100644 (file)
@@ -11,7 +11,6 @@ extern void do_cmd_message_one(void);
 extern void do_cmd_messages(int num_now);
 extern void do_cmd_pref(player_type *creature_ptr);
 extern void do_cmd_reload_autopick(player_type *creature_ptr);
-extern void do_cmd_macros(player_type *creature_ptr);
 extern void do_cmd_visuals(player_type *creature_ptr);
 extern void do_cmd_colors(player_type *creature_ptr);
 extern void do_cmd_note(void);
diff --git a/src/cmd/cmd-macro.c b/src/cmd/cmd-macro.c
new file mode 100644 (file)
index 0000000..7bbbd83
--- /dev/null
@@ -0,0 +1,323 @@
+#include "angband.h"
+#include "cmd-macro.h"
+#include "cmd-gameoption.h"
+#include "files.h"
+#include "io/read-pref-file.h"
+#include "term.h"
+
+/*!
+ * @brief マクロ情報をprefファイルに保存する /
+ * @param fname ファイル名
+ * @return なし
+ */
+static void macro_dump(concptr fname)
+{
+       static concptr mark = "Macro Dump";
+       char buf[1024];
+       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
+       FILE_TYPE(FILE_TYPE_TEXT);
+       if (!open_auto_dump(buf, mark)) return;
+
+       auto_dump_printf(_("\n# 自動マクロセーブ\n\n", "\n# Automatic macro dump\n\n"));
+       for (int i = 0; i < macro__num; i++)
+       {
+               ascii_to_text(buf, macro__act[i]);
+               auto_dump_printf("A:%s\n", buf);
+               ascii_to_text(buf, macro__pat[i]);
+               auto_dump_printf("P:%s\n", buf);
+               auto_dump_printf("\n");
+       }
+
+       close_auto_dump();
+}
+
+
+/*!
+ * @brief マクロのトリガーキーを取得する /
+ * Hack -- ask for a "trigger" (see below)
+ * @param buf キー表記を保管するバッファ
+ * @return なし
+ * @details
+ * <pre>
+ * Note the complex use of the "inkey()" function from "util.c".
+ *
+ * Note that both "flush()" calls are extremely important.
+ * </pre>
+ */
+static void do_cmd_macro_aux(char *buf)
+{
+       flush();
+       inkey_base = TRUE;
+       char i = inkey();
+       int n = 0;
+       while (i)
+       {
+               buf[n++] = i;
+               inkey_base = TRUE;
+               inkey_scan = TRUE;
+               i = inkey();
+       }
+
+       buf[n] = '\0';
+       flush();
+       char tmp[1024];
+       ascii_to_text(tmp, buf);
+       Term_addstr(-1, TERM_WHITE, tmp);
+}
+
+
+/*!
+ * @brief マクロのキー表記からアスキーコードを得てターミナルに表示する /
+ * Hack -- ask for a keymap "trigger" (see below)
+ * @param buf キー表記を取得するバッファ
+ * @return なし
+ * @details
+ * <pre>
+ * Note that both "flush()" calls are extremely important.  This may
+ * no longer be true, since "util.c" is much simpler now.
+ * </pre>
+ */
+static void do_cmd_macro_aux_keymap(char *buf)
+{
+       char tmp[1024];
+       flush();
+       buf[0] = inkey();
+       buf[1] = '\0';
+       ascii_to_text(tmp, buf);
+       Term_addstr(-1, TERM_WHITE, tmp);
+       flush();
+}
+
+
+/*!
+ * @brief キーマップをprefファイルにダンプする /
+ * Hack -- append all keymaps to the given file
+ * @param fname ファイルネーム
+ * @return エラーコード
+ * @details
+ */
+static errr keymap_dump(concptr fname)
+{
+       static concptr mark = "Keymap Dump";
+       char key[1024];
+       char buf[1024];
+       BIT_FLAGS mode;
+       if (rogue_like_commands)
+       {
+               mode = KEYMAP_MODE_ROGUE;
+       }
+       else
+       {
+               mode = KEYMAP_MODE_ORIG;
+       }
+
+       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
+       FILE_TYPE(FILE_TYPE_TEXT);
+       if (!open_auto_dump(buf, mark)) return -1;
+
+       auto_dump_printf(_("\n# 自動キー配置セーブ\n\n", "\n# Automatic keymap dump\n\n"));
+       for (int i = 0; i < 256; i++)
+       {
+               concptr act;
+               act = keymap_act[mode][i];
+               if (!act) continue;
+
+               buf[0] = (char)i;
+               buf[1] = '\0';
+               ascii_to_text(key, buf);
+               ascii_to_text(buf, act);
+               auto_dump_printf("A:%s\n", buf);
+               auto_dump_printf("C:%d:%s\n", mode, key);
+       }
+
+       close_auto_dump();
+       return 0;
+}
+
+
+/*!
+ * @brief マクロを設定するコマンドのメインルーチン /
+ * Interact with "macros"
+ * @return なし
+ * @details
+ * <pre>
+ * Note that the macro "action" must be defined before the trigger.
+ *
+ * Could use some helpful instructions on this page.
+ * </pre>
+ */
+void do_cmd_macros(player_type *creature_ptr)
+{
+       char tmp[1024];
+       char buf[1024];
+       BIT_FLAGS mode = rogue_like_commands ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG;
+       FILE_TYPE(FILE_TYPE_TEXT);
+       screen_save();
+       while (TRUE)
+       {
+               Term_clear();
+               prt(_("[ マクロの設定 ]", "Interact with Macros"), 2, 0);
+               prt(_("マクロ行動が(もしあれば)下に表示されます:", "Current action (if any) shown below:"), 20, 0);
+               ascii_to_text(buf, macro__buf);
+               prt(buf, 22, 0);
+
+               prt(_("(1) ユーザー設定ファイルのロード", "(1) Load a user pref file"), 4, 5);
+               prt(_("(2) ファイルにマクロを追加", "(2) Append macros to a file"), 5, 5);
+               prt(_("(3) マクロの確認", "(3) Query a macro"), 6, 5);
+               prt(_("(4) マクロの作成", "(4) Create a macro"), 7, 5);
+               prt(_("(5) マクロの削除", "(5) Remove a macro"), 8, 5);
+               prt(_("(6) ファイルにキー配置を追加", "(6) Append keymaps to a file"), 9, 5);
+               prt(_("(7) キー配置の確認", "(7) Query a keymap"), 10, 5);
+               prt(_("(8) キー配置の作成", "(8) Create a keymap"), 11, 5);
+               prt(_("(9) キー配置の削除", "(9) Remove a keymap"), 12, 5);
+               prt(_("(0) マクロ行動の入力", "(0) Enter a new action"), 13, 5);
+
+               prt(_("コマンド: ", "Command: "), 16, 0);
+               int i = inkey();
+               if (i == ESCAPE) break;
+
+               else if (i == '1')
+               {
+                       prt(_("コマンド: ユーザー設定ファイルのロード", "Command: Load a user pref file"), 16, 0);
+                       prt(_("ファイル: ", "File: "), 18, 0);
+                       sprintf(tmp, "%s.prf", creature_ptr->base_name);
+                       if (!askfor(tmp, 80)) continue;
+
+                       errr err = process_pref_file(creature_ptr, tmp);
+                       if (-2 == err)
+                               msg_format(_("標準の設定ファイル'%s'を読み込みました。", "Loaded default '%s'."), tmp);
+                       else if (err)
+                               msg_format(_("'%s'の読み込みに失敗しました!", "Failed to load '%s'!"), tmp);
+                       else
+                               msg_format(_("'%s'を読み込みました。", "Loaded '%s'."), tmp);
+               }
+               else if (i == '2')
+               {
+                       prt(_("コマンド: マクロをファイルに追加する", "Command: Append macros to a file"), 16, 0);
+                       prt(_("ファイル: ", "File: "), 18, 0);
+                       sprintf(tmp, "%s.prf", creature_ptr->base_name);
+                       if (!askfor(tmp, 80)) continue;
+
+                       macro_dump(tmp);
+                       msg_print(_("マクロを追加しました。", "Appended macros."));
+               }
+               else if (i == '3')
+               {
+                       prt(_("コマンド: マクロの確認", "Command: Query a macro"), 16, 0);
+                       prt(_("トリガーキー: ", "Trigger: "), 18, 0);
+                       do_cmd_macro_aux(buf);
+                       int k = macro_find_exact(buf);
+                       if (k < 0)
+                       {
+                               msg_print(_("そのキーにはマクロは定義されていません。", "Found no macro."));
+                       }
+                       else
+                       {
+                               strcpy(macro__buf, macro__act[k]);
+                               ascii_to_text(buf, macro__buf);
+                               prt(buf, 22, 0);
+                               msg_print(_("マクロを確認しました。", "Found a macro."));
+                       }
+               }
+               else if (i == '4')
+               {
+                       prt(_("コマンド: マクロの作成", "Command: Create a macro"), 16, 0);
+                       prt(_("トリガーキー: ", "Trigger: "), 18, 0);
+                       do_cmd_macro_aux(buf);
+                       clear_from(20);
+                       c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
+                               "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
+                       prt(_("マクロ行動: ", "Action: "), 20, 0);
+                       ascii_to_text(tmp, macro__buf);
+                       if (askfor(tmp, 80))
+                       {
+                               text_to_ascii(macro__buf, tmp);
+                               macro_add(buf, macro__buf);
+                               msg_print(_("マクロを追加しました。", "Added a macro."));
+                       }
+               }
+               else if (i == '5')
+               {
+                       prt(_("コマンド: マクロの削除", "Command: Remove a macro"), 16, 0);
+                       prt(_("トリガーキー: ", "Trigger: "), 18, 0);
+                       do_cmd_macro_aux(buf);
+                       macro_add(buf, buf);
+                       msg_print(_("マクロを削除しました。", "Removed a macro."));
+               }
+               else if (i == '6')
+               {
+                       prt(_("コマンド: キー配置をファイルに追加する", "Command: Append keymaps to a file"), 16, 0);
+                       prt(_("ファイル: ", "File: "), 18, 0);
+                       sprintf(tmp, "%s.prf", creature_ptr->base_name);
+                       if (!askfor(tmp, 80)) continue;
+
+                       (void)keymap_dump(tmp);
+                       msg_print(_("キー配置を追加しました。", "Appended keymaps."));
+               }
+               else if (i == '7')
+               {
+                       prt(_("コマンド: キー配置の確認", "Command: Query a keymap"), 16, 0);
+                       prt(_("押すキー: ", "Keypress: "), 18, 0);
+                       do_cmd_macro_aux_keymap(buf);
+                       concptr act = keymap_act[mode][(byte)(buf[0])];
+                       if (!act)
+                       {
+                               msg_print(_("キー配置は定義されていません。", "Found no keymap."));
+                       }
+                       else
+                       {
+                               strcpy(macro__buf, act);
+                               ascii_to_text(buf, macro__buf);
+                               prt(buf, 22, 0);
+                               msg_print(_("キー配置を確認しました。", "Found a keymap."));
+                       }
+               }
+               else if (i == '8')
+               {
+                       prt(_("コマンド: キー配置の作成", "Command: Create a keymap"), 16, 0);
+                       prt(_("押すキー: ", "Keypress: "), 18, 0);
+                       do_cmd_macro_aux_keymap(buf);
+                       clear_from(20);
+                       c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
+                               "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
+                       prt(_("行動: ", "Action: "), 20, 0);
+                       ascii_to_text(tmp, macro__buf);
+                       if (askfor(tmp, 80))
+                       {
+                               text_to_ascii(macro__buf, tmp);
+                               string_free(keymap_act[mode][(byte)(buf[0])]);
+                               keymap_act[mode][(byte)(buf[0])] = string_make(macro__buf);
+                               msg_print(_("キー配置を追加しました。", "Added a keymap."));
+                       }
+               }
+               else if (i == '9')
+               {
+                       prt(_("コマンド: キー配置の削除", "Command: Remove a keymap"), 16, 0);
+                       prt(_("押すキー: ", "Keypress: "), 18, 0);
+                       do_cmd_macro_aux_keymap(buf);
+                       string_free(keymap_act[mode][(byte)(buf[0])]);
+                       keymap_act[mode][(byte)(buf[0])] = NULL;
+                       msg_print(_("キー配置を削除しました。", "Removed a keymap."));
+               }
+               else if (i == '0')
+               {
+                       prt(_("コマンド: マクロ行動の入力", "Command: Enter a new action"), 16, 0);
+                       clear_from(20);
+                       c_prt(TERM_L_RED, _("カーソルキーの左右でカーソル位置を移動。BackspaceかDeleteで一文字削除。",
+                               "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char."), 22, 0);
+                       prt(_("マクロ行動: ", "Action: "), 20, 0);
+                       tmp[80] = '\0';
+                       if (!askfor(buf, 80)) continue;
+
+                       text_to_ascii(macro__buf, buf);
+               }
+               else
+               {
+                       bell();
+               }
+
+               msg_erase();
+       }
+
+       screen_load();
+}
diff --git a/src/cmd/cmd-macro.h b/src/cmd/cmd-macro.h
new file mode 100644 (file)
index 0000000..4c415c6
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+void do_cmd_macros(player_type *creature_ptr);
index 66de01b..48e7804 100644 (file)
@@ -31,6 +31,7 @@
 #include "cmd/cmd-item.h"
 #include "cmd/cmd-magiceat.h"
 #include "cmd/cmd-mane.h"
+#include "cmd/cmd-macro.h"
 #include "cmd/cmd-quaff.h"
 #include "cmd/cmd-read.h"
 #include "cmd/cmd-save.h"
index 674d1bc..a085606 100644 (file)
@@ -21,6 +21,7 @@
 #include "cmd/cmd-dump.h"
 #include "cmd/cmd-help.h"
 #include "cmd/cmd-item.h"
+#include "cmd/cmd-macro.h"
 #include "cmd/cmd-smith.h"
 #include "cmd/cmd-zapwand.h"
 #include "cmd/cmd-magiceat.h"