<ItemGroup>\r
<ClCompile Include="..\..\src\artifact.c" />\r
<ClCompile Include="..\..\src\autopick\autopick-adder.c" />\r
+ <ClCompile Include="..\..\src\autopick\autopick-command-menu.c" />\r
<ClCompile Include="..\..\src\autopick\autopick-describer.c" />\r
<ClCompile Include="..\..\src\autopick\autopick-destroyer.c" />\r
<ClCompile Include="..\..\src\autopick\autopick-drawer.c" />\r
<ClCompile Include="..\..\src\realm-sorcery.c" />\r
<ClInclude Include="..\..\src\artifact.h" />\r
<ClInclude Include="..\..\src\autopick\autopick-adder.h" />\r
+ <ClInclude Include="..\..\src\autopick\autopick-command-menu.h" />\r
<ClInclude Include="..\..\src\autopick\autopick-commands-table.h" />\r
<ClInclude Include="..\..\src\autopick\autopick-describer.h" />\r
<ClInclude Include="..\..\src\autopick\autopick-destroyer.h" />\r
<ClCompile Include="..\..\src\autopick\autopick-registry.c">
<Filter>autopick</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\autopick\autopick-command-menu.c">
+ <Filter>autopick</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\gamevalue.h" />
<ClInclude Include="..\..\src\autopick\autopick-registry.h">
<Filter>autopick</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\autopick\autopick-command-menu.h">
+ <Filter>autopick</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\wall.bmp" />
autopick/autopick-searcher.c autopick/autopick-searcher.h \
autopick/autopick-inserter-killer.c autopick/autopick-inserter-killer.h \
autopick/autopick-registry.c autopick/autopick-registry.h \
+ autopick/autopick-command-menu.c autopick/autopick-command-menu.h \
\
avatar.h avatar.c birth.c birth.h \
\
--- /dev/null
+#include "angband.h"
+#include "autopick/autopick-command-menu.h"
+#include "autopick/autopick-util.h"
+#include "autopick/autopick-menu-data-table.h"
+#include "gameterm.h"
+
+/*
+ * Display the menu, and get a command
+ */
+int do_command_menu(int level, int start)
+{
+ int max_len = 0;
+ int col0 = 5 + level * 7;
+ int row0 = 1 + level * 3;
+ int menu_id_list[26];
+ bool redraw = TRUE;
+ char linestr[MAX_LINELEN];
+
+ byte menu_key = 0;
+ for (int i = start; menu_data[i].level >= level; i++)
+ {
+ /* Ignore lower level sub menus */
+ if (menu_data[i].level > level) continue;
+
+ int len = strlen(menu_data[i].name);
+ if (len > max_len) max_len = len;
+
+ menu_id_list[menu_key] = i;
+ menu_key++;
+ }
+
+ while (menu_key < 26)
+ {
+ menu_id_list[menu_key] = -1;
+ menu_key++;
+ }
+
+ int max_menu_wid = max_len + 3 + 3;
+
+ /* Prepare box line */
+ linestr[0] = '\0';
+ strcat(linestr, "+");
+ for (int i = 0; i < max_menu_wid + 2; i++)
+ {
+ strcat(linestr, "-");
+ }
+
+ strcat(linestr, "+");
+
+ while (TRUE)
+ {
+ if (redraw)
+ {
+ int row1 = row0 + 1;
+ Term_putstr(col0, row0, -1, TERM_WHITE, linestr);
+
+ menu_key = 0;
+ for (int i = start; menu_data[i].level >= level; i++)
+ {
+ char com_key_str[3];
+ concptr str;
+ if (menu_data[i].level > level) continue;
+
+ if (menu_data[i].com_id == -1)
+ {
+ strcpy(com_key_str, _("▼", ">"));
+ }
+ else if (menu_data[i].key != -1)
+ {
+ com_key_str[0] = '^';
+ com_key_str[1] = menu_data[i].key + '@';
+ com_key_str[2] = '\0';
+ }
+ else
+ {
+ com_key_str[0] = '\0';
+ }
+
+ str = format("| %c) %-*s %2s | ", menu_key + 'a', max_len, menu_data[i].name, com_key_str);
+
+ Term_putstr(col0, row1++, -1, TERM_WHITE, str);
+
+ menu_key++;
+ }
+
+ Term_putstr(col0, row1, -1, TERM_WHITE, linestr);
+ redraw = FALSE;
+ }
+
+ prt(format(_("(a-%c) コマンド:", "(a-%c) Command:"), menu_key + 'a' - 1), 0, 0);
+ char key = inkey();
+
+ if (key == ESCAPE) return 0;
+
+ int com_id;
+ bool is_alphabet = key >= 'a' && key <= 'z';
+ if (!is_alphabet)
+ {
+ com_id = get_com_id(key);
+ if (com_id)
+ {
+ return com_id;
+ }
+
+ continue;
+ }
+
+ int menu_id = menu_id_list[key - 'a'];
+
+ if (menu_id < 0) continue;
+
+ com_id = menu_data[menu_id].com_id;
+
+ if (com_id == -1)
+ {
+ com_id = do_command_menu(level + 1, menu_id + 1);
+
+ if (com_id) return com_id;
+ else redraw = TRUE;
+ }
+ else if (com_id)
+ {
+ return com_id;
+ }
+ }
+}
--- /dev/null
+#pragma once
+
+int do_command_menu(int level, int start);
#include "autopick/autopick-searcher.h"
#include "autopick/autopick-inserter-killer.h"
#include "autopick/autopick-registry.h"
+#include "autopick/autopick-command-menu.h"
#include "gameterm.h"
#include "autopick/autopick.h"
#include "core/show-file.h"
}
-/*
- * Display the menu, and get a command
- */
-static int do_command_menu(int level, int start)
-{
- int max_len = 0;
- int col0 = 5 + level * 7;
- int row0 = 1 + level * 3;
- int menu_id_list[26];
- bool redraw = TRUE;
- char linestr[MAX_LINELEN];
-
- byte menu_key = 0;
- for (int i = start; menu_data[i].level >= level; i++)
- {
- /* Ignore lower level sub menus */
- if (menu_data[i].level > level) continue;
-
- int len = strlen(menu_data[i].name);
- if (len > max_len) max_len = len;
-
- menu_id_list[menu_key] = i;
- menu_key++;
- }
-
- while (menu_key < 26)
- {
- menu_id_list[menu_key] = -1;
- menu_key++;
- }
-
- int max_menu_wid = max_len + 3 + 3;
-
- /* Prepare box line */
- linestr[0] = '\0';
- strcat(linestr, "+");
- for (int i = 0; i < max_menu_wid + 2; i++)
- {
- strcat(linestr, "-");
- }
-
- strcat(linestr, "+");
-
- while (TRUE)
- {
- if (redraw)
- {
- int row1 = row0 + 1;
- Term_putstr(col0, row0, -1, TERM_WHITE, linestr);
-
- menu_key = 0;
- for (int i = start; menu_data[i].level >= level; i++)
- {
- char com_key_str[3];
- concptr str;
- if (menu_data[i].level > level) continue;
-
- if (menu_data[i].com_id == -1)
- {
- strcpy(com_key_str, _("▼", ">"));
- }
- else if (menu_data[i].key != -1)
- {
- com_key_str[0] = '^';
- com_key_str[1] = menu_data[i].key + '@';
- com_key_str[2] = '\0';
- }
- else
- {
- com_key_str[0] = '\0';
- }
-
- str = format("| %c) %-*s %2s | ", menu_key + 'a', max_len, menu_data[i].name, com_key_str);
-
- Term_putstr(col0, row1++, -1, TERM_WHITE, str);
-
- menu_key++;
- }
-
- Term_putstr(col0, row1, -1, TERM_WHITE, linestr);
- redraw = FALSE;
- }
-
- prt(format(_("(a-%c) コマンド:", "(a-%c) Command:"), menu_key + 'a' - 1), 0, 0);
- char key = inkey();
-
- if (key == ESCAPE) return 0;
-
- int com_id;
- bool is_alphabet = key >= 'a' && key <= 'z';
- if (!is_alphabet)
- {
- com_id = get_com_id(key);
- if (com_id)
- {
- return com_id;
- }
-
- continue;
- }
-
- int menu_id = menu_id_list[key - 'a'];
-
- if (menu_id < 0) continue;
-
- com_id = menu_data[menu_id].com_id;
-
- if (com_id == -1)
- {
- com_id = do_command_menu(level + 1, menu_id + 1);
-
- if (com_id) return com_id;
- else redraw = TRUE;
- }
- else if (com_id)
- {
- return com_id;
- }
- }
-}
-
-
static chain_str_type *new_chain_str(concptr str)
{
chain_str_type *chain;