OSDN Git Service

[Refactor] #40413 Separated asking-player.c/h from util.c/h
authorHourier <hourier@users.sourceforge.jp>
Sun, 14 Jun 2020 05:54:24 +0000 (14:54 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 14 Jun 2020 05:54:24 +0000 (14:54 +0900)
81 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/autopick/autopick-editor-command.c
src/autopick/autopick-registry.c
src/autopick/autopick.c
src/birth/birth-select-realm.c
src/birth/birth-wizard.c
src/cmd-action/cmd-attack.c
src/cmd-action/cmd-hissatsu.c
src/cmd-action/cmd-mane.c
src/cmd-action/cmd-pet.c
src/cmd-action/cmd-spell.c
src/cmd-building/cmd-building.c
src/cmd-io/cmd-diary.c
src/cmd-io/cmd-dump.c
src/cmd-io/cmd-lore.c
src/cmd-io/cmd-macro.c
src/cmd-io/cmd-process-screen.c
src/cmd-item/cmd-activate.c
src/cmd-item/cmd-item.c
src/cmd-item/cmd-magiceat.c
src/cmd-item/cmd-smith.c
src/cmd/cmd-basic.c
src/cmd/cmd-draw.c
src/cmd/cmd-visuals.c
src/core/asking-player.c [new file with mode: 0644]
src/core/asking-player.h [new file with mode: 0644]
src/core/game-closer.c
src/core/game-play.c
src/core/scores.c
src/core/show-file.c
src/dungeon/quest.c
src/floor/floor-save.c
src/floor/pattern-walk.c
src/floor/wild.c
src/inventory/inventory-curse.c
src/inventory/player-inventory.c
src/io/chuukei.c
src/io/files-util.c
src/io/input-key-processor.c
src/io/read-pref-file.c
src/io/report.c
src/io/targeting.c
src/knowledge/knowledge-autopick.c
src/market/arena.c
src/market/bounty.c
src/market/building-craft-fix.c
src/market/building-monster.c
src/market/building-recharger.c
src/market/play-gamble.c
src/mind/mind-sniper.c
src/mind/mind.c
src/mind/racial.c
src/mspell/mspells3.c
src/mutation/mutation.c
src/object-enchant/artifact.c
src/object/warning.c
src/player/player-damage.c
src/player/player-move.c
src/player/player-status.c
src/player/process-death.c
src/player/process-name.c
src/realm/realm-arcane.c
src/realm/realm-chaos.c
src/realm/realm-hex.c
src/realm/realm-hissatsu.c
src/realm/realm-sorcery.c
src/realm/realm-trump.c
src/spell-kind/spells-genocide.c
src/spell-kind/spells-pet.c
src/spell-kind/spells-teleport.c
src/spell-kind/spells-world.c
src/spell-kind/spells-world.h
src/spell-realm/spells-hex.c
src/spell/spells-object.c
src/spell/spells3.c
src/store/store.c
src/util/util.c
src/util/util.h
src/wizard/wizard-special-process.c

index 6af277f..97876d6 100644 (file)
     <ClCompile Include="..\..\src\cmd-io\cmd-lore.c" />\r
     <ClCompile Include="..\..\src\cmd-io\cmd-menu-content-table.c" />\r
     <ClCompile Include="..\..\src\cmd-io\macro-util.c" />\r
+    <ClCompile Include="..\..\src\core\asking-player.c" />\r
     <ClCompile Include="..\..\src\core\visuals-reseter.c" />\r
     <ClCompile Include="..\..\src\floor\fixed-map-generator.c" />\r
     <ClCompile Include="..\..\src\game-option\auto-destruction-options.c" />\r
     <ClInclude Include="..\..\src\cmd-io\cmd-lore.h" />\r
     <ClInclude Include="..\..\src\cmd-io\cmd-menu-content-table.h" />\r
     <ClInclude Include="..\..\src\cmd-io\macro-util.h" />\r
+    <ClInclude Include="..\..\src\core\asking-player.h" />\r
     <ClInclude Include="..\..\src\core\visuals-reseter.h" />\r
     <ClInclude Include="..\..\src\floor\fixed-map-generator.h" />\r
     <ClInclude Include="..\..\src\game-option\auto-destruction-options.h" />\r
index 603c562..b1742d6 100644 (file)
     <ClCompile Include="..\..\src\view\display-messages.c">
       <Filter>view</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\core\asking-player.c">
+      <Filter>core</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\locale\english.h">
       <Filter>locale</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\core\asking-player.h">
+      <Filter>core</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 0b68ad3..4080e07 100644 (file)
@@ -104,20 +104,21 @@ hengband_SOURCES = \
        combat/vorpal-weapon.c combat/vorpal-weapon.h \
        combat/shoot.c combat/shoot.h \
        \
-       core/game-play.c core/game-play.h \
-       core/show-file.c core/show-file.h \
-       core/stuff-handler.c core/stuff-handler.h \
-       core/special-internal-keys.h \
-       core/output-updater.c core/output-updater.h \
+       core/asking-player.c core/asking-player.h \
        core/game-closer.c core/game-closer.h \
-       core/turn-compensator.c core/turn-compensator.h \
-       core/hp-mp-regenerator.c core/hp-mp-regenerator.h \
+       core/game-play.c core/game-play.h \
        core/hp-mp-processor.c core/hp-mp-processor.h \
+       core/hp-mp-regenerator.c core/hp-mp-regenerator.h \
        core/magic-effects-timeout-reducer.c core/magic-effects-timeout-reducer.h \
+       core/output-updater.c core/output-updater.h \
        core/player-processor.c core/player-processor.h \
        core/scores.c core/scores.h \
+       core/show-file.c core/show-file.h \
        core/sort.c core/sort.h \
+       core/special-internal-keys.h \
        core/speed-table.c core/speed-table.h \
+       core/stuff-handler.c core/stuff-handler.h \
+       core/turn-compensator.c core/turn-compensator.h \
        core/visuals-reseter.c core/visuals-reseter.h \
        \
        dungeon/dungeon.c dungeon/dungeon.h \
index 8befd27..f221cda 100644 (file)
@@ -16,6 +16,7 @@
 #include "autopick/autopick-inserter-killer.h"
 #include "autopick/autopick-methods-table.h"
 #include "autopick/autopick-reader-writer.h"
+#include "core/asking-player.h"
 #include "core/show-file.h"
 #include "game-option/input-options.h"
 #include "term/term-color-types.h"
index f5a285f..c86274e 100644 (file)
@@ -9,6 +9,7 @@
 #include "autopick/autopick-finder.h"
 #include "autopick/autopick-methods-table.h"
 #include "autopick/autopick-reader-writer.h"
+#include "core/asking-player.h"
 #include "io/files-util.h"
 #include "object-enchant/item-feeling.h"
 #include "perception/object-perception.h"
index 57a97ac..e52b61f 100644 (file)
@@ -16,6 +16,7 @@
 #include "autopick/autopick-finder.h"
 #include "autopick/autopick-menu-data-table.h"
 #include "autopick/autopick-methods-table.h"
+#include "core/asking-player.h"
 #include "floor/floor.h"
 #include "floor/floor-object.h"
 #include "inventory/inventory-object.h"
index 4295be9..a10a263 100644 (file)
@@ -1,6 +1,7 @@
 #include "birth/birth-select-realm.h"
 #include "birth/birth-explanations-table.h"
 #include "birth/birth-util.h"
+#include "core/asking-player.h"
 #include "io/input-key-acceptor.h"
 #include "term/term-color-types.h"
 
index 25669ee..f3d85fe 100644 (file)
@@ -14,6 +14,7 @@
 #include "birth/quick-start.h"
 #include "cmd-io/cmd-gameoption.h"
 #include "cmd-io/cmd-help.h"
+#include "core/asking-player.h"
 #include "game-option/birth-options.h"
 #include "io/input-key-acceptor.h"
 #include "main/sound-definitions-table.h"
index 161faa2..00f8f5a 100644 (file)
@@ -8,7 +8,7 @@
 #include "art-definition/art-sword-types.h"
 #include "combat/attack-accuracy.h"
 #include "combat/attack-criticality.h"
-#include "player-attack/player-attack.h"
+#include "core/asking-player.h"
 #include "dungeon/dungeon.h"
 #include "effect/effect-characteristics.h"
 #include "main/sound-definitions-table.h"
 #include "monster-race/race-flags2.h"
 #include "monster-race/race-flags3.h"
 #include "monster/monster-describer.h"
-#include "monster/monster-status.h"
 #include "monster/monster-info.h"
+#include "monster/monster-status.h"
 #include "object/item-use-flags.h"
+#include "player-attack/player-attack.h"
 #include "player/avatar.h"
 #include "player/player-damage.h"
 #include "player/player-effects.h"
@@ -217,8 +218,7 @@ bool do_cmd_attack(player_type *attacker_ptr, POSITION y, POSITION x, combat_opt
         return FALSE;
     }
 
-    if (monster_csleep_remaining(m_ptr))
-    {
+    if (monster_csleep_remaining(m_ptr)) {
         if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5))
             chg_virtue(attacker_ptr, V_COMPASSION, -1);
         if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5))
index a3aa697..0a35da2 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "cmd-action/cmd-spell.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "game-option/disturbance-options.h"
 #include "game-option/text-display-options.h"
index e2be245..1747e40 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "cmd-action/cmd-spell.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "floor/floor.h"
 #include "game-option/disturbance-options.h"
index b232d26..9375e7d 100644 (file)
@@ -2,6 +2,7 @@
 #include "cmd-action/cmd-attack.h"
 #include "cmd-io/cmd-dump.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/sort.h"
 #include "core/stuff-handler.h"
 #include "effect/spells-effect-util.h"
index 229b7c1..1582fab 100644 (file)
@@ -9,6 +9,7 @@
 #include "autopick/autopick-reader-writer.h"
 #include "cmd-io/cmd-dump.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "floor/floor.h"
 #include "game-option/disturbance-options.h"
index 69c1aab..b302d68 100644 (file)
@@ -16,6 +16,7 @@
 #include "cmd-action/cmd-spell.h"
 #include "cmd-io/cmd-dump.h"
 #include "cmd-building/cmd-inn.h"
+#include "core/asking-player.h"
 #include "core/scores.h"
 #include "core/show-file.h"
 #include "core/special-internal-keys.h"
index 6f55f79..4a14b0f 100644 (file)
@@ -1,5 +1,6 @@
 #include "cmd-io/cmd-diary.h"
 #include "cmd-io/diary-subtitle-table.h"
+#include "core/asking-player.h"
 #include "core/show-file.h"
 #include "game-option/play-record-options.h"
 #include "main/sound-of-music.h"
index 8bba653..58c4d2f 100644 (file)
@@ -1,38 +1,18 @@
 /*!
- * @file cmd-dump.c
  * @brief プレイヤーのインターフェイスに関するコマンドの実装 / Interface commands
  * @date 2014/01/02
  * @author
- * <pre>
  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
  * This software may be copied and distributed for educational, research,
  * and not for profit purposes provided that this copyright and statement
  * are included in all such copies.  Other copyrights may also apply.
- * </pre>
- * @details
- * <pre>
- * A set of functions to maintain automatic dumps of various kinds.
- * The dump commands of original Angband simply add new lines to
- * existing files; these files will become bigger and bigger unless
- * an user deletes some or all of these files by hand at some
- * point.
- * These three functions automatically delete old dumped lines
- * before adding new ones.  Since there are various kinds of automatic
- * dumps in a single file, we add a header and a footer with a type
- * name for every automatic dump, and kill old lines only when the
- * lines have the correct type of header and footer.
- * We need to be quite paranoid about correctness; the user might
- * (mistakenly) edit the file by hand, and see all their work come
- * to nothing on the next auto dump otherwise.  The current code only
- * detects changes by noting inconsistencies between the actual number
- * of lines and the number written in the footer.  Note that this will
- * not catch single-line edits.
- * </pre>
+ * 2020 Hourier Rearranged
  */
 
 #include "cmd-io/cmd-dump.h"
 #include "art-definition/art-bow-types.h"
 #include "cmd-io/feeling-table.h"
+#include "core/asking-player.h"
 #include "dungeon/quest.h"
 #include "floor/floor-town.h"
 #include "floor/floor.h"
index 7ea1324..d103b11 100644 (file)
@@ -1,4 +1,5 @@
 #include "cmd-io/cmd-lore.h"
+#include "core/asking-player.h"
 #include "core/sort.h"
 #include "core/stuff-handler.h"
 #include "game-option/game-play-options.h"
index 1d5a988..4ee2564 100644 (file)
@@ -1,6 +1,7 @@
 #include "cmd-io/cmd-macro.h"
 #include "cmd-io/cmd-gameoption.h"
 #include "cmd-io/macro-util.h"
+#include "core/asking-player.h"
 #include "game-option/input-options.h"
 #include "io/files-util.h"
 #include "io/input-key-acceptor.h"
index 2cf2d06..d6900af 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "cmd-io/cmd-process-screen.h"
 #include "cmd/cmd-draw.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "core/visuals-reseter.h"
 #include "game-option/special-options.h"
index 7c8fc81..0e27247 100644 (file)
@@ -11,6 +11,7 @@
 #include "art-definition/random-art-effects.h"
 #include "cmd-io/cmd-save.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/sort.h"
 #include "effect/effect-characteristics.h"
 #include "effect/spells-effect-util.h"
index 8acb491..e8d8517 100644 (file)
@@ -22,6 +22,7 @@
 #include "cmd-item/cmd-zaprod.h"
 #include "cmd-item/cmd-zapwand.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "dungeon/quest.h"
 #include "floor/floor-object.h"
index 502d922..9e8ddb0 100644 (file)
@@ -56,6 +56,7 @@
 #include "cmd-item/cmd-zaprod.h"
 #include "cmd-item/cmd-zapwand.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "game-option/disturbance-options.h"
 #include "game-option/text-display-options.h"
 #include "io/input-key-acceptor.h"
