OSDN Git Service

[Refactor] #40483 Moved print_map(), display_map() and set_term_color() from display...
authorHourier <hourier@users.sourceforge.jp>
Fri, 26 Jun 2020 13:51:53 +0000 (22:51 +0900)
committerHourier <hourier@users.sourceforge.jp>
Fri, 26 Jun 2020 13:51:53 +0000 (22:51 +0900)
14 files changed:
src/autopick/autopick-registry.c
src/cmd-item/cmd-item.c
src/core/game-play.c
src/floor/fixed-map-generator.c
src/floor/floor-generate.c
src/floor/floor-save.c
src/floor/wild.c
src/grid/grid.c
src/io/input-key-requester.c
src/io/targeting.c
src/view/display-main-window.c
src/view/display-main-window.h
src/view/main-window-util.c
src/view/main-window-util.h

index c86274e..f4bef01 100644 (file)
@@ -119,11 +119,11 @@ static bool clear_auto_register(player_type *player_ptr)
 bool autopick_autoregister(player_type *player_ptr, object_type *o_ptr)
 {
        autopick_type an_entry, *entry = &an_entry;
-       int match_autopick = find_autopick_list(player_ptr, o_ptr);
-       if (match_autopick != -1)
+       int autopick_registered = find_autopick_list(player_ptr, o_ptr);
+       if (autopick_registered != -1)
        {
                concptr what;
-               byte act = autopick_list[match_autopick].action;
+               byte act = autopick_list[autopick_registered].action;
                if (act & DO_AUTOPICK) what = _("自動で拾う", "auto-pickup");
                else if (act & DO_AUTODESTROY) what = _("自動破壊する", "auto-destroy");
                else if (act & DONT_AUTOPICK) what = _("放置する", "leave on floor");
index 881b38f..86d63f7 100644 (file)
@@ -68,6 +68,7 @@
 #include "util/quarks.h"
 #include "view/display-messages.h"
 #include "view/display-main-window.h"
+#include "view/main-window-util.h"
 
 /*!
  * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory_list
index 2760867..7641259 100644 (file)
@@ -74,6 +74,7 @@
 #include "view/display-main-window.h"
 #include "view/display-messages.h"
 #include "view/display-player.h"
+#include "view/main-window-util.h"
 #include "world/world.h"
 
 /*!
index d7c99e4..5592db2 100644 (file)
@@ -4,6 +4,7 @@
 #include "floor/floor-town.h"
 #include "floor/floor.h"
 #include "floor/wild.h"
+#include "grid/feature.h"
 #include "grid/grid.h"
 #include "grid/trap.h"
 #include "info-reader/general-parser.h"
@@ -28,7 +29,7 @@
 #include "room/rooms-vault.h"
 #include "sv-definition/sv-scroll-types.h"
 #include "system/system-variables.h"
-#include "view/display-main-window.h"
+#include "view/main-window-util.h"
 #include "world/world-object.h"
 #include "world/world.h"
 
index 5eada21..f5ac388 100644 (file)
@@ -47,8 +47,8 @@
 #include "room/rooms.h"
 #include "system/system-variables.h"
 #include "util/bit-flags-calculator.h"
-#include "view/display-main-window.h"
 #include "view/display-messages.h"
+#include "view/main-window-util.h"
 #include "world/world.h"
 
 int dun_tun_rnd; 
index 9861371..b271077 100644 (file)
@@ -58,8 +58,8 @@
 #include "system/system-variables.h"
 #include "util/angband-files.h"
 #include "util/bit-flags-calculator.h"
-#include "view/display-main-window.h"
 #include "view/display-messages.h"
+#include "view/main-window-util.h"
 #include "world/world.h"
 
 bool repair_monsters;
index 27ffc5a..cd7cee0 100644 (file)
@@ -37,8 +37,8 @@
 #include "spell-realm/spells-hex.h"
 #include "system/system-variables.h"
 #include "util/bit-flags-calculator.h"
-#include "view/display-main-window.h"
 #include "view/display-messages.h"
+#include "view/main-window-util.h"
 #include "world/world.h"
 
 #define MAX_FEAT_IN_TERRAIN 18
index 9820c0a..e2a859c 100644 (file)
@@ -43,6 +43,7 @@
 #include "util/bit-flags-calculator.h"
 #include "view/display-main-window.h"
 #include "view/display-messages.h"
+#include "view/main-window-util.h"
 #include "world/world.h"
 
 #define MONSTER_FLOW_DEPTH 32 /*!< 敵のプレイヤーに対する移動道のりの最大値(この値以上は処理を打ち切る) / OPTION: Maximum flow depth when using "MONSTER_FLOW" */
index 7bb52f3..dbdb0b6 100644 (file)
@@ -10,8 +10,9 @@
 #include "util/int-char-converter.h"
 #include "util/quarks.h"
 #include "util/string-processor.h"
-#include "view/display-main-window.h" // todo panel_row_min が依存している。後で移設を検討する.
+#include "view/display-main-window.h" // todo move_cursor_relative() が依存している。後で移設を検討する.
 #include "view/display-messages.h"
+#include "view/main-window-util.h"
 
 /*
  * Keymaps for each "mode" associated with each keypress.
index f1e151e..9808177 100644 (file)
@@ -65,6 +65,7 @@
 #include "view/display-messages.h"
 #include "view/display-lore.h"
 #include "view/display-monster-status.h"
+#include "view/main-window-util.h"
 #include "world/world.h"
 
  /*!
index 9e35067..c97cc98 100644 (file)
@@ -44,7 +44,6 @@
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
 #include "monster/smart-learn-types.h"
-#include "object/object-flavor.h"
 #include "object/object-info.h"
 #include "object/object-kind.h"
 #include "object/object-mark-types.h"
  */
 #define IS_ASCII_GRAPHICS(A) (!((A)&0x80))
 
-static int feat_priority; /*!< マップ縮小表示時に表示すべき地形の優先度を保管する */
 static byte display_autopick; /*!< 自動拾い状態の設定フラグ */
-static int match_autopick;
-static object_type *autopick_obj; /*!< 各種自動拾い処理時に使うオブジェクトポインタ */
-
-/*
- * Dungeon size info
- */
-POSITION panel_row_min, panel_row_max;
-POSITION panel_col_min, panel_col_max;
-POSITION panel_col_prt, panel_row_prt;
-
-void print_map(player_type *player_ptr);
-void display_map(player_type *player_ptr, int *cy, int *cx);
-void set_term_color(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp);
 
 /*!
  * @brief ゲーム時刻を表示する /
@@ -1921,64 +1906,6 @@ int panel_col_of(int col)
     return col + 13;
 }
 
-/*
- * Prints the map of the dungeon
- *
- * Note that, for efficiency, we contain an "optimized" version
- * of both "lite_spot()" and "print_rel()", and that we use the
- * "lite_spot()" function to display the player grid, if needed.
- */
-void print_map(player_type *player_ptr)
-{
-    TERM_LEN wid, hgt;
-    Term_get_size(&wid, &hgt);
-
-    wid -= COL_MAP + 2;
-    hgt -= ROW_MAP + 2;
-
-    int v;
-    (void)Term_get_cursor(&v);
-
-    (void)Term_set_cursor(0);
-
-    floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    POSITION xmin = (0 < panel_col_min) ? panel_col_min : 0;
-    POSITION xmax = (floor_ptr->width - 1 > panel_col_max) ? panel_col_max : floor_ptr->width - 1;
-    POSITION ymin = (0 < panel_row_min) ? panel_row_min : 0;
-    POSITION ymax = (floor_ptr->height - 1 > panel_row_max) ? panel_row_max : floor_ptr->height - 1;
-
-    for (POSITION y = 1; y <= ymin - panel_row_prt; y++) {
-        Term_erase(COL_MAP, y, wid);
-    }
-
-    for (POSITION y = ymax - panel_row_prt; y <= hgt; y++) {
-        Term_erase(COL_MAP, y, wid);
-    }
-
-    for (POSITION y = ymin; y <= ymax; y++) {
-        for (POSITION x = xmin; x <= xmax; x++) {
-            TERM_COLOR a;
-            SYMBOL_CODE c;
-            TERM_COLOR ta;
-            SYMBOL_CODE tc;
-            map_info(player_ptr, y, x, &a, &c, &ta, &tc);
-            if (!use_graphics) {
-                if (current_world_ptr->timewalk_m_idx)
-                    a = TERM_DARK;
-                else if (is_invuln(player_ptr) || player_ptr->timewalk)
-                    a = TERM_WHITE;
-                else if (player_ptr->wraith_form)
-                    a = TERM_L_DARK;
-            }
-
-            Term_queue_bigchar(panel_col_of(x), y - panel_row_prt, a, c, ta, tc);
-        }
-    }
-
-    lite_spot(player_ptr, player_ptr->y, player_ptr->x);
-    (void)Term_set_cursor(v);
-}
-
 /* 一般的にモンスターシンボルとして扱われる記号を定義する(幻覚処理向け) / Hack -- Legal monster codes */
 static char image_monster_hack[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
@@ -2360,284 +2287,6 @@ void map_info(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, S
     set_term_color(player_ptr, y, x, ap, cp);
 }
 
-void set_term_color(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp)
-{
-    if (!player_bold(player_ptr, y, x))
-        return;
-
-    monster_race *r_ptr = &r_info[0];
-    *ap = r_ptr->x_attr;
-    *cp = r_ptr->x_char;
-    feat_priority = 31;
-}
-
-static concptr simplify_list[][2] = {
-#ifdef JP
-    { "の魔法書", "" }, { NULL, NULL }
-#else
-    { "^Ring of ", "=" }, { "^Amulet of ", "\"" }, { "^Scroll of ", "?" }, { "^Scroll titled ", "?" }, { "^Wand of ", "-" }, { "^Rod of ", "-" },
-    { "^Staff of ", "_" }, { "^Potion of ", "!" }, { " Spellbook ", "" }, { "^Book of ", "" }, { " Magic [", "[" }, { " Book [", "[" }, { " Arts [", "[" },
-    { "^Set of ", "" }, { "^Pair of ", "" }, { NULL, NULL }
-#endif
-};
-
-static void display_shortened_item_name(player_type *player_ptr, object_type *o_ptr, int y)
-{
-    char buf[MAX_NLEN];
-    object_desc(player_ptr, buf, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
-    TERM_COLOR attr = tval_to_attr[o_ptr->tval % 128];
-
-    if (player_ptr->image) {
-        attr = TERM_WHITE;
-        strcpy(buf, _("何か奇妙な物", "something strange"));
-    }
-
-    char *c = buf;
-    for (c = buf; *c; c++) {
-        for (int i = 0; simplify_list[i][1]; i++) {
-            concptr org_w = simplify_list[i][0];
-
-            if (*org_w == '^') {
-                if (c == buf)
-                    org_w++;
-                else
-                    continue;
-            }
-
-            if (strncmp(c, org_w, strlen(org_w)))
-                continue;
-
-            char *s = c;
-            concptr tmp = simplify_list[i][1];
-            while (*tmp)
-                *s++ = *tmp++;
-            tmp = c + strlen(org_w);
-            while (*tmp)
-                *s++ = *tmp++;
-            *s = '\0';
-        }
-    }
-
-    c = buf;
-    int len = 0;
-    /* 半角 12 文字分で切る */
-    while (*c) {
-#ifdef JP
-        if (iskanji(*c)) {
-            if (len + 2 > 12)
-                break;
-            c += 2;
-            len += 2;
-        } else
-#endif
-        {
-            if (len + 1 > 12)
-                break;
-            c++;
-            len++;
-        }
-    }
-
-    *c = '\0';
-    Term_putstr(0, y, 12, attr, buf);
-}
-
-/*
- * Display a "small-scale" map of the dungeon in the active Term
- */
-void display_map(player_type *player_ptr, int *cy, int *cx)
-{
-    int i, j, x, y;
-
-    TERM_COLOR ta;
-    SYMBOL_CODE tc;
-
-    byte tp;
-
-    TERM_COLOR **bigma;
-    SYMBOL_CODE **bigmc;
-    byte **bigmp;
-
-    TERM_COLOR **ma;
-    SYMBOL_CODE **mc;
-    byte **mp;
-
-    bool old_view_special_lite = view_special_lite;
-    bool old_view_granite_lite = view_granite_lite;
-    TERM_LEN hgt, wid, yrat, xrat;
-    int **match_autopick_yx;
-    object_type ***object_autopick_yx;
-    Term_get_size(&wid, &hgt);
-    hgt -= 2;
-    wid -= 14;
-    if (use_bigtile)
-        wid /= 2;
-
-    floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    yrat = (floor_ptr->height + hgt - 1) / hgt;
-    xrat = (floor_ptr->width + wid - 1) / wid;
-    view_special_lite = FALSE;
-    view_granite_lite = FALSE;
-
-    C_MAKE(ma, (hgt + 2), TERM_COLOR *);
-    C_MAKE(mc, (hgt + 2), char_ptr);
-    C_MAKE(mp, (hgt + 2), byte_ptr);
-    C_MAKE(match_autopick_yx, (hgt + 2), int *);
-    C_MAKE(object_autopick_yx, (hgt + 2), object_type **);
-    for (y = 0; y < (hgt + 2); y++) {
-        C_MAKE(ma[y], (wid + 2), TERM_COLOR);
-        C_MAKE(mc[y], (wid + 2), char);
-        C_MAKE(mp[y], (wid + 2), byte);
-        C_MAKE(match_autopick_yx[y], (wid + 2), int);
-        C_MAKE(object_autopick_yx[y], (wid + 2), object_type *);
-        for (x = 0; x < wid + 2; ++x) {
-            match_autopick_yx[y][x] = -1;
-            object_autopick_yx[y][x] = NULL;
-            ma[y][x] = TERM_WHITE;
-            mc[y][x] = ' ';
-            mp[y][x] = 0;
-        }
-    }
-
-    C_MAKE(bigma, (floor_ptr->height + 2), TERM_COLOR *);
-    C_MAKE(bigmc, (floor_ptr->height + 2), char_ptr);
-    C_MAKE(bigmp, (floor_ptr->height + 2), byte_ptr);
-    for (y = 0; y < (floor_ptr->height + 2); y++) {
-        C_MAKE(bigma[y], (floor_ptr->width + 2), TERM_COLOR);
-        C_MAKE(bigmc[y], (floor_ptr->width + 2), char);
-        C_MAKE(bigmp[y], (floor_ptr->width + 2), byte);
-        for (x = 0; x < floor_ptr->width + 2; ++x) {
-            bigma[y][x] = TERM_WHITE;
-            bigmc[y][x] = ' ';
-            bigmp[y][x] = 0;
-        }
-    }
-
-    for (i = 0; i < floor_ptr->width; ++i) {
-        for (j = 0; j < floor_ptr->height; ++j) {
-            x = i / xrat + 1;
-            y = j / yrat + 1;
-
-            match_autopick = -1;
-            autopick_obj = NULL;
-            feat_priority = -1;
-            map_info(player_ptr, j, i, &ta, &tc, &ta, &tc);
-            tp = (byte)feat_priority;
-            if (match_autopick != -1 && (match_autopick_yx[y][x] == -1 || match_autopick_yx[y][x] > match_autopick)) {
-                match_autopick_yx[y][x] = match_autopick;
-                object_autopick_yx[y][x] = autopick_obj;
-                tp = 0x7f;
-            }
-
-            bigmc[j + 1][i + 1] = tc;
-            bigma[j + 1][i + 1] = ta;
-            bigmp[j + 1][i + 1] = tp;
-        }
-    }
-
-    for (j = 0; j < floor_ptr->height; ++j) {
-        for (i = 0; i < floor_ptr->width; ++i) {
-            x = i / xrat + 1;
-            y = j / yrat + 1;
-
-            tc = bigmc[j + 1][i + 1];
-            ta = bigma[j + 1][i + 1];
-            tp = bigmp[j + 1][i + 1];
-            if (mp[y][x] == tp) {
-                int t;
-                int cnt = 0;
-
-                for (t = 0; t < 8; t++) {
-                    if (tc == bigmc[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]] && ta == bigma[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]])
-                        cnt++;
-                }
-                if (cnt <= 4)
-                    tp++;
-            }
-
-            if (mp[y][x] < tp) {
-                mc[y][x] = tc;
-                ma[y][x] = ta;
-                mp[y][x] = tp;
-            }
-        }
-    }
-
-    x = wid + 1;
-    y = hgt + 1;
-
-    mc[0][0] = mc[0][x] = mc[y][0] = mc[y][x] = '+';
-    for (x = 1; x <= wid; x++)
-        mc[0][x] = mc[y][x] = '-';
-
-    for (y = 1; y <= hgt; y++)
-        mc[y][0] = mc[y][x] = '|';
-
-    for (y = 0; y < hgt + 2; ++y) {
-        Term_gotoxy(COL_MAP, y);
-        for (x = 0; x < wid + 2; ++x) {
-            ta = ma[y][x];
-            tc = mc[y][x];
-            if (!use_graphics) {
-                if (current_world_ptr->timewalk_m_idx)
-                    ta = TERM_DARK;
-                else if (is_invuln(player_ptr) || player_ptr->timewalk)
-                    ta = TERM_WHITE;
-                else if (player_ptr->wraith_form)
-                    ta = TERM_L_DARK;
-            }
-
-            Term_add_bigch(ta, tc);
-        }
-    }
-
-    for (y = 1; y < hgt + 1; ++y) {
-        match_autopick = -1;
-        for (x = 1; x <= wid; x++) {
-            if (match_autopick_yx[y][x] != -1 && (match_autopick > match_autopick_yx[y][x] || match_autopick == -1)) {
-                match_autopick = match_autopick_yx[y][x];
-                autopick_obj = object_autopick_yx[y][x];
-            }
-        }
-
-        Term_putstr(0, y, 12, 0, "            ");
-        if (match_autopick != -1)
-            display_shortened_item_name(player_ptr, autopick_obj, y);
-    }
-
-    (*cy) = player_ptr->y / yrat + 1 + ROW_MAP;
-    if (!use_bigtile)
-        (*cx) = player_ptr->x / xrat + 1 + COL_MAP;
-    else
-        (*cx) = (player_ptr->x / xrat + 1) * 2 + COL_MAP;
-
-    view_special_lite = old_view_special_lite;
-    view_granite_lite = old_view_granite_lite;
-
-    for (y = 0; y < (hgt + 2); y++) {
-        C_KILL(ma[y], (wid + 2), TERM_COLOR);
-        C_KILL(mc[y], (wid + 2), SYMBOL_CODE);
-        C_KILL(mp[y], (wid + 2), byte);
-        C_KILL(match_autopick_yx[y], (wid + 2), int);
-        C_KILL(object_autopick_yx[y], (wid + 2), object_type *);
-    }
-
-    C_KILL(ma, (hgt + 2), TERM_COLOR *);
-    C_KILL(mc, (hgt + 2), char_ptr);
-    C_KILL(mp, (hgt + 2), byte_ptr);
-    C_KILL(match_autopick_yx, (hgt + 2), int *);
-    C_KILL(object_autopick_yx, (hgt + 2), object_type **);
-    for (y = 0; y < (floor_ptr->height + 2); y++) {
-        C_KILL(bigma[y], (floor_ptr->width + 2), TERM_COLOR);
-        C_KILL(bigmc[y], (floor_ptr->width + 2), SYMBOL_CODE);
-        C_KILL(bigmp[y], (floor_ptr->width + 2), byte);
-    }
-
-    C_KILL(bigma, (floor_ptr->height + 2), TERM_COLOR *);
-    C_KILL(bigmc, (floor_ptr->height + 2), char_ptr);
-    C_KILL(bigmp, (floor_ptr->height + 2), byte_ptr);
-}
-
 /*
  * Display a "small-scale" map of the dungeon for the player
  *
index 6da54be..663e5f6 100644 (file)
@@ -24,19 +24,11 @@ extern bool change_panel(player_type *player_ptr, POSITION dy, POSITION dx);
 extern void window_stuff(player_type *player_ptr);
 extern void update_playtime(void);
 
-#define ROW_MAP                 0
-#define COL_MAP                 12
-
-
 /*
  * Bit flags for the "redraw" variable
  */
 extern void redraw_stuff(player_type *creature_ptr);
 
-extern POSITION panel_row_min, panel_row_max;
-extern POSITION panel_col_min, panel_col_max;
-extern POSITION panel_col_prt, panel_row_prt;
-
 /*
  * Determines if a map location is currently "on screen" -RAK-
  * Note that "panel_contains(Y,X)" always implies "in_bounds2(Y,X)".
index 52853b7..97b9293 100644 (file)
@@ -1,6 +1,41 @@
 #include "view/main-window-util.h"
+#include "floor/floor.h"
+#include "floor/geometry.h"
+#include "game-option/map-screen-options.h"
+#include "game-option/special-options.h"
+#include "grid/grid.h"
+#include "object/object-flavor.h"
+#include "monster-race/monster-race.h"
+#include "system/monster-race-definition.h"
+#include "term/gameterm.h"
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
+#include "view/display-main-window.h" // 相互依存している。後で何とかする
+#include "world/world.h"
+
+/*
+ * Dungeon size info
+ */
+POSITION panel_row_min;
+POSITION panel_row_max;
+POSITION panel_col_min;
+POSITION panel_col_max;
+POSITION panel_col_prt;
+POSITION panel_row_prt;
+
+int match_autopick;
+object_type *autopick_obj; /*!< 各種自動拾い処理時に使うオブジェクトポインタ */
+int feat_priority; /*!< マップ縮小表示時に表示すべき地形の優先度を保管する */
+
+static concptr simplify_list[][2] = {
+#ifdef JP
+    { "の魔法書", "" }, { NULL, NULL }
+#else
+    { "^Ring of ", "=" }, { "^Amulet of ", "\"" }, { "^Scroll of ", "?" }, { "^Scroll titled ", "?" }, { "^Wand of ", "-" }, { "^Rod of ", "-" },
+    { "^Staff of ", "_" }, { "^Potion of ", "!" }, { " Spellbook ", "" }, { "^Book of ", "" }, { " Magic [", "[" }, { " Book [", "[" }, { " Arts [", "[" },
+    { "^Set of ", "" }, { "^Pair of ", "" }, { NULL, NULL }
+#endif
+};
 
 /*!
  * @brief 画面左の能力値表示を行うために指定位置から13キャラ分を空白消去後指定のメッセージを明るい青で描画する /
@@ -15,3 +50,329 @@ void print_field(concptr info, TERM_LEN row, TERM_LEN col)
     c_put_str(TERM_WHITE, "             ", row, col);
     c_put_str(TERM_L_BLUE, info, row, col);
 }
+
+/*
+ * Prints the map of the dungeon
+ *
+ * Note that, for efficiency, we contain an "optimized" version
+ * of both "lite_spot()" and "print_rel()", and that we use the
+ * "lite_spot()" function to display the player grid, if needed.
+ */
+void print_map(player_type *player_ptr)
+{
+    TERM_LEN wid, hgt;
+    Term_get_size(&wid, &hgt);
+
+    wid -= COL_MAP + 2;
+    hgt -= ROW_MAP + 2;
+
+    int v;
+    (void)Term_get_cursor(&v);
+
+    (void)Term_set_cursor(0);
+
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    POSITION xmin = (0 < panel_col_min) ? panel_col_min : 0;
+    POSITION xmax = (floor_ptr->width - 1 > panel_col_max) ? panel_col_max : floor_ptr->width - 1;
+    POSITION ymin = (0 < panel_row_min) ? panel_row_min : 0;
+    POSITION ymax = (floor_ptr->height - 1 > panel_row_max) ? panel_row_max : floor_ptr->height - 1;
+
+    for (POSITION y = 1; y <= ymin - panel_row_prt; y++) {
+        Term_erase(COL_MAP, y, wid);
+    }
+
+    for (POSITION y = ymax - panel_row_prt; y <= hgt; y++) {
+        Term_erase(COL_MAP, y, wid);
+    }
+
+    for (POSITION y = ymin; y <= ymax; y++) {
+        for (POSITION x = xmin; x <= xmax; x++) {
+            TERM_COLOR a;
+            SYMBOL_CODE c;
+            TERM_COLOR ta;
+            SYMBOL_CODE tc;
+            map_info(player_ptr, y, x, &a, &c, &ta, &tc);
+            if (!use_graphics) {
+                if (current_world_ptr->timewalk_m_idx)
+                    a = TERM_DARK;
+                else if (is_invuln(player_ptr) || player_ptr->timewalk)
+                    a = TERM_WHITE;
+                else if (player_ptr->wraith_form)
+                    a = TERM_L_DARK;
+            }
+
+            Term_queue_bigchar(panel_col_of(x), y - panel_row_prt, a, c, ta, tc);
+        }
+    }
+
+    lite_spot(player_ptr, player_ptr->y, player_ptr->x);
+    (void)Term_set_cursor(v);
+}
+
+static void display_shortened_item_name(player_type *player_ptr, object_type *o_ptr, int y)
+{
+    char buf[MAX_NLEN];
+    object_desc(player_ptr, buf, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
+    TERM_COLOR attr = tval_to_attr[o_ptr->tval % 128];
+
+    if (player_ptr->image) {
+        attr = TERM_WHITE;
+        strcpy(buf, _("何か奇妙な物", "something strange"));
+    }
+
+    char *c = buf;
+    for (c = buf; *c; c++) {
+        for (int i = 0; simplify_list[i][1]; i++) {
+            concptr org_w = simplify_list[i][0];
+
+            if (*org_w == '^') {
+                if (c == buf)
+                    org_w++;
+                else
+                    continue;
+            }
+
+            if (strncmp(c, org_w, strlen(org_w)))
+                continue;
+
+            char *s = c;
+            concptr tmp = simplify_list[i][1];
+            while (*tmp)
+                *s++ = *tmp++;
+            tmp = c + strlen(org_w);
+            while (*tmp)
+                *s++ = *tmp++;
+            *s = '\0';
+        }
+    }
+
+    c = buf;
+    int len = 0;
+    /* 半角 12 文字分で切る */
+    while (*c) {
+#ifdef JP
+        if (iskanji(*c)) {
+            if (len + 2 > 12)
+                break;
+            c += 2;
+            len += 2;
+        } else
+#endif
+        {
+            if (len + 1 > 12)
+                break;
+            c++;
+            len++;
+        }
+    }
+
+    *c = '\0';
+    Term_putstr(0, y, 12, attr, buf);
+}
+
+/*
+ * Display a "small-scale" map of the dungeon in the active Term
+ */
+void display_map(player_type *player_ptr, int *cy, int *cx)
+{
+    int i, j, x, y;
+
+    TERM_COLOR ta;
+    SYMBOL_CODE tc;
+
+    byte tp;
+
+    TERM_COLOR **bigma;
+    SYMBOL_CODE **bigmc;
+    byte **bigmp;
+
+    TERM_COLOR **ma;
+    SYMBOL_CODE **mc;
+    byte **mp;
+
+    bool old_view_special_lite = view_special_lite;
+    bool old_view_granite_lite = view_granite_lite;
+    TERM_LEN hgt, wid, yrat, xrat;
+    int **match_autopick_yx;
+    object_type ***object_autopick_yx;
+    Term_get_size(&wid, &hgt);
+    hgt -= 2;
+    wid -= 14;
+    if (use_bigtile)
+        wid /= 2;
+
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    yrat = (floor_ptr->height + hgt - 1) / hgt;
+    xrat = (floor_ptr->width + wid - 1) / wid;
+    view_special_lite = FALSE;
+    view_granite_lite = FALSE;
+
+    C_MAKE(ma, (hgt + 2), TERM_COLOR *);
+    C_MAKE(mc, (hgt + 2), char_ptr);
+    C_MAKE(mp, (hgt + 2), byte_ptr);
+    C_MAKE(match_autopick_yx, (hgt + 2), int *);
+    C_MAKE(object_autopick_yx, (hgt + 2), object_type **);
+    for (y = 0; y < (hgt + 2); y++) {
+        C_MAKE(ma[y], (wid + 2), TERM_COLOR);
+        C_MAKE(mc[y], (wid + 2), char);
+        C_MAKE(mp[y], (wid + 2), byte);
+        C_MAKE(match_autopick_yx[y], (wid + 2), int);
+        C_MAKE(object_autopick_yx[y], (wid + 2), object_type *);
+        for (x = 0; x < wid + 2; ++x) {
+            match_autopick_yx[y][x] = -1;
+            object_autopick_yx[y][x] = NULL;
+            ma[y][x] = TERM_WHITE;
+            mc[y][x] = ' ';
+            mp[y][x] = 0;
+        }
+    }
+
+    C_MAKE(bigma, (floor_ptr->height + 2), TERM_COLOR *);
+    C_MAKE(bigmc, (floor_ptr->height + 2), char_ptr);
+    C_MAKE(bigmp, (floor_ptr->height + 2), byte_ptr);
+    for (y = 0; y < (floor_ptr->height + 2); y++) {
+        C_MAKE(bigma[y], (floor_ptr->width + 2), TERM_COLOR);
+        C_MAKE(bigmc[y], (floor_ptr->width + 2), char);
+        C_MAKE(bigmp[y], (floor_ptr->width + 2), byte);
+        for (x = 0; x < floor_ptr->width + 2; ++x) {
+            bigma[y][x] = TERM_WHITE;
+            bigmc[y][x] = ' ';
+            bigmp[y][x] = 0;
+        }
+    }
+
+    for (i = 0; i < floor_ptr->width; ++i) {
+        for (j = 0; j < floor_ptr->height; ++j) {
+            x = i / xrat + 1;
+            y = j / yrat + 1;
+
+            match_autopick = -1;
+            autopick_obj = NULL;
+            feat_priority = -1;
+            map_info(player_ptr, j, i, &ta, &tc, &ta, &tc);
+            tp = (byte)feat_priority;
+            if (match_autopick != -1 && (match_autopick_yx[y][x] == -1 || match_autopick_yx[y][x] > match_autopick)) {
+                match_autopick_yx[y][x] = match_autopick;
+                object_autopick_yx[y][x] = autopick_obj;
+                tp = 0x7f;
+            }
+
+            bigmc[j + 1][i + 1] = tc;
+            bigma[j + 1][i + 1] = ta;
+            bigmp[j + 1][i + 1] = tp;
+        }
+    }
+
+    for (j = 0; j < floor_ptr->height; ++j) {
+        for (i = 0; i < floor_ptr->width; ++i) {
+            x = i / xrat + 1;
+            y = j / yrat + 1;
+
+            tc = bigmc[j + 1][i + 1];
+            ta = bigma[j + 1][i + 1];
+            tp = bigmp[j + 1][i + 1];
+            if (mp[y][x] == tp) {
+                int t;
+                int cnt = 0;
+
+                for (t = 0; t < 8; t++) {
+                    if (tc == bigmc[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]] && ta == bigma[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]])
+                        cnt++;
+                }
+                if (cnt <= 4)
+                    tp++;
+            }
+
+            if (mp[y][x] < tp) {
+                mc[y][x] = tc;
+                ma[y][x] = ta;
+                mp[y][x] = tp;
+            }
+        }
+    }
+
+    x = wid + 1;
+    y = hgt + 1;
+
+    mc[0][0] = mc[0][x] = mc[y][0] = mc[y][x] = '+';
+    for (x = 1; x <= wid; x++)
+        mc[0][x] = mc[y][x] = '-';
+
+    for (y = 1; y <= hgt; y++)
+        mc[y][0] = mc[y][x] = '|';
+
+    for (y = 0; y < hgt + 2; ++y) {
+        Term_gotoxy(COL_MAP, y);
+        for (x = 0; x < wid + 2; ++x) {
+            ta = ma[y][x];
+            tc = mc[y][x];
+            if (!use_graphics) {
+                if (current_world_ptr->timewalk_m_idx)
+                    ta = TERM_DARK;
+                else if (is_invuln(player_ptr) || player_ptr->timewalk)
+                    ta = TERM_WHITE;
+                else if (player_ptr->wraith_form)
+                    ta = TERM_L_DARK;
+            }
+
+            Term_add_bigch(ta, tc);
+        }
+    }
+
+    for (y = 1; y < hgt + 1; ++y) {
+        match_autopick = -1;
+        for (x = 1; x <= wid; x++) {
+            if (match_autopick_yx[y][x] != -1 && (match_autopick > match_autopick_yx[y][x] || match_autopick == -1)) {
+                match_autopick = match_autopick_yx[y][x];
+                autopick_obj = object_autopick_yx[y][x];
+            }
+        }
+
+        Term_putstr(0, y, 12, 0, "            ");
+        if (match_autopick != -1)
+            display_shortened_item_name(player_ptr, autopick_obj, y);
+    }
+
+    (*cy) = player_ptr->y / yrat + 1 + ROW_MAP;
+    if (!use_bigtile)
+        (*cx) = player_ptr->x / xrat + 1 + COL_MAP;
+    else
+        (*cx) = (player_ptr->x / xrat + 1) * 2 + COL_MAP;
+
+    view_special_lite = old_view_special_lite;
+    view_granite_lite = old_view_granite_lite;
+
+    for (y = 0; y < (hgt + 2); y++) {
+        C_KILL(ma[y], (wid + 2), TERM_COLOR);
+        C_KILL(mc[y], (wid + 2), SYMBOL_CODE);
+        C_KILL(mp[y], (wid + 2), byte);
+        C_KILL(match_autopick_yx[y], (wid + 2), int);
+        C_KILL(object_autopick_yx[y], (wid + 2), object_type *);
+    }
+
+    C_KILL(ma, (hgt + 2), TERM_COLOR *);
+    C_KILL(mc, (hgt + 2), char_ptr);
+    C_KILL(mp, (hgt + 2), byte_ptr);
+    C_KILL(match_autopick_yx, (hgt + 2), int *);
+    C_KILL(object_autopick_yx, (hgt + 2), object_type **);
+    for (y = 0; y < (floor_ptr->height + 2); y++) {
+        C_KILL(bigma[y], (floor_ptr->width + 2), TERM_COLOR);
+        C_KILL(bigmc[y], (floor_ptr->width + 2), SYMBOL_CODE);
+        C_KILL(bigmp[y], (floor_ptr->width + 2), byte);
+    }
+
+    C_KILL(bigma, (floor_ptr->height + 2), TERM_COLOR *);
+    C_KILL(bigmc, (floor_ptr->height + 2), char_ptr);
+    C_KILL(bigmp, (floor_ptr->height + 2), byte_ptr);
+}
+
+void set_term_color(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp)
+{
+    if (!player_bold(player_ptr, y, x))
+        return;
+
+    monster_race *r_ptr = &r_info[0];
+    *ap = r_ptr->x_attr;
+    *cp = r_ptr->x_char;
+    feat_priority = 31;
+}
index f4cf472..9cf5cdd 100644 (file)
@@ -2,4 +2,20 @@
 
 #include "system/angband.h"
 
+#define ROW_MAP 0
+#define COL_MAP 12
+
+extern POSITION panel_row_min;
+extern POSITION panel_row_max;
+extern POSITION panel_col_min;
+extern POSITION panel_col_max;
+extern POSITION panel_col_prt;
+extern POSITION panel_row_prt;
+extern int match_autopick;
+extern object_type *autopick_obj;
+extern int feat_priority;
+
 void print_field(concptr info, TERM_LEN row, TERM_LEN col);
+void print_map(player_type *player_ptr);
+void display_map(player_type *player_ptr, int *cy, int *cx);
+void set_term_color(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp);