OSDN Git Service

[Refactor] #40483 Separated display-sub-windows.c/h from display-main-window.c/h
authorHourier <hourier@users.sourceforge.jp>
Fri, 26 Jun 2020 14:58:01 +0000 (23:58 +0900)
committerHourier <hourier@users.sourceforge.jp>
Fri, 26 Jun 2020 14:58:01 +0000 (23:58 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/player/player-status.c
src/player/player-status.h
src/view/display-main-window.c
src/view/display-main-window.h
src/view/display-sub-windows.c [new file with mode: 0644]
src/view/display-sub-windows.h [new file with mode: 0644]
src/view/main-window-util.c

index 5387ddf..81f9f73 100644 (file)
     <ClCompile Include="..\..\src\io\input-key-acceptor.c" />\r
     <ClCompile Include="..\..\src\io\input-key-requester.c" />\r
     <ClCompile Include="..\..\src\locale\vowel-checker.c" />\r
+    <ClCompile Include="..\..\src\view\display-sub-windows.c" />\r
     <ClCompile Include="..\..\src\view\main-window-left-frame.c" />\r
     <ClCompile Include="..\..\src\view\main-window-stat-poster.c" />\r
     <ClCompile Include="..\..\src\view\main-window-util.c" />\r
     <ClInclude Include="..\..\src\view\display-lore.h" />\r
     <ClInclude Include="..\..\src\view\display-messages.h" />\r
     <ClInclude Include="..\..\src\view\display-monster-status.h" />\r
+    <ClInclude Include="..\..\src\view\display-sub-windows.h" />\r
     <ClInclude Include="..\..\src\view\main-window-left-frame.h" />\r
     <ClInclude Include="..\..\src\view\main-window-row-column.h" />\r
     <ClInclude Include="..\..\src\view\main-window-stat-poster.h" />\r
index 3c01908..833b12e 100644 (file)
     <ClCompile Include="..\..\src\view\main-window-left-frame.c">
       <Filter>view</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\view\display-sub-windows.c">
+      <Filter>view</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\view\main-window-left-frame.h">
       <Filter>view</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\view\display-sub-windows.h">
+      <Filter>view</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index ee3628d..5949885 100644 (file)
@@ -573,6 +573,7 @@ hengband_SOURCES = \
        \
        view/display-birth.c view/display-birth.h \
        view/display-characteristic.c view/display-characteristic.h \
+       view/display-sub-windows.c view/display-sub-windows.h \
        view/display-fruit.c view/display-fruit.h \
        view/display-lore-attacks.c view/display-lore-attacks.h \
        view/display-lore-drops.c view/display-lore-drops.h \
index fe31cd7..8903030 100644 (file)
@@ -1319,6 +1319,17 @@ static void clear_creature_bonuses(player_type *creature_ptr)
 }
 
 /*!
+ * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
+ * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
+ * @return 重すぎるならばTRUE
+ */
+static bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
+{
+    int hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
+    return (hold < o_ptr->weight / 10);
+}
+
+/*!
  * @brief プレイヤーの全ステータスを更新する /
  * Calculate the players current "state", taking into account
  * not only race/class intrinsics, but also objects being worn
index e319e31..05e27f3 100644 (file)
@@ -775,7 +775,6 @@ extern s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr);
 extern void calc_bonuses(player_type *creature_ptr);
 extern WEIGHT weight_limit(player_type *creature_ptr);
 extern bool has_melee_weapon(player_type *creature_ptr, int i);
-extern bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr);
 
 extern bool heavy_armor(player_type *creature_ptr);
 extern void update_creature(player_type *creature_ptr);
index 7833b35..fb39dfe 100644 (file)
 #include "game-option/option-flags.h"
 #include "game-option/special-options.h"
 #include "grid/grid.h"
-#include "inventory/player-inventory.h"
 #include "io/input-key-acceptor.h"
-#include "io/input-key-processor.h"
 #include "io/targeting.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-flags1.h"
 #include "monster-race/race-flags2.h"
-#include "monster/monster-flag-types.h"
-#include "monster/monster-info.h"
 #include "monster/monster-update.h"
 #include "object/object-info.h"
 #include "object/object-kind.h"
 #include "object/object-mark-types.h"
 #include "player/mimic-info-table.h"
-#include "spell/spells3.h"
 #include "term/gameterm.h"
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
 #include "util/bit-flags-calculator.h"
-#include "view/display-lore.h"
 #include "view/display-messages.h"
 #include "view/display-player.h"
+#include "view/display-sub-windows.h" // todo 相互依存している、後で何とかする.
 #include "view/main-window-left-frame.h"
 #include "view/main-window-row-column.h"
 #include "view/main-window-stat-poster.h"
-#include "view/main-window-util.h"
-#include "view/object-describer.h"
+#include "view/main-window-util.h" // 相互依存している。後で何とかする.
 #include "world/world.h"
 
 /*
@@ -101,411 +95,6 @@ concptr map_name(player_type *creature_ptr)
 }
 
 /*!
- * @brief サブウィンドウに所持品一覧を表示する / Hack -- display inventory in sub-windows
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return なし
- */
-static void fix_inventory(player_type *player_ptr, tval_type item_tester_tval)
-{
-    for (int j = 0; j < 8; j++) {
-        term *old = Term;
-        if (!angband_term[j])
-            continue;
-
-        if (!(window_flag[j] & (PW_INVEN)))
-            continue;
-
-        Term_activate(angband_term[j]);
-        display_inventory(player_ptr, item_tester_tval);
-        Term_fresh();
-        Term_activate(old);
-    }
-}
-
-/*!
- * @brief モンスターの現在数を一行で表現する / Print monster info in line
- * @param x 表示列
- * @param y 表示行
- * @param m_ptr 思い出を表示するモンスター情報の参照ポインタ
- * @param n_same モンスターの数の現在数
- * @details
- * <pre>
- * nnn X LV name
- *  nnn : number or unique(U) or wanted unique(W)
- *  X   : symbol of monster
- *  LV  : monster lv if known
- *  name: name of monster
- * @return なし
- * </pre>
- */
-static void print_monster_line(TERM_LEN x, TERM_LEN y, monster_type *m_ptr, int n_same)
-{
-    char buf[256];
-    MONRACE_IDX r_idx = m_ptr->ap_r_idx;
-    monster_race *r_ptr = &r_info[r_idx];
-
-    Term_gotoxy(x, y);
-    if (!r_ptr)
-        return;
-    if (r_ptr->flags1 & RF1_UNIQUE) {
-        bool is_bounty = FALSE;
-        for (int i = 0; i < MAX_BOUNTY; i++) {
-            if (current_world_ptr->bounty_r_idx[i] == r_idx) {
-                is_bounty = TRUE;
-                break;
-            }
-        }
-
-        Term_addstr(-1, TERM_WHITE, is_bounty ? "  W" : "  U");
-    } else {
-        sprintf(buf, "%3d", n_same);
-        Term_addstr(-1, TERM_WHITE, buf);
-    }
-
-    Term_addstr(-1, TERM_WHITE, " ");
-    Term_add_bigch(r_ptr->x_attr, r_ptr->x_char);
-
-    if (r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE)) {
-        sprintf(buf, " %2d", (int)r_ptr->level);
-    } else {
-        strcpy(buf, " ??");
-    }
-
-    Term_addstr(-1, TERM_WHITE, buf);
-
-    sprintf(buf, " %s ", r_name + r_ptr->name);
-    Term_addstr(-1, TERM_WHITE, buf);
-}
-
-/*!
- * @brief モンスターの出現リストを表示する / Print monster info in line
- * @param x 表示列
- * @param y 表示行
- * @param max_lines 最大何行描画するか
- */
-void print_monster_list(floor_type *floor_ptr, TERM_LEN x, TERM_LEN y, TERM_LEN max_lines)
-{
-    TERM_LEN line = y;
-    monster_type *last_mons = NULL;
-    monster_type *m_ptr = NULL;
-    int n_same = 0;
-    int i;
-    for (i = 0; i < tmp_pos.n; i++) {
-        grid_type *g_ptr = &floor_ptr->grid_array[tmp_pos.y[i]][tmp_pos.x[i]];
-        if (!g_ptr->m_idx || !floor_ptr->m_list[g_ptr->m_idx].ml)
-            continue;
-        m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
-        if (is_pet(m_ptr))
-            continue; // pet
-        if (!m_ptr->r_idx)
-            continue; // dead?
-
-        //ソート済みなので同じモンスターは連続する.これを利用して同じモンスターをカウント,まとめて表示する.
-        //先頭モンスター
-        if (!last_mons) {
-            last_mons = m_ptr;
-            n_same = 1;
-            continue;
-        }
-
-        // same race?
-        if (last_mons->ap_r_idx == m_ptr->ap_r_idx) {
-            n_same++;
-            continue; //表示処理を次に回す
-        }
-
-        // print last mons info
-        print_monster_line(x, line++, last_mons, n_same);
-        n_same = 1;
-        last_mons = m_ptr;
-        if (line - y - 1 == max_lines)
-            break;
-    }
-
-    if (line - y - 1 == max_lines && i != tmp_pos.n) {
-        Term_gotoxy(x, line);
-        Term_addstr(-1, TERM_WHITE, "-- and more --");
-    } else {
-        if (last_mons)
-            print_monster_line(x, line++, last_mons, n_same);
-    }
-}
-
-/*!
- * @brief 出現中モンスターのリストをサブウィンドウに表示する / Hack -- display monster list in sub-windows
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return なし
- */
-static void fix_monster_list(player_type *player_ptr)
-{
-    for (int j = 0; j < 8; j++) {
-        term *old = Term;
-        if (!angband_term[j])
-            continue;
-        if (!(window_flag[j] & (PW_MONSTER_LIST)))
-            continue;
-
-        Term_activate(angband_term[j]);
-        int w, h;
-        Term_get_size(&w, &h);
-        Term_clear();
-        target_set_prepare_look(player_ptr);
-        print_monster_list(player_ptr->current_floor_ptr, 0, 0, h);
-        Term_fresh();
-        Term_activate(old);
-    }
-}
-
-/*!
- * @brief 現在の装備品をサブウィンドウに表示する /
- * Hack -- display equipment in sub-windows
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return なし
- */
-static void fix_equip(player_type *player_ptr, tval_type item_tester_tval)
-{
-    for (int j = 0; j < 8; j++) {
-        term *old = Term;
-        if (!angband_term[j])
-            continue;
-        if (!(window_flag[j] & (PW_EQUIP)))
-            continue;
-
-        Term_activate(angband_term[j]);
-        display_equipment(player_ptr, item_tester_tval);
-        Term_fresh();
-        Term_activate(old);
-    }
-}
-
-/*!
- * @brief 現在の習得済魔法をサブウィンドウに表示する /
- * @param player_ptr プレーヤーへの参照ポインタ
- * Hack -- display spells in sub-windows
- * @return なし
- */
-static void fix_spell(player_type *player_ptr)
-{
-    for (int j = 0; j < 8; j++) {
-        term *old = Term;
-        if (!angband_term[j])
-            continue;
-
-        if (!(window_flag[j] & (PW_SPELL)))
-            continue;
-
-        Term_activate(angband_term[j]);
-        display_spell_list(player_ptr);
-        Term_fresh();
-        Term_activate(old);
-    }
-}
-
-/*!
- * @brief 現在のプレイヤーステータスをサブウィンドウに表示する /
- * @param player_ptr プレーヤーへの参照ポインタ
- * Hack -- display character in sub-windows
- * @return なし
- */
-static void fix_player(player_type *player_ptr)
-{
-    for (int j = 0; j < 8; j++) {
-        term *old = Term;
-        if (!angband_term[j])
-            continue;
-
-        if (!(window_flag[j] & (PW_PLAYER)))
-            continue;
-
-        Term_activate(angband_term[j]);
-        update_playtime();
-        display_player(player_ptr, 0, map_name);
-        Term_fresh();
-        Term_activate(old);
-    }
-}
-
-/*!
- * @brief ゲームメッセージ履歴をサブウィンドウに表示する /
- * Hack -- display recent messages in sub-windows
- * Adjust for width and split messages
- * @return なし
- */
-static void fix_message(void)
-{
-    for (int j = 0; j < 8; j++) {
-        term *old = Term;
-        if (!angband_term[j])
-            continue;
-
-        if (!(window_flag[j] & (PW_MESSAGE)))
-            continue;
-
-        Term_activate(angband_term[j]);
-        TERM_LEN w, h;
-        Term_get_size(&w, &h);
-        for (int i = 0; i < h; i++) {
-            Term_putstr(0, (h - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), message_str((s16b)i));
-            TERM_LEN x, y;
-            Term_locate(&x, &y);
-            Term_erase(x, y, 255);
-        }
-
-        Term_fresh();
-        Term_activate(old);
-    }
-}
-
-/*!
- * @brief 簡易マップをサブウィンドウに表示する /
- * Hack -- display overhead view in sub-windows
- * Adjust for width and split messages
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return なし
- * @details
- * Note that the "player" symbol does NOT appear on the map.
- */
-static void fix_overhead(player_type *player_ptr)
-{
-    for (int j = 0; j < 8; j++) {
-        term *old = Term;
-        TERM_LEN wid, hgt;
-        if (!angband_term[j])
-            continue;
-
-        if (!(window_flag[j] & (PW_OVERHEAD)))
-            continue;
-
-        Term_activate(angband_term[j]);
-        Term_get_size(&wid, &hgt);
-        if (wid > COL_MAP + 2 && hgt > ROW_MAP + 2) {
-            int cy, cx;
-            display_map(player_ptr, &cy, &cx);
-            Term_fresh();
-        }
-
-        Term_activate(old);
-    }
-}
-
-static void display_dungeon(player_type *player_ptr)
-{
-    TERM_COLOR ta = 0;
-    SYMBOL_CODE tc = '\0';
-
-    for (TERM_LEN x = player_ptr->x - Term->wid / 2 + 1; x <= player_ptr->x + Term->wid / 2; x++) {
-        for (TERM_LEN y = player_ptr->y - Term->hgt / 2 + 1; y <= player_ptr->y + Term->hgt / 2; y++) {
-            TERM_COLOR a;
-            SYMBOL_CODE c;
-            if (!in_bounds2(player_ptr->current_floor_ptr, y, x)) {
-                feature_type *f_ptr = &f_info[feat_none];
-                a = f_ptr->x_attr[F_LIT_STANDARD];
-                c = f_ptr->x_char[F_LIT_STANDARD];
-                Term_queue_char(x - player_ptr->x + Term->wid / 2 - 1, y - player_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
-                continue;
-            }
-
-            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_char(x - player_ptr->x + Term->wid / 2 - 1, y - player_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
-        }
-    }
-}
-
-/*!
- * @brief ダンジョンの地形をサブウィンドウに表示する /
- * Hack -- display dungeon view in sub-windows
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return なし
- */
-static void fix_dungeon(player_type *player_ptr)
-{
-    for (int j = 0; j < 8; j++) {
-        term *old = Term;
-        if (!angband_term[j])
-            continue;
-
-        if (!(window_flag[j] & (PW_DUNGEON)))
-            continue;
-
-        Term_activate(angband_term[j]);
-        display_dungeon(player_ptr);
-        Term_fresh();
-        Term_activate(old);
-    }
-}
-
-/*!
- * @brief モンスターの思い出をサブウィンドウに表示する /
- * Hack -- display dungeon view in sub-windows
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return なし
- */
-static void fix_monster(player_type *player_ptr)
-{
-    for (int j = 0; j < 8; j++) {
-        term *old = Term;
-        if (!angband_term[j])
-            continue;
-
-        if (!(window_flag[j] & (PW_MONSTER)))
-            continue;
-
-        Term_activate(angband_term[j]);
-        if (player_ptr->monster_race_idx)
-            display_roff(player_ptr);
-
-        Term_fresh();
-        Term_activate(old);
-    }
-}
-
-/*!
- * @brief ベースアイテム情報をサブウィンドウに表示する /
- * Hack -- display object recall in sub-windows
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return なし
- */
-static void fix_object(player_type *player_ptr)
-{
-    for (int j = 0; j < 8; j++) {
-        term *old = Term;
-        if (!angband_term[j])
-            continue;
-
-        if (!(window_flag[j] & (PW_OBJECT)))
-            continue;
-
-        Term_activate(angband_term[j]);
-        if (player_ptr->object_kind_idx)
-            display_koff(player_ptr, player_ptr->object_kind_idx);
-
-        Term_fresh();
-        Term_activate(old);
-    }
-}
-
-/*!
- * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
- * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
- * @return 重すぎるならばTRUE
- */
-bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
-{
-    int hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
-    return (hold < o_ptr->weight / 10);
-}
-
-/*!
  * @brief 現在のマップ名を描画する / Print dungeon
  * @param creature_ptr プレーヤーへの参照ポインタ
  * @return なし
index 663e5f6..1fe1db1 100644 (file)
@@ -12,7 +12,6 @@ extern void do_cmd_view_map(player_type *player_ptr);
 extern void health_track(player_type *player_ptr, MONSTER_IDX m_idx);
 extern void print_time(player_type *player_ptr);
 extern concptr map_name(player_type *creature_ptr);
-extern void print_monster_list(floor_type *floor_ptr, TERM_LEN x, TERM_LEN y, TERM_LEN max_lines);
 extern void move_cursor_relative(int row, int col);
 extern void print_path(player_type *player_ptr, POSITION y, POSITION x);
 extern void monster_race_track(player_type *player_ptr, MONRACE_IDX r_idx);
diff --git a/src/view/display-sub-windows.c b/src/view/display-sub-windows.c
new file mode 100644 (file)
index 0000000..9508d4e
--- /dev/null
@@ -0,0 +1,417 @@
+#include "view/display-sub-windows.h"
+#include "floor/floor.h"
+#include "game-option/option-flags.h"
+#include "game-option/special-options.h"
+#include "grid/grid.h"
+#include "inventory/player-inventory.h"
+#include "io/input-key-processor.h"
+#include "io/targeting.h"
+#include "monster-race/monster-race.h"
+#include "monster-race/race-flags1.h"
+#include "monster/monster-flag-types.h"
+#include "monster/monster-info.h"
+#include "spell/spells3.h"
+#include "system/monster-type-definition.h"
+#include "term/gameterm.h"
+#include "term/term-color-types.h"
+#include "view/display-main-window.h" // todo 相互依存している、後で何とかする.
+#include "view/display-messages.h"
+#include "view/display-lore.h"
+#include "view/display-player.h"
+#include "view/main-window-util.h"
+#include "view/object-describer.h"
+#include "world/world.h"
+
+/*!
+ * @brief サブウィンドウに所持品一覧を表示する / Hack -- display inventory in sub-windows
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
+void fix_inventory(player_type *player_ptr, tval_type item_tester_tval)
+{
+    for (int j = 0; j < 8; j++) {
+        term *old = Term;
+        if (!angband_term[j])
+            continue;
+
+        if (!(window_flag[j] & (PW_INVEN)))
+            continue;
+
+        Term_activate(angband_term[j]);
+        display_inventory(player_ptr, item_tester_tval);
+        Term_fresh();
+        Term_activate(old);
+    }
+}
+
+/*!
+ * @brief モンスターの現在数を一行で表現する / Print monster info in line
+ * @param x 表示列
+ * @param y 表示行
+ * @param m_ptr 思い出を表示するモンスター情報の参照ポインタ
+ * @param n_same モンスターの数の現在数
+ * @details
+ * <pre>
+ * nnn X LV name
+ *  nnn : number or unique(U) or wanted unique(W)
+ *  X   : symbol of monster
+ *  LV  : monster lv if known
+ *  name: name of monster
+ * @return なし
+ * </pre>
+ */
+static void print_monster_line(TERM_LEN x, TERM_LEN y, monster_type *m_ptr, int n_same)
+{
+    char buf[256];
+    MONRACE_IDX r_idx = m_ptr->ap_r_idx;
+    monster_race *r_ptr = &r_info[r_idx];
+
+    Term_gotoxy(x, y);
+    if (!r_ptr)
+        return;
+    if (r_ptr->flags1 & RF1_UNIQUE) {
+        bool is_bounty = FALSE;
+        for (int i = 0; i < MAX_BOUNTY; i++) {
+            if (current_world_ptr->bounty_r_idx[i] == r_idx) {
+                is_bounty = TRUE;
+                break;
+            }
+        }
+
+        Term_addstr(-1, TERM_WHITE, is_bounty ? "  W" : "  U");
+    } else {
+        sprintf(buf, "%3d", n_same);
+        Term_addstr(-1, TERM_WHITE, buf);
+    }
+
+    Term_addstr(-1, TERM_WHITE, " ");
+    Term_add_bigch(r_ptr->x_attr, r_ptr->x_char);
+
+    if (r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE)) {
+        sprintf(buf, " %2d", (int)r_ptr->level);
+    } else {
+        strcpy(buf, " ??");
+    }
+
+    Term_addstr(-1, TERM_WHITE, buf);
+
+    sprintf(buf, " %s ", r_name + r_ptr->name);
+    Term_addstr(-1, TERM_WHITE, buf);
+}
+
+/*!
+ * @brief モンスターの出現リストを表示する / Print monster info in line
+ * @param x 表示列
+ * @param y 表示行
+ * @param max_lines 最大何行描画するか
+ */
+void print_monster_list(floor_type *floor_ptr, TERM_LEN x, TERM_LEN y, TERM_LEN max_lines)
+{
+    TERM_LEN line = y;
+    monster_type *last_mons = NULL;
+    monster_type *m_ptr = NULL;
+    int n_same = 0;
+    int i;
+    for (i = 0; i < tmp_pos.n; i++) {
+        grid_type *g_ptr = &floor_ptr->grid_array[tmp_pos.y[i]][tmp_pos.x[i]];
+        if (!g_ptr->m_idx || !floor_ptr->m_list[g_ptr->m_idx].ml)
+            continue;
+        m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
+        if (is_pet(m_ptr))
+            continue; // pet
+        if (!m_ptr->r_idx)
+            continue; // dead?
+
+        //ソート済みなので同じモンスターは連続する.これを利用して同じモンスターをカウント,まとめて表示する.
+        //先頭モンスター
+        if (!last_mons) {
+            last_mons = m_ptr;
+            n_same = 1;
+            continue;
+        }
+
+        // same race?
+        if (last_mons->ap_r_idx == m_ptr->ap_r_idx) {
+            n_same++;
+            continue; //表示処理を次に回す
+        }
+
+        // print last mons info
+        print_monster_line(x, line++, last_mons, n_same);
+        n_same = 1;
+        last_mons = m_ptr;
+        if (line - y - 1 == max_lines)
+            break;
+    }
+
+    if (line - y - 1 == max_lines && i != tmp_pos.n) {
+        Term_gotoxy(x, line);
+        Term_addstr(-1, TERM_WHITE, "-- and more --");
+    } else {
+        if (last_mons)
+            print_monster_line(x, line++, last_mons, n_same);
+    }
+}
+
+/*!
+ * @brief 出現中モンスターのリストをサブウィンドウに表示する / Hack -- display monster list in sub-windows
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
+void fix_monster_list(player_type *player_ptr)
+{
+    for (int j = 0; j < 8; j++) {
+        term *old = Term;
+        if (!angband_term[j])
+            continue;
+        if (!(window_flag[j] & (PW_MONSTER_LIST)))
+            continue;
+
+        Term_activate(angband_term[j]);
+        int w, h;
+        Term_get_size(&w, &h);
+        Term_clear();
+        target_set_prepare_look(player_ptr);
+        print_monster_list(player_ptr->current_floor_ptr, 0, 0, h);
+        Term_fresh();
+        Term_activate(old);
+    }
+}
+
+/*!
+ * @brief 現在の装備品をサブウィンドウに表示する /
+ * Hack -- display equipment in sub-windows
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
+void fix_equip(player_type *player_ptr, tval_type item_tester_tval)
+{
+    for (int j = 0; j < 8; j++) {
+        term *old = Term;
+        if (!angband_term[j])
+            continue;
+        if (!(window_flag[j] & (PW_EQUIP)))
+            continue;
+
+        Term_activate(angband_term[j]);
+        display_equipment(player_ptr, item_tester_tval);
+        Term_fresh();
+        Term_activate(old);
+    }
+}
+
+/*!
+ * @brief 現在の習得済魔法をサブウィンドウに表示する /
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * Hack -- display spells in sub-windows
+ * @return なし
+ */
+void fix_spell(player_type *player_ptr)
+{
+    for (int j = 0; j < 8; j++) {
+        term *old = Term;
+        if (!angband_term[j])
+            continue;
+
+        if (!(window_flag[j] & (PW_SPELL)))
+            continue;
+
+        Term_activate(angband_term[j]);
+        display_spell_list(player_ptr);
+        Term_fresh();
+        Term_activate(old);
+    }
+}
+
+/*!
+ * @brief 現在のプレイヤーステータスをサブウィンドウに表示する /
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * Hack -- display character in sub-windows
+ * @return なし
+ */
+void fix_player(player_type *player_ptr)
+{
+    for (int j = 0; j < 8; j++) {
+        term *old = Term;
+        if (!angband_term[j])
+            continue;
+
+        if (!(window_flag[j] & (PW_PLAYER)))
+            continue;
+
+        Term_activate(angband_term[j]);
+        update_playtime();
+        display_player(player_ptr, 0, map_name);
+        Term_fresh();
+        Term_activate(old);
+    }
+}
+
+/*!
+ * @brief ゲームメッセージ履歴をサブウィンドウに表示する /
+ * Hack -- display recent messages in sub-windows
+ * Adjust for width and split messages
+ * @return なし
+ */
+void fix_message(void)
+{
+    for (int j = 0; j < 8; j++) {
+        term *old = Term;
+        if (!angband_term[j])
+            continue;
+
+        if (!(window_flag[j] & (PW_MESSAGE)))
+            continue;
+
+        Term_activate(angband_term[j]);
+        TERM_LEN w, h;
+        Term_get_size(&w, &h);
+        for (int i = 0; i < h; i++) {
+            Term_putstr(0, (h - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), message_str((s16b)i));
+            TERM_LEN x, y;
+            Term_locate(&x, &y);
+            Term_erase(x, y, 255);
+        }
+
+        Term_fresh();
+        Term_activate(old);
+    }
+}
+
+/*!
+ * @brief 簡易マップをサブウィンドウに表示する /
+ * Hack -- display overhead view in sub-windows
+ * Adjust for width and split messages
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ * @details
+ * Note that the "player" symbol does NOT appear on the map.
+ */
+void fix_overhead(player_type *player_ptr)
+{
+    for (int j = 0; j < 8; j++) {
+        term *old = Term;
+        TERM_LEN wid, hgt;
+        if (!angband_term[j])
+            continue;
+
+        if (!(window_flag[j] & (PW_OVERHEAD)))
+            continue;
+
+        Term_activate(angband_term[j]);
+        Term_get_size(&wid, &hgt);
+        if (wid > COL_MAP + 2 && hgt > ROW_MAP + 2) {
+            int cy, cx;
+            display_map(player_ptr, &cy, &cx);
+            Term_fresh();
+        }
+
+        Term_activate(old);
+    }
+}
+
+static void display_dungeon(player_type *player_ptr)
+{
+    TERM_COLOR ta = 0;
+    SYMBOL_CODE tc = '\0';
+
+    for (TERM_LEN x = player_ptr->x - Term->wid / 2 + 1; x <= player_ptr->x + Term->wid / 2; x++) {
+        for (TERM_LEN y = player_ptr->y - Term->hgt / 2 + 1; y <= player_ptr->y + Term->hgt / 2; y++) {
+            TERM_COLOR a;
+            SYMBOL_CODE c;
+            if (!in_bounds2(player_ptr->current_floor_ptr, y, x)) {
+                feature_type *f_ptr = &f_info[feat_none];
+                a = f_ptr->x_attr[F_LIT_STANDARD];
+                c = f_ptr->x_char[F_LIT_STANDARD];
+                Term_queue_char(x - player_ptr->x + Term->wid / 2 - 1, y - player_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
+                continue;
+            }
+
+            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_char(x - player_ptr->x + Term->wid / 2 - 1, y - player_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
+        }
+    }
+}
+
+/*!
+ * @brief ダンジョンの地形をサブウィンドウに表示する /
+ * Hack -- display dungeon view in sub-windows
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
+void fix_dungeon(player_type *player_ptr)
+{
+    for (int j = 0; j < 8; j++) {
+        term *old = Term;
+        if (!angband_term[j])
+            continue;
+
+        if (!(window_flag[j] & (PW_DUNGEON)))
+            continue;
+
+        Term_activate(angband_term[j]);
+        display_dungeon(player_ptr);
+        Term_fresh();
+        Term_activate(old);
+    }
+}
+
+/*!
+ * @brief モンスターの思い出をサブウィンドウに表示する /
+ * Hack -- display dungeon view in sub-windows
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
+void fix_monster(player_type *player_ptr)
+{
+    for (int j = 0; j < 8; j++) {
+        term *old = Term;
+        if (!angband_term[j])
+            continue;
+
+        if (!(window_flag[j] & (PW_MONSTER)))
+            continue;
+
+        Term_activate(angband_term[j]);
+        if (player_ptr->monster_race_idx)
+            display_roff(player_ptr);
+
+        Term_fresh();
+        Term_activate(old);
+    }
+}
+
+/*!
+ * @brief ベースアイテム情報をサブウィンドウに表示する /
+ * Hack -- display object recall in sub-windows
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
+void fix_object(player_type *player_ptr)
+{
+    for (int j = 0; j < 8; j++) {
+        term *old = Term;
+        if (!angband_term[j])
+            continue;
+
+        if (!(window_flag[j] & (PW_OBJECT)))
+            continue;
+
+        Term_activate(angband_term[j]);
+        if (player_ptr->object_kind_idx)
+            display_koff(player_ptr, player_ptr->object_kind_idx);
+
+        Term_fresh();
+        Term_activate(old);
+    }
+}
diff --git a/src/view/display-sub-windows.h b/src/view/display-sub-windows.h
new file mode 100644 (file)
index 0000000..bab1f0c
--- /dev/null
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "system/angband.h"
+#include "object/tval-types.h"
+
+void fix_inventory(player_type *player_ptr, tval_type item_tester_tval);
+void print_monster_list(floor_type *floor_ptr, TERM_LEN x, TERM_LEN y, TERM_LEN max_lines);
+void fix_monster_list(player_type *player_ptr);
+void fix_equip(player_type *player_ptr, tval_type item_tester_tval);
+void fix_spell(player_type *player_ptr);
+void fix_player(player_type *player_ptr);
+void fix_message(void);
+void fix_overhead(player_type *player_ptr);
+void fix_dungeon(player_type *player_ptr);
+void fix_monster(player_type *player_ptr);
+void fix_object(player_type *player_ptr);
index 97b9293..0d809f7 100644 (file)
@@ -10,7 +10,7 @@
 #include "term/gameterm.h"
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
-#include "view/display-main-window.h" // 相互依存している。後で何とかする
+#include "view/display-main-window.h" // 相互依存している。後で何とかする.
 #include "world/world.h"
 
 /*