index 355aede..2fd104c 100644 (file)
@@ -7,6 +7,7 @@
 #include "cmd-item/cmd-smith.h"
 #include "autopick/autopick.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "game-option/text-display-options.h"
 #include "inventory/player-inventory.h"
 #include "io/input-key-acceptor.h"
index e57e0dd..ef34fdb 100644 (file)
@@ -18,6 +18,7 @@
 #include "combat/attack-power-table.h"
 #include "combat/shoot.h"
 #include "combat/slaying.h"
+#include "core/asking-player.h"
 #include "core/output-updater.h"
 #include "core/stuff-handler.h"
 #include "dungeon/dungeon.h"
index cf3942f..13a3266 100644 (file)
@@ -1,4 +1,5 @@
 #include "cmd/cmd-draw.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "io/files-util.h"
 #include "io/input-key-acceptor.h"
index 58908f9..14f9c83 100644 (file)
@@ -1,5 +1,6 @@
 #include "cmd/cmd-visuals.h"
 #include "cmd/cmd-draw.h"
+#include "core/asking-player.h"
 #include "core/visuals-reseter.h"
 #include "game-option/special-options.h"
 #include "io/files-util.h"
diff --git a/src/core/asking-player.c b/src/core/asking-player.c
new file mode 100644 (file)
index 0000000..7650ba6
--- /dev/null
@@ -0,0 +1,403 @@
+#include "core/asking-player.h"
+#include "core/stuff-handler.h"
+#include "game-option/input-options.h"
+#include "io/input-key-acceptor.h"
+#include "main/sound-of-music.h"
+#include "term/term-color-types.h"
+#include "view/display-messages.h"
+
+/*
+ * Get some string input at the cursor location.
+ * Assume the buffer is initialized to a default string.
+ *
+ * The default buffer is in Overwrite mode and displayed in yellow at
+ * first.  Normal chars clear the yellow text and append the char in
+ * white text.
+ *
+ * LEFT (^B) and RIGHT (^F) movement keys move the cursor position.
+ * If the text is still displayed in yellow (Overwite mode), it will
+ * turns into white (Insert mode) when cursor moves.
+ *
+ * DELETE (^D) deletes a char at the cursor position.
+ * BACKSPACE (^H) deletes a char at the left of cursor position.
+ * ESCAPE clears the buffer and the window and returns FALSE.
+ * RETURN accepts the current buffer contents and returns TRUE.
+ */
+bool askfor_aux(char *buf, int len, bool numpad_cursor)
+{
+    /*
+     * Text color
+     * TERM_YELLOW : Overwrite mode
+     * TERM_WHITE : Insert mode
+     */
+    byte color = TERM_YELLOW;
+
+    int y, x;
+    Term_locate(&x, &y);
+    if (len < 1)
+        len = 1;
+    if ((x < 0) || (x >= 80))
+        x = 0;
+    if (x + len > 80)
+        len = 80 - x;
+
+    buf[len] = '\0';
+
+    int pos = 0;
+    while (TRUE) {
+        Term_erase(x, y, len);
+        Term_putstr(x, y, -1, color, buf);
+
+        Term_gotoxy(x + pos, y);
+        int skey = inkey_special(numpad_cursor);
+
+        switch (skey) {
+        case SKEY_LEFT:
+        case KTRL('b'): {
+            int i = 0;
+            color = TERM_WHITE;
+
+            if (0 == pos)
+                break;
+            while (TRUE) {
+                int next_pos = i + 1;
+#ifdef JP
+                if (iskanji(buf[i]))
+                    next_pos++;
+#endif
+                if (next_pos >= pos)
+                    break;
+
+                i = next_pos;
+            }
+
+            pos = i;
+            break;
+        }
+
+        case SKEY_RIGHT:
+        case KTRL('f'):
+            color = TERM_WHITE;
+            if ('\0' == buf[pos])
+                break;
+
+#ifdef JP
+            if (iskanji(buf[pos]))
+                pos += 2;
+            else
+                pos++;
+#else
+            pos++;
+#endif
+            break;
+
+        case ESCAPE:
+            buf[0] = '\0';
+            return FALSE;
+
+        case '\n':
+        case '\r':
+            return TRUE;
+
+        case '\010': {
+            int i = 0;
+            color = TERM_WHITE;
+            if (0 == pos)
+                break;
+            while (TRUE) {
+                int next_pos = i + 1;
+#ifdef JP
+                if (iskanji(buf[i]))
+                    next_pos++;
+#endif
+                if (next_pos >= pos)
+                    break;
+
+                i = next_pos;
+            }
+
+            pos = i;
+        }
+            /* Fall through */
+
+        case 0x7F:
+        case KTRL('d'): {
+            color = TERM_WHITE;
+            if ('\0' == buf[pos])
+                break;
+            int src = pos + 1;
+#ifdef JP
+            if (iskanji(buf[pos]))
+                src++;
+#endif
+
+            int dst = pos;
+            while ('\0' != (buf[dst++] = buf[src++]))
+                ;
+            break;
+        }
+
+        default: {
+            char tmp[100];
+            if (skey & SKEY_MASK)
+                break;
+            char c = (char)skey;
+
+            if (color == TERM_YELLOW) {
+                buf[0] = '\0';
+                color = TERM_WHITE;
+            }
+
+            strcpy(tmp, buf + pos);
+#ifdef JP
+            if (iskanji(c)) {
+                inkey_base = TRUE;
+                char next = inkey();
+                if (pos + 1 < len) {
+                    buf[pos++] = c;
+                    buf[pos++] = next;
+                } else {
+                    bell();
+                }
+            } else
+#endif
+            {
+#ifdef JP
+                if (pos < len && (isprint(c) || iskana(c)))
+#else
+                if (pos < len && isprint(c))
+#endif
+                {
+                    buf[pos++] = c;
+                } else {
+                    bell();
+                }
+            }
+
+            buf[pos] = '\0';
+            angband_strcat(buf, tmp, len + 1);
+
+            break;
+        }
+        }
+    }
+}
+
+/*
+ * Get some string input at the cursor location.
+ *
+ * Allow to use numpad keys as cursor keys.
+ */
+bool askfor(char *buf, int len) { return askfor_aux(buf, len, TRUE); }
+
+/*
+ * Get a string from the user
+ *
+ * The "prompt" should take the form "Prompt: "
+ *
+ * Note that the initial contents of the string is used as
+ * the default response, so be sure to "clear" it if needed.
+ *
+ * We clear the input, and return FALSE, on "ESCAPE".
+ */
+bool get_string(concptr prompt, char *buf, int len)
+{
+    bool res;
+    msg_print(NULL);
+    prt(prompt, 0, 0);
+    res = askfor(buf, len);
+    prt("", 0, 0);
+    return (res);
+}
+
+/*
+ * Verify something with the user
+ *
+ * The "prompt" should take the form "Query? "
+ *
+ * Note that "[y/n]" is appended to the prompt.
+ */
+bool get_check(concptr prompt) { return get_check_strict(p_ptr, prompt, 0); }
+
+/*
+ * Verify something with the user strictly
+ *
+ * mode & CHECK_OKAY_CANCEL : force user to answer 'O'kay or 'C'ancel
+ * mode & CHECK_NO_ESCAPE   : don't allow ESCAPE key
+ * mode & CHECK_NO_HISTORY  : no message_add
+ * mode & CHECK_DEFAULT_Y   : accept any key as y, except n and Esc.
+ */
+bool get_check_strict(player_type *player_ptr, concptr prompt, BIT_FLAGS mode)
+{
+    char buf[80];
+    if (auto_more) {
+        player_ptr->window |= PW_MESSAGE;
+        handle_stuff(player_ptr);
+        num_more = 0;
+    }
+
+    msg_print(NULL);
+    if (!rogue_like_commands)
+        mode &= ~CHECK_OKAY_CANCEL;
+
+    if (mode & CHECK_OKAY_CANCEL) {
+        angband_strcpy(buf, prompt, sizeof(buf) - 15);
+        strcat(buf, "[(O)k/(C)ancel]");
+    } else if (mode & CHECK_DEFAULT_Y) {
+        angband_strcpy(buf, prompt, sizeof(buf) - 5);
+        strcat(buf, "[Y/n]");
+    } else {
+        angband_strcpy(buf, prompt, sizeof(buf) - 5);
+        strcat(buf, "[y/n]");
+    }
+
+    prt(buf, 0, 0);
+    if (!(mode & CHECK_NO_HISTORY) && player_ptr->playing) {
+        message_add(buf);
+        player_ptr->window |= (PW_MESSAGE);
+        handle_stuff(player_ptr);
+    }
+
+    bool flag = FALSE;
+    while (TRUE) {
+        int i = inkey();
+
+        if (!(mode & CHECK_NO_ESCAPE)) {
+            if (i == ESCAPE) {
+                flag = FALSE;
+                break;
+            }
+        }
+
+        if (mode & CHECK_OKAY_CANCEL) {
+            if (i == 'o' || i == 'O') {
+                flag = TRUE;
+                break;
+            } else if (i == 'c' || i == 'C') {
+                flag = FALSE;
+                break;
+            }
+        } else {
+            if (i == 'y' || i == 'Y') {
+                flag = TRUE;
+                break;
+            } else if (i == 'n' || i == 'N') {
+                flag = FALSE;
+                break;
+            }
+        }
+
+        if (mode & CHECK_DEFAULT_Y) {
+            flag = TRUE;
+            break;
+        }
+
+        bell();
+    }
+
+    prt("", 0, 0);
+    return flag;
+}
+
+/*
+ * Prompts for a keypress
+ *
+ * The "prompt" should take the form "Command: "
+ *
+ * Returns TRUE unless the character is "Escape"
+ */
+bool get_com(concptr prompt, char *command, bool z_escape)
+{
+    msg_print(NULL);
+    prt(prompt, 0, 0);
+    if (get_com_no_macros)
+        *command = (char)inkey_special(FALSE);
+    else
+        *command = inkey();
+
+    prt("", 0, 0);
+    if (*command == ESCAPE)
+        return FALSE;
+    if (z_escape && ((*command == 'z') || (*command == 'Z')))
+        return FALSE;
+
+    return TRUE;
+}
+
+/*
+ * Request a "quantity" from the user
+ *
+ * Hack -- allow "command_arg" to specify a quantity
+ */
+QUANTITY get_quantity(concptr prompt, QUANTITY max)
+{
+    bool res;
+    char tmp[80];
+    char buf[80];
+
+    QUANTITY amt;
+    if (command_arg) {
+        amt = command_arg;
+        command_arg = 0;
+        if (amt > max)
+            amt = max;
+
+        return (amt);
+    }
+
+    COMMAND_CODE code;
+    bool result = repeat_pull(&code);
+    amt = (QUANTITY)code;
+    if ((max != 1) && result) {
+        if (amt > max)
+            amt = max;
+        if (amt < 0)
+            amt = 0;
+
+        return (amt);
+    }
+
+    if (!prompt) {
+        sprintf(tmp, _("いくつですか (1-%d): ", "Quantity (1-%d): "), max);
+        prompt = tmp;
+    }
+
+    msg_print(NULL);
+    prt(prompt, 0, 0);
+    amt = 1;
+    sprintf(buf, "%d", amt);
+
+    /*
+     * Ask for a quantity
+     * Don't allow to use numpad as cursor key.
+     */
+    res = askfor_aux(buf, 6, FALSE);
+
+    prt("", 0, 0);
+    if (!res)
+        return 0;
+
+    amt = (COMMAND_CODE)atoi(buf);
+    if (isalpha(buf[0]))
+        amt = max;
+    if (amt > max)
+        amt = max;
+    if (amt < 0)
+        amt = 0;
+    if (amt)
+        repeat_push((COMMAND_CODE)amt);
+
+    return (amt);
+}
+
+/*
+ * Pause for user response
+ */
+void pause_line(int row)
+{
+    prt("", row, 0);
+    put_str(_("[ 何かキーを押して下さい ]", "[Press any key to continue]"), row, _(26, 23));
+
+    (void)inkey();
+    prt("", row, 0);
+}
diff --git a/src/core/asking-player.h b/src/core/asking-player.h
new file mode 100644 (file)
index 0000000..535522d
--- /dev/null
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "system/angband.h"
+
+/*
+ * Bit flags for control of get_check_strict()
+ */
+#define CHECK_OKAY_CANCEL 0x01
+#define CHECK_NO_ESCAPE 0x02
+#define CHECK_NO_HISTORY 0x04
+#define CHECK_DEFAULT_Y 0x08
+
+bool askfor_aux(char *buf, int len, bool numpad_cursor);
+bool askfor(char *buf, int len);
+bool get_string(concptr prompt, char *buf, int len);
+bool get_check(concptr prompt);
+bool get_check_strict(player_type *player_ptr, concptr prompt, BIT_FLAGS mode);
+bool get_com(concptr prompt, char *command, bool z_escape);
+QUANTITY get_quantity(concptr prompt, QUANTITY max);
+void pause_line(int row);
index bf4317f..6368691 100644 (file)
@@ -1,5 +1,6 @@
 #include "core/game-closer.h"
 #include "cmd-io/cmd-save.h"
