OSDN Git Service

[Fix] 広域マップで'M'コマンドを押すとメッセージがずれる
authorHabu <habu1010+github@gmail.com>
Sat, 24 Jun 2023 09:49:07 +0000 (18:49 +0900)
committerHabu <habu1010+github@gmail.com>
Sat, 24 Jun 2023 09:49:07 +0000 (18:49 +0900)
広域マップで'M'コマンドを押すと「何かキーを押すとゲームに戻ります」とい
うメッセージが表示されるが、表示位置が固定なのでウィンドウを広げていると
意図とずれた位置に表示される。
ウィンドウの大きさから表示位置を決定するよう修正する。

src/cmd-visual/cmd-map.cpp

index a40f581..d19fc39 100644 (file)
@@ -6,6 +6,7 @@
 #include "term/screen-processor.h"
 #include "view/display-map.h"
 #include "window/main-window-util.h"
+#include <string_view>
 
 /*
  * Display a "small-scale" map of the dungeon for the player
@@ -23,7 +24,11 @@ void do_cmd_view_map(PlayerType *player_ptr)
     int cy, cx;
     display_map(player_ptr, &cy, &cx);
     if (autopick_list.empty() || player_ptr->wild_mode) {
-        put_str(_("何かキーを押すとゲームに戻ります", "Hit any key to continue"), 23, 30);
+        int wid, hgt;
+        term_get_size(&wid, &hgt);
+        constexpr auto msg = _("何かキーを押すとゲームに戻ります", "Hit any key to continue");
+        const auto center_x = (wid - std::string_view(msg).length()) / 2;
+        put_str(msg, hgt - 1, center_x);
         move_cursor(cy, cx);
         inkey(true);
         screen_load();