+#include "core/asking-player.h"
 #include "core/scores.h"
 #include "core/stuff-handler.h"
 #include "game-option/cheat-options.h"
index eceb313..6e5cb5c 100644 (file)
@@ -15,6 +15,7 @@
 #include "birth/character-builder.h"
 #include "birth/inventory-initializer.h"
 #include "cmd-io/cmd-gameoption.h"
+#include "core/asking-player.h"
 #include "core/game-closer.h"
 #include "core/output-updater.h"
 #include "core/player-processor.h"
index 434db7a..5ee71d6 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "core/scores.h"
 #include "cmd-io/cmd-dump.h"
+#include "core/asking-player.h"
 #include "core/turn-compensator.h"
 #include "dungeon/dungeon.h"
 #include "floor/floor.h"
index 3398710..fe09bef 100644 (file)
@@ -1,4 +1,5 @@
 #include "core/show-file.h"
+#include "core/asking-player.h"
 #include "io/files-util.h"
 #include "io/input-key-acceptor.h"
 #include "main/sound-of-music.h"
index 0047eaa..98d0d44 100644 (file)
@@ -1,6 +1,7 @@
 #include "dungeon/quest.h"
 #include "art-definition/art-bow-types.h"
 #include "cmd-io/cmd-dump.h"
+#include "core/asking-player.h"
 #include "dungeon/dungeon.h"
 #include "floor/floor-events.h"
 #include "floor/floor-object.h"
index 0e5cc65..f9327dd 100644 (file)
@@ -13,6 +13,7 @@
 #include "cmd-building/cmd-building.h"
 #include "cmd-io/cmd-dump.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "dungeon/dungeon.h"
 #include "dungeon/quest.h"
 #include "floor/floor-events.h"
index bc93186..cd11898 100644 (file)
@@ -1,5 +1,6 @@
 #include "floor/pattern-walk.h"
 #include "cmd-io/cmd-save.h"
+#include "core/asking-player.h"
 #include "dungeon/dungeon.h"
 #include "dungeon/quest.h"
 #include "game-option/birth-options.h"
index 244d49a..6de8a34 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #include "floor/wild.h"
-#include "info-reader/fixed-map-parser.h"
+#include "core/asking-player.h"
 #include "dungeon/dungeon.h"
 #include "dungeon/quest.h"
 #include "floor/floor-town.h"
@@ -19,6 +19,7 @@
 #include "game-option/map-screen-options.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
+#include "info-reader/fixed-map-parser.h"
 #include "info-reader/parse-error-types.h"
 #include "io/files-util.h"
 #include "io/tokenizer.h"
 #include "monster-floor/monster-generator.h"
 #include "monster-floor/monster-remover.h"
 #include "monster-floor/monster-summon.h"
+#include "monster-floor/place-monster-types.h"
+#include "monster/monster-info.h"
 #include "monster/monster-status.h"
 #include "monster/monster-util.h"
-#include "monster/monster-info.h"
-#include "monster-floor/place-monster-types.h"
 #include "player/player-effects.h"
 #include "player/player-status.h"
 #include "realm/realm-names-table.h"
index abc3e4b..dc230bd 100644 (file)
@@ -1,5 +1,6 @@
 #include "inventory/inventory-curse.h"
 #include "art-definition/art-accessory-types.h"
+#include "core/asking-player.h"
 #include "io/files-util.h"
 #include "monster-floor/monster-summon.h"
 #include "monster-floor/place-monster-types.h"
index 83b76d9..850e068 100644 (file)
@@ -1,4 +1,5 @@
 #include "inventory/player-inventory.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "floor/floor-object.h"
 #include "floor/floor.h"
index d37a291..7ceaada 100644 (file)
@@ -9,6 +9,7 @@
 #include "io/chuukei.h"
 #include "cmd-io/cmd-dump.h"
 #include "cmd/cmd-draw.h"
+#include "core/asking-player.h"
 #include "io/files-util.h"
 #include "io/inet.h"
 #include "io/signal-handlers.h"
index fe96db1..54b0ef2 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include "io/files-util.h"
+#include "core/asking-player.h"
 #include "io-dump/character-dump.h"
 #include "io/input-key-acceptor.h"
 #include "io/uid-checker.h"
index 6abb8f5..9d6d3ac 100644 (file)
@@ -35,6 +35,7 @@
 #include "cmd/cmd-basic.h"
 #include "cmd/cmd-draw.h"
 #include "cmd/cmd-visuals.h"
+#include "core/asking-player.h"
 #include "core/special-internal-keys.h"
 #include "dungeon/dungeon.h"
 #include "dungeon/quest.h" // do_cmd_quest() がある。後で移設する.
index 3e1aa95..76be8b2 100644 (file)
@@ -16,6 +16,7 @@
 #include "io/read-pref-file.h"
 #include "autopick/autopick-pref-processor.h"
 #include "autopick/autopick-reader-writer.h"
+#include "core/asking-player.h"
 #include "io-dump/dump-remover.h"
 #include "io/files-util.h"
 #include "io/interpret-pref-file.h"
index 416a0a1..92906d6 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "io/report.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "core/turn-compensator.h"
 #include "core/visuals-reseter.h"
index 76adef1..2e879c4 100644 (file)
@@ -12,6 +12,7 @@
 #include "io/targeting.h"
 #include "cmd-action/cmd-pet.h"
 #include "cmd-building/cmd-building.h"
+#include "core/asking-player.h"
 #include "core/sort.h"
 #include "core/stuff-handler.h"
 #include "info-reader/fixed-map-parser.h"
index 58e7dd0..6a9d467 100644 (file)
@@ -8,6 +8,7 @@
 #include "autopick/autopick-entry.h"
 #include "autopick/autopick-methods-table.h"
 #include "autopick/autopick-reader-writer.h"
+#include "core/asking-player.h"
 #include "core/show-file.h"
 #include "io-dump/dump-util.h"
 #include "util/angband-files.h"
index 5cdf89a..01e956e 100644 (file)
@@ -1,4 +1,5 @@
 #include "market/arena.h"
+#include "core/asking-player.h"
 #include "core/show-file.h"
 #include "core/stuff-handler.h"
 #include "dungeon/dungeon.h"
index 0a1e131..5915dcc 100644 (file)
@@ -1,5 +1,6 @@
 #include "market/bounty.h"
 #include "autopick/autopick.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "dungeon/dungeon.h"
 #include "floor/floor.h"
index b73b7bc..7c10dba 100644 (file)
@@ -1,5 +1,6 @@
 #include "market/building-craft-fix.h"
 #include "art-definition/art-sword-types.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "inventory/inventory-object.h"
 #include "inventory/player-inventory.h"
index 2adadeb..785549e 100644 (file)
@@ -1,4 +1,5 @@
 #include "market/building-monster.h"
+#include "core/asking-player.h"
 #include "core/sort.h"
 #include "core/stuff-handler.h"
 #include "game-option/game-play-options.h"
index 0ad6077..c8d44b9 100644 (file)
@@ -1,5 +1,6 @@
 #include "market/building-recharger.h"
 #include "autopick/autopick.h"
+#include "core/asking-player.h"
 #include "inventory/player-inventory.h"
 #include "market/building-util.h"
 #include "object/item-use-flags.h"
index 351996b..e5025e3 100644 (file)
@@ -1,4 +1,5 @@
 #include "play-gamble.h"
+#include "core/asking-player.h"
 #include "core/show-file.h"
 #include "io/input-key-acceptor.h"
 #include "market/building-actions-table.h"
index 9cd1184..ce4c37d 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "mind/mind-sniper.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "floor/floor.h"
 #include "game-option/text-display-options.h"
index 651fda9..eaab57d 100644 (file)
@@ -18,6 +18,7 @@
 #include "cmd-action/cmd-attack.h"
 #include "cmd-action/cmd-spell.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "effect/effect-characteristics.h"
 #include "effect/spells-effect-util.h"
index 8671a12..094a27b 100644 (file)
@@ -1,5 +1,4 @@
 /*!
- * @file racial.c
  * @brief レイシャルと突然変異の技能処理 / Racial powers (and mutations)
  * @date 2014/01/08
  * @author
@@ -16,6 +15,7 @@
 #include "cmd-item/cmd-magiceat.h"
 #include "cmd-item/cmd-zapwand.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "effect/spells-effect-util.h"
 #include "game-option/disturbance-options.h"
index 750325c..b7d4471 100644 (file)
@@ -12,6 +12,7 @@
 #include "system/angband.h"
 #include "cmd-action/cmd-spell.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "floor/floor.h"
 #include "game-option/disturbance-options.h"
index 2b60e3e..5a9887c 100644 (file)
@@ -14,6 +14,7 @@
 #include "mutation/mutation.h"
 #include "cmd-io/cmd-dump.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/show-file.h"
 #include "core/stuff-handler.h"
 #include "effect/spells-effect-util.h"
index 54f30e3..f5951ea 100644 (file)
@@ -17,6 +17,7 @@
 #include "art-definition/art-weapon-types.h"
 #include "art-definition/random-art-effects.h"
 #include "cmd-item/cmd-smith.h"
+#include "core/asking-player.h"
 #include "floor/floor-object.h"
 #include "floor/floor.h"
 #include "grid/grid.h"
index 0ca1fe6..4dbbf2a 100644 (file)
@@ -1,5 +1,6 @@
 #include "object/warning.h"
 #include "art-definition/art-sword-types.h"
+#include "core/asking-player.h"
 #include "dungeon/dungeon.h"
 #include "floor/floor.h"
 #include "game-option/input-options.h"
index 0c57520..d0df825 100644 (file)
@@ -2,6 +2,7 @@
 #include "autopick/autopick-pref-processor.h"
 #include "cmd-building/cmd-building.h"
 #include "cmd-io/cmd-process-screen.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "dungeon/quest.h"
 #include "floor/floor.h"
index 775853d..c952d13 100644 (file)
 #include "autopick/autopick.h"
 #include "cmd-action/cmd-attack.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "core/special-internal-keys.h"
 #include "core/stuff-handler.h"
 #include "dungeon/dungeon.h"
index 90c0c9c..333ffc5 100644 (file)
@@ -10,6 +10,7 @@
 #include "cmd-io/cmd-dump.h"
 #include "cmd-item/cmd-magiceat.h"
 #include "combat/attack-power-table.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "dungeon/dungeon.h"
 #include "dungeon/quest.h"
index 0e51edf..bb46598 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "process-death.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "floor/floor-town.h"
 #include "floor/floor.h"
index 019cab3..65098a0 100644 (file)
@@ -1,5 +1,6 @@
 #include "player/process-name.h"
 #include "autopick/autopick-reader-writer.h"
+#include "core/asking-player.h"
 #include "io/files-util.h"
 #include "player/player-personality.h"
 #include "term/term-color-types.h"
index 32ef27c..244ae08 100644 (file)
@@ -1,5 +1,6 @@
 #include "realm/realm-arcane.h"
 #include "cmd-action/cmd-spell.h"
+#include "core/asking-player.h"
 #include "io/targeting.h"
 #include "monster-floor/monster-summon.h"
 #include "monster-floor/place-monster-types.h"
index 3be178d..b5b923d 100644 (file)
@@ -1,5 +1,6 @@
 #include "realm/realm-chaos.h"
 #include "cmd-action/cmd-spell.h"
+#include "core/asking-player.h"
 #include "effect/effect-characteristics.h"
 #include "io/targeting.h"
 #include "player/player-class.h"
index e24220f..828d64f 100644 (file)
@@ -1,5 +1,4 @@
 /*!
- * @file hex.c
  * @brief 呪術の処理実装 / Hex code
  * @date 2014/01/14
  * @author
@@ -18,6 +17,7 @@
 #include "realm/realm-hex.h"
 #include "cmd-action/cmd-spell.h"
 #include "cmd-item/cmd-quaff.h"
+#include "core/asking-player.h"
 #include "effect/effect-characteristics.h"
 #include "floor/floor.h"
 #include "grid/grid.h"
index 335c208..fa6f505 100644 (file)
@@ -4,6 +4,7 @@
 #include "cmd-action/cmd-spell.h"
 #include "cmd/cmd-basic.h"
 #include "combat/combat-options-type.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "dungeon/dungeon.h"
 #include "effect/effect-characteristics.h"
index 0ddfe0f..c7219ce 100644 (file)
@@ -1,5 +1,6 @@
 #include "realm/realm-sorcery.h"
 #include "cmd-action/cmd-spell.h"
+#include "core/asking-player.h"
 #include "io/targeting.h"
 #include "player/avatar.h"
 #include "player/player-effects.h"
index 93136d9..4a180f8 100644 (file)
@@ -1,5 +1,6 @@
 #include "realm/realm-trump.h"
 #include "cmd-action/cmd-spell.h"
+#include "core/asking-player.h"
 #include "effect/spells-effect-util.h"
 #include "game-option/input-options.h"
 #include "io/targeting.h"
index 7689018..df8d7fa 100644 (file)
@@ -1,4 +1,5 @@
 #include "spell-kind/spells-genocide.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "dungeon/quest.h"
 #include "floor/floor.h"
index 04d4b60..a8f9fee 100644 (file)
@@ -1,4 +1,5 @@
 #include "spell-kind/spells-pet.h"
+#include "core/asking-player.h"
 #include "effect/effect-characteristics.h"
 #include "floor/floor.h"
 #include "game-option/play-record-options.h"
index 1c44d7c..811f45b 100644 (file)
@@ -8,6 +8,7 @@
 #include "spell-kind/spells-teleport.h"
 #include "art-definition/art-bow-types.h"
 #include "cmd-io/cmd-save.h"
+#include "core/asking-player.h"
 #include "dungeon/dungeon.h"
 #include "dungeon/quest.h"
 #include "effect/effect-characteristics.h"
index d5940ac..e88d9c2 100644 (file)
@@ -1,6 +1,5 @@
-#include "system/angband.h"
-#include "spell-kind/spells-world.h"
-#include "util/util.h"
+#include "spell-kind/spells-world.h"
+#include "core/asking-player.h"
 #include "world/world.h"
 
 /*!
@@ -24,4 +23,3 @@ bool set_gametime(void)
        return TRUE;
 
 }
-
index 45b353f..a0f5e17 100644 (file)
@@ -1 +1,5 @@
-extern bool set_gametime(void);
+#pragma once
+
+#include "system/angband.h"
+
+bool set_gametime(void);
index 18b2420..5257a1c 100644 (file)
@@ -1,4 +1,5 @@
 #include "spell-realm/spells-hex.h"
+#include "core/asking-player.h"
 #include "floor/floor.h"
 #include "player/player-effects.h" // todo 相互参照している.
 #include "player/player-skill.h"
index 6d4b107..e2b46d2 100644 (file)
@@ -8,6 +8,7 @@
 #include "art-definition/art-weapon-types.h"
 #include "autopick/autopick.h"
 #include "cmd/cmd-basic.h"
+#include "core/asking-player.h"
 #include "floor/floor-object.h"
 #include "floor/floor.h"
 #include "game-option/disturbance-options.h"
index 9765e4a..116205b 100644 (file)
@@ -16,6 +16,7 @@
 #include "cmd-action/cmd-spell.h"
 #include "cmd-building/cmd-building.h"
 #include "cmd-io/cmd-dump.h"
+#include "core/asking-player.h"
 #include "core/speed-table.h"
 #include "core/stuff-handler.h"
 #include "dungeon/dungeon.h"
index e97df7c..4df65af 100644 (file)
@@ -29,6 +29,7 @@
 #include "cmd/cmd-basic.h"
 #include "cmd/cmd-draw.h"
 #include "cmd/cmd-visuals.h"
+#include "core/asking-player.h"
 #include "mind/mind-sniper.h"
 #include "core/stuff-handler.h"
 #include "floor/floor-events.h"
index 62821b9..d081371 100644 (file)
@@ -15,6 +15,7 @@
 #include "cmd-io/cmd-dump.h"
 #include "cmd-io/cmd-menu-content-table.h"
 #include "cmd-io/macro-util.h"
+#include "core/asking-player.h"
 #include "core/output-updater.h"
 #include "core/stuff-handler.h"
 #include "dungeon/quest.h"
@@ -341,429 +342,6 @@ void clear_from(int row)
 
 
 /*
- * Get some string input at the cursor location.
- * Assume the buffer is initialized to a default string.
- *
- * The default buffer is in Overwrite mode and displayed in yellow at
- * first.  Normal chars clear the yellow text and append the char in
- * white text.
- *
- * LEFT (^B) and RIGHT (^F) movement keys move the cursor position.
- * If the text is still displayed in yellow (Overwite mode), it will
- * turns into white (Insert mode) when cursor moves.
- *
- * DELETE (^D) deletes a char at the cursor position.
- * BACKSPACE (^H) deletes a char at the left of cursor position.
- * ESCAPE clears the buffer and the window and returns FALSE.
- * RETURN accepts the current buffer contents and returns TRUE.
- */
-bool askfor_aux(char *buf, int len, bool numpad_cursor)
-{
-       /*
-        * Text color
-        * TERM_YELLOW : Overwrite mode
-        * TERM_WHITE : Insert mode
-        */
-       byte color = TERM_YELLOW;
-
-       int y, x;
-       Term_locate(&x, &y);
-       if (len < 1) len = 1;
-       if ((x < 0) || (x >= 80)) x = 0;
-       if (x + len > 80) len = 80 - x;
-
-       buf[len] = '\0';
-
-       int pos = 0;
-       while (TRUE)
-       {
-               Term_erase(x, y, len);
-               Term_putstr(x, y, -1, color, buf);
-
-               Term_gotoxy(x + pos, y);
-               int skey = inkey_special(numpad_cursor);
-
-               switch (skey)
-               {
-               case SKEY_LEFT:
-               case KTRL('b'):
-               {
-                       int i = 0;
-                       color = TERM_WHITE;
-
-                       if (0 == pos) break;
-                       while (TRUE)
-                       {
-                               int next_pos = i + 1;
-#ifdef JP
-                               if (iskanji(buf[i])) next_pos++;
-#endif
-                               if (next_pos >= pos) break;
-
-                               i = next_pos;
-                       }
-
-                       pos = i;
-                       break;
-               }
-
-               case SKEY_RIGHT:
-               case KTRL('f'):
-                       color = TERM_WHITE;
-                       if ('\0' == buf[pos]) break;
-
-#ifdef JP
-                       if (iskanji(buf[pos])) pos += 2;
-                       else pos++;
-#else
-                       pos++;
-#endif
-                       break;
-
-               case ESCAPE:
-                       buf[0] = '\0';
-                       return FALSE;
-
-               case '\n':
-               case '\r':
-                       return TRUE;
-
-               case '\010':
-               {
-                       int i = 0;
-                       color = TERM_WHITE;
-                       if (0 == pos) break;
-                       while (TRUE)
-                       {
-                               int next_pos = i + 1;
-#ifdef JP
-                               if (iskanji(buf[i])) next_pos++;
-#endif
-                               if (next_pos >= pos) break;
-
-                               i = next_pos;
-                       }
-
-                       pos = i;
-               }
-                       /* Fall through */
-
-               case 0x7F:
-               case KTRL('d'):
-               {
-                       color = TERM_WHITE;
-                       if ('\0' == buf[pos]) break;
-                       int src = pos + 1;
-#ifdef JP
-                       if (iskanji(buf[pos])) src++;
-#endif
-
-                       int dst = pos;
-                       while ('\0' != (buf[dst++] = buf[src++]));
-                       break;
-               }
-
-               default:
-               {
-                       char tmp[100];
-                       if (skey & SKEY_MASK) break;
-                       char c = (char)skey;
-
-                       if (color == TERM_YELLOW)
-                       {
-                               buf[0] = '\0';
-                               color = TERM_WHITE;
-                       }
-
-                       strcpy(tmp, buf + pos);
-#ifdef JP
-                       if (iskanji(c))
-                       {
-                               inkey_base = TRUE;
-                               char next = inkey();
-                               if (pos + 1 < len)
-                               {
-                                       buf[pos++] = c;
-                                       buf[pos++] = next;
-                               }
-                               else
-                               {
-                                       bell();
-                               }
-                       }
-                       else
-#endif
-                       {
-#ifdef JP
-                               if (pos < len && (isprint(c) || iskana(c)))
-#else
-                               if (pos < len && isprint(c))
-#endif
-                               {
-                                       buf[pos++] = c;
-                               }
-                               else
-                               {
-                                       bell();
-                               }
-                       }
-
-                       buf[pos] = '\0';
-                       angband_strcat(buf, tmp, len + 1);
-
-                       break;
-               }
-               }
-
-       }
-}
-
-
-/*
- * Get some string input at the cursor location.
- *
- * Allow to use numpad keys as cursor keys.
- */
-bool askfor(char *buf, int len)
-{
-       return askfor_aux(buf, len, TRUE);
-}
-
-
-/*
- * Get a string from the user
- *
- * The "prompt" should take the form "Prompt: "
- *
- * Note that the initial contents of the string is used as
- * the default response, so be sure to "clear" it if needed.
- *
- * We clear the input, and return FALSE, on "ESCAPE".
- */
-bool get_string(concptr prompt, char *buf, int len)
-{
-       bool res;
-       msg_print(NULL);
-       prt(prompt, 0, 0);
-       res = askfor(buf, len);
-       prt("", 0, 0);
-       return (res);
-}
-
-
-/*
- * Verify something with the user
- *
- * The "prompt" should take the form "Query? "
- *
- * Note that "[y/n]" is appended to the prompt.
- */
-bool get_check(concptr prompt)
-{
-       return get_check_strict(p_ptr, prompt, 0);
-}
-
-
-/*
- * Verify something with the user strictly
- *
- * mode & CHECK_OKAY_CANCEL : force user to answer 'O'kay or 'C'ancel
- * mode & CHECK_NO_ESCAPE   : don't allow ESCAPE key
- * mode & CHECK_NO_HISTORY  : no message_add
- * mode & CHECK_DEFAULT_Y   : accept any key as y, except n and Esc.
- */
-bool get_check_strict(player_type *player_ptr, concptr prompt, BIT_FLAGS mode)
-{
-       char buf[80];
-       if (auto_more)
-       {
-               player_ptr->window |= PW_MESSAGE;
-               handle_stuff(player_ptr);
-               num_more = 0;
-       }
-
-       msg_print(NULL);
-       if (!rogue_like_commands)
-               mode &= ~CHECK_OKAY_CANCEL;
-
-       if (mode & CHECK_OKAY_CANCEL)
-       {
-               angband_strcpy(buf, prompt, sizeof(buf) - 15);
-               strcat(buf, "[(O)k/(C)ancel]");
-       }
-       else if (mode & CHECK_DEFAULT_Y)
-       {
-               angband_strcpy(buf, prompt, sizeof(buf) - 5);
-               strcat(buf, "[Y/n]");
-       }
-       else
-       {
-               angband_strcpy(buf, prompt, sizeof(buf) - 5);
-               strcat(buf, "[y/n]");
-       }
-
-       prt(buf, 0, 0);
-        if (!(mode & CHECK_NO_HISTORY) && player_ptr->playing)
-       {
-               message_add(buf);
-               player_ptr->window |= (PW_MESSAGE);
-               handle_stuff(player_ptr);
-       }
-
-       bool flag = FALSE;
-       while (TRUE)
-       {
-               int i = inkey();
-
-               if (!(mode & CHECK_NO_ESCAPE))
-               {
-                       if (i == ESCAPE)
-                       {
-                               flag = FALSE;
-                               break;
-                       }
-               }
-
-               if (mode & CHECK_OKAY_CANCEL)
-               {
-                       if (i == 'o' || i == 'O')
-                       {
-                               flag = TRUE;
-                               break;
-                       }
-                       else if (i == 'c' || i == 'C')
-                       {
-                               flag = FALSE;
-                               break;
-                       }
-               }
-               else
-               {
-                       if (i == 'y' || i == 'Y')
-                       {
-                               flag = TRUE;
-                               break;
-                       }
-                       else if (i == 'n' || i == 'N')
-                       {
-                               flag = FALSE;
-                               break;
-                       }
-               }
-
-               if (mode & CHECK_DEFAULT_Y)
-               {
-                       flag = TRUE;
-                       break;
-               }
-
-               bell();
-       }
-
-       prt("", 0, 0);
-       return flag;
-}
-
-
-/*
- * Prompts for a keypress
- *
- * The "prompt" should take the form "Command: "
- *
- * Returns TRUE unless the character is "Escape"
- */
-bool get_com(concptr prompt, char *command, bool z_escape)
-{
-       msg_print(NULL);
-       prt(prompt, 0, 0);
-       if (get_com_no_macros)
-               *command = (char)inkey_special(FALSE);
-       else
-               *command = inkey();
-
-       prt("", 0, 0);
-       if (*command == ESCAPE) return FALSE;
-       if (z_escape && ((*command == 'z') || (*command == 'Z'))) return FALSE;
-
-       return TRUE;
-}
-
-
-/*
- * Request a "quantity" from the user
- *
- * Hack -- allow "command_arg" to specify a quantity
- */
-QUANTITY get_quantity(concptr prompt, QUANTITY max)
-{
-       bool res;
-       char tmp[80];
-       char buf[80];
-
-       QUANTITY amt;
-       if (command_arg)
-       {
-               amt = command_arg;
-               command_arg = 0;
-               if (amt > max) amt = max;
-
-               return (amt);
-       }
-
-       COMMAND_CODE code;
-       bool result = repeat_pull(&code);
-       amt = (QUANTITY)code;
-       if ((max != 1) && result)
-       {
-               if (amt > max) amt = max;
-               if (amt < 0) amt = 0;
-
-               return (amt);
-       }
-
-       if (!prompt)
-       {
-               sprintf(tmp, _("いくつですか (1-%d): ", "Quantity (1-%d): "), max);
-               prompt = tmp;
-       }
-
-       msg_print(NULL);
-       prt(prompt, 0, 0);
-       amt = 1;
-       sprintf(buf, "%d", amt);
-
-       /*
-        * Ask for a quantity
-        * Don't allow to use numpad as cursor key.
-        */
-       res = askfor_aux(buf, 6, FALSE);
-
-       prt("", 0, 0);
-       if (!res) return 0;
-
-       amt = (COMMAND_CODE)atoi(buf);
-       if (isalpha(buf[0])) amt = max;
-       if (amt > max) amt = max;
-       if (amt < 0) amt = 0;
-       if (amt) repeat_push((COMMAND_CODE)amt);
-
-       return (amt);
-}
-
-
-/*
- * Pause for user response
- */
-void pause_line(int row)
-{
-       prt("", row, 0);
-       put_str(_("[ 何かキーを押して下さい ]", "[Press any key to continue]"), row, _(26, 23));
-
-       (void)inkey();
-       prt("", row, 0);
-}
-
-/*
  * Hack -- special buffer to hold the action of the current keymap
  */
 static char request_command_buffer[256];
index 533c544..8a01874 100644 (file)
@@ -207,23 +207,7 @@ extern void prt(concptr str, TERM_LEN row, TERM_LEN col);
 extern void c_roff(TERM_COLOR attr, concptr str);
 extern void roff(concptr str);
 extern void clear_from(int row);
-extern bool askfor_aux(char *buf, int len, bool numpad_cursor);
-extern bool askfor(char *buf, int len);
-extern bool get_string(concptr prompt, char *buf, int len);
 
-/*
- * Bit flags for control of get_check_strict()
- */
-#define CHECK_OKAY_CANCEL 0x01
-#define CHECK_NO_ESCAPE   0x02
-#define CHECK_NO_HISTORY  0x04
-#define CHECK_DEFAULT_Y   0x08
-extern bool get_check(concptr prompt);
-extern bool get_check_strict(player_type *player_ptr, concptr prompt, BIT_FLAGS mode);
-
-extern bool get_com(concptr prompt, char *command, bool z_escape);
-extern QUANTITY get_quantity(concptr prompt, QUANTITY max);
-extern void pause_line(int row);
 extern void request_command(player_type *player_ptr, int shopping);
 extern bool is_a_vowel(int ch);
 extern int get_keymap_dir(char ch);
index a82ef2d..17c527f 100644 (file)
@@ -16,6 +16,7 @@
 #include "cmd-io/cmd-help.h"
 #include "cmd-io/cmd-save.h"
 #include "cmd/cmd-draw.h"
+#include "core/asking-player.h"
 #include "core/stuff-handler.h"
 #include "dungeon/dungeon.h"
 #include "dungeon/quest.h"