OSDN Git Service

[Refactor] #40483 Separated cursor.c/h from display-main-window.c/h
authorHourier <hourier@users.sourceforge.jp>
Sat, 27 Jun 2020 06:37:08 +0000 (15:37 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 27 Jun 2020 06:37:08 +0000 (15:37 +0900)
19 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd-action/cmd-pet.c
src/cmd-item/cmd-item.c
src/cmd/cmd-basic.c
src/combat/shoot.c
src/core/player-processor.c
src/dungeon/dungeon-processor.c
src/io/cursor.c [new file with mode: 0644]
src/io/cursor.h [new file with mode: 0644]
src/io/input-key-requester.c
src/io/targeting.c
src/mind/mind-mirror-master.c
src/spell-kind/spells-genocide.c
src/spell-kind/spells-sight.c
src/spell/process-effect.c
src/view/display-main-window.c
src/view/display-main-window.h

index 249e673..0001719 100644 (file)
     <ClCompile Include="..\..\src\info-reader\skill-reader.c" />\r
     <ClCompile Include="..\..\src\info-reader\vault-reader.c" />\r
     <ClCompile Include="..\..\src\io\command-repeater.c" />\r
+    <ClCompile Include="..\..\src\io\cursor.c" />\r
     <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
     <ClInclude Include="..\..\src\info-reader\skill-reader.h" />\r
     <ClInclude Include="..\..\src\info-reader\vault-reader.h" />\r
     <ClInclude Include="..\..\src\io\command-repeater.h" />\r
+    <ClInclude Include="..\..\src\io\cursor.h" />\r
     <ClInclude Include="..\..\src\io\input-key-acceptor.h" />\r
     <ClInclude Include="..\..\src\io\input-key-requester.h" />\r
     <ClInclude Include="..\..\src\locale\language-switcher.h" />\r
index 91e7273..e12b547 100644 (file)
     <ClCompile Include="..\..\src\grid\lighting-colors-table.c">
       <Filter>grid</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\io\cursor.c">
+      <Filter>io</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\grid\lighting-colors-table.h">
       <Filter>grid</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\io\cursor.h">
+      <Filter>io</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index ede60e7..3be1bdd 100644 (file)
@@ -211,6 +211,7 @@ hengband_SOURCES = \
        \
        io/chuukei.c io/chuukei.h \
        io/command-repeater.c io/command-repeater.h \
+       io/cursor.c io/cursor.h \
        io/exit-panic.c io/exit-panic.h \
        io/files-util.c io/files-util.h \
        io/gf-descriptions.c io/gf-descriptions.h \
index 0bd29cf..9635b3f 100644 (file)
@@ -3,7 +3,6 @@
 #include "cmd-io/cmd-dump.h"
 #include "cmd/cmd-basic.h"
 #include "core/asking-player.h"
-#include "util/sort.h"
 #include "core/stuff-handler.h"
 #include "effect/spells-effect-util.h"
 #include "floor/floor.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "io/command-repeater.h"
+#include "io/cursor.h"
 #include "io/input-key-acceptor.h"
 #include "io/input-key-requester.h"
 #include "io/targeting.h"
 #include "io/write-diary.h"
 #include "main/sound-of-music.h"
+#include "monster-floor/monster-object.h"
+#include "monster-floor/monster-remover.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-flags1.h"
 #include "monster-race/race-flags7.h"
 #include "monster/monster-describer.h"
 #include "monster/monster-description-types.h"
 #include "monster/monster-info.h"
-#include "monster-floor/monster-object.h"
-#include "monster-floor/monster-remover.h"
 #include "monster/monster-status.h"
 #include "monster/smart-learn-types.h"
 #include "object/object-hook.h"
 #include "player/player-move.h"
 #include "player/player-skill.h"
 #include "player/player-status.h"
-#include "view/display-main-window.h"
+#include "term/screen-processor.h"
 #include "util/bit-flags-calculator.h"
 #include "util/int-char-converter.h"
 #include "util/quarks.h"
-#include "term/screen-processor.h"
+#include "util/sort.h"
 #include "view/display-messages.h"
 #include "world/world.h"
 
index 86d63f7..118758d 100644 (file)
@@ -31,6 +31,7 @@
 #include "game-option/keymap-directory-getter.h"
 #include "inventory/inventory-object.h"
 #include "inventory/player-inventory.h"
+#include "io/cursor.h"
 #include "io/input-key-acceptor.h"
 #include "io/input-key-requester.h"
 #include "io/targeting.h"
index 03b0cc2..7d1ca07 100644 (file)
@@ -38,6 +38,7 @@
 #include "info-reader/fixed-map-parser.h"
 #include "inventory/inventory-object.h"
 #include "inventory/player-inventory.h"
+#include "io/cursor.h"
 #include "io/input-key-acceptor.h"
 #include "io/input-key-requester.h"
 #include "io/targeting.h"
index af96bc1..38661ed 100644 (file)
@@ -10,6 +10,7 @@
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "inventory/inventory-object.h"
+#include "io/cursor.h"
 #include "io/targeting.h"
 #include "main/sound-definitions-table.h"
 #include "main/sound-of-music.h"
index 7a1c414..7802404 100644 (file)
@@ -8,6 +8,7 @@
 #include "game-option/map-screen-options.h"
 #include "grid/grid.h"
 #include "inventory/pack-overflow.h"
+#include "io/cursor.h"
 #include "io/input-key-acceptor.h"
 #include "io/input-key-processor.h"
 #include "io/input-key-requester.h"
@@ -32,7 +33,6 @@
 #include "spell-kind/spells-random.h"
 #include "spell-realm/spells-hex.h"
 #include "term/screen-processor.h"
-#include "view/display-main-window.h"
 #include "view/display-messages.h"
 #include "world/world-turn-processor.h"
 
index 4c6cd4e..f3f0fd2 100644 (file)
@@ -10,6 +10,7 @@
 #include "floor/floor-save.h"
 #include "game-option/map-screen-options.h"
 #include "game-option/play-record-options.h"
+#include "io/cursor.h"
 #include "io/input-key-requester.h"
 #include "io/targeting.h"
 #include "io/write-diary.h"
@@ -24,7 +25,6 @@
 #include "player/player-move.h"
 #include "realm/realm-song-numbers.h"
 #include "realm/realm-song.h"
-#include "view/display-main-window.h"
 #include "view/display-messages.h"
 #include "world/world-turn-processor.h"
 #include "world/world.h"
diff --git a/src/io/cursor.c b/src/io/cursor.c
new file mode 100644 (file)
index 0000000..20ef026
--- /dev/null
@@ -0,0 +1,132 @@
+#include "io/cursor.h"
+#include "core/stuff-handler.h"
+#include "effect/effect-characteristics.h"
+#include "effect/spells-effect-util.h"
+#include "floor/floor.h"
+#include "game-option/map-screen-options.h"
+#include "game-option/special-options.h"
+#include "grid/feature.h"
+#include "grid/grid.h"
+#include "io/targeting.h"
+#include "term/term-color-types.h"
+#include "util/bit-flags-calculator.h"
+#include "view/display-main-window.h" // todo 暫定.
+#include "view/display-map.h"
+#include "view/main-window-util.h"
+#include "world/world.h"
+
+/*
+ * Moves the cursor to a given MAP (y,x) location
+ */
+void move_cursor_relative(int row, int col)
+{
+    row -= panel_row_prt;
+    Term_gotoxy(panel_col_of(col), row);
+}
+
+/*
+ * @brief 矢などの軌跡を*で表示する / print project path
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param y 目標地点のY座標
+ * @param x 目標地点のX座標
+ * @return なし
+ */
+void print_path(player_type *player_ptr, POSITION y, POSITION x)
+{
+    int path_n;
+    u16b path_g[512];
+    byte default_color = TERM_SLATE;
+
+    if (!display_path)
+        return;
+    if (project_length == -1)
+        return;
+
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    path_n = project_path(player_ptr, path_g, (project_length ? project_length : MAX_RANGE), player_ptr->y, player_ptr->x, y, x, PROJECT_PATH | PROJECT_THRU);
+    player_ptr->redraw |= (PR_MAP);
+    handle_stuff(player_ptr);
+    for (int i = 0; i < path_n; i++) {
+        POSITION ny = GRID_Y(path_g[i]);
+        POSITION nx = GRID_X(path_g[i]);
+        grid_type *g_ptr = &floor_ptr->grid_array[ny][nx];
+        if (panel_contains(ny, nx)) {
+            TERM_COLOR a = default_color;
+            SYMBOL_CODE c;
+
+            TERM_COLOR ta = default_color;
+            SYMBOL_CODE tc = '*';
+
+            if (g_ptr->m_idx && floor_ptr->m_list[g_ptr->m_idx].ml) {
+                map_info(player_ptr, ny, nx, &a, &c, &ta, &tc);
+
+                if (!is_ascii_graphics(a))
+                    a = default_color;
+                else if (c == '.' && (a == TERM_WHITE || a == TERM_L_WHITE))
+                    a = default_color;
+                else if (a == default_color)
+                    a = TERM_WHITE;
+            }
+
+            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;
+            }
+
+            c = '*';
+            Term_queue_bigchar(panel_col_of(nx), ny - panel_row_prt, a, c, ta, tc);
+        }
+
+        if ((g_ptr->info & CAVE_MARK) && !cave_have_flag_grid(g_ptr, FF_PROJECT))
+            break;
+
+        if (nx == x && ny == y)
+            default_color = TERM_L_DARK;
+    }
+}
+
+/*!
+ * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param dy 変更先のフロアY座標
+ * @param dx 変更先のフロアX座標
+ * Handle a request to change the current panel
+ * Return TRUE if the panel was changed.
+ * Also used in do_cmd_locate
+ * @return 実際に再描画が必要だった場合TRUEを返す
+ */
+bool change_panel(player_type *player_ptr, POSITION dy, POSITION dx)
+{
+    TERM_LEN wid, hgt;
+    get_screen_size(&wid, &hgt);
+
+    POSITION y = panel_row_min + dy * hgt / 2;
+    POSITION x = panel_col_min + dx * wid / 2;
+
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    if (y > floor_ptr->height - hgt)
+        y = floor_ptr->height - hgt;
+    if (y < 0)
+        y = 0;
+
+    if (x > floor_ptr->width - wid)
+        x = floor_ptr->width - wid;
+    if (x < 0)
+        x = 0;
+
+    if ((y == panel_row_min) && (x == panel_col_min))
+        return FALSE;
+
+    panel_row_min = y;
+    panel_col_min = x;
+    panel_bounds_center();
+
+    player_ptr->update |= (PU_MONSTERS);
+    player_ptr->redraw |= (PR_MAP);
+    handle_stuff(player_ptr);
+    return TRUE;
+}
diff --git a/src/io/cursor.h b/src/io/cursor.h
new file mode 100644 (file)
index 0000000..6b03e32
--- /dev/null
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "system/angband.h"
+
+void move_cursor_relative(int row, int col);
+void print_path(player_type *player_ptr, POSITION y, POSITION x);
+bool change_panel(player_type *player_ptr, POSITION dy, POSITION dx);
index dbdb0b6..d868171 100644 (file)
@@ -4,13 +4,13 @@
 #include "core/asking-player.h" // todo 相互依存している、後で何とかする.
 #include "floor/floor.h"
 #include "game-option/input-options.h"
+#include "io/cursor.h"
 #include "io/input-key-acceptor.h"
 #include "main/sound-of-music.h"
 #include "term/screen-processor.h" // todo 相互依存している、後で何とかする.
 #include "util/int-char-converter.h"
 #include "util/quarks.h"
 #include "util/string-processor.h"
-#include "view/display-main-window.h" // todo move_cursor_relative() が依存している。後で移設を検討する.
 #include "view/display-messages.h"
 #include "view/main-window-util.h"
 
index 9808177..1f37076 100644 (file)
@@ -33,6 +33,7 @@
 #include "grid/grid.h"
 #include "inventory/player-inventory.h"
 #include "io/command-repeater.h"
+#include "io/cursor.h"
 #include "io/input-key-acceptor.h"
 #include "io/input-key-requester.h"
 #include "locale/vowel-checker.h"
index 3daf55d..ce228b8 100644 (file)
@@ -8,6 +8,7 @@
 #include "floor/floor.h"
 #include "game-option/special-options.h"
 #include "grid/feature.h"
+#include "io/cursor.h"
 #include "io/targeting.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
index b8516ec..7d9ee1e 100644 (file)
@@ -6,6 +6,7 @@
 #include "game-option/play-record-options.h"
 #include "game-option/special-options.h"
 #include "grid/grid.h"
+#include "io/cursor.h"
 #include "io/write-diary.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-flags1.h"
@@ -19,7 +20,6 @@
 #include "monster/monster-status.h"
 #include "player/avatar.h"
 #include "player/player-damage.h"
-#include "view/display-main-window.h"
 #include "view/display-messages.h"
 
 /*!
index 20ab277..9d68de7 100644 (file)
@@ -4,6 +4,7 @@
 #include "floor/floor.h"
 #include "game-option/birth-options.h"
 #include "grid/grid.h"
+#include "io/cursor.h"
 #include "io/input-key-acceptor.h"
 #include "locale/english.h"
 #include "lore/lore-store.h"
@@ -19,7 +20,6 @@
 #include "spell/process-effect.h"
 #include "spell/spell-types.h"
 #include "term/screen-processor.h"
-#include "view/display-main-window.h"
 #include "view/display-messages.h"
 
 /*!
index 088197b..bd925f1 100644 (file)
@@ -9,6 +9,7 @@
 #include "floor/floor.h"
 #include "game-option/special-options.h"
 #include "grid/feature.h"
+#include "io/cursor.h"
 #include "main/sound-definitions-table.h"
 #include "main/sound-of-music.h"
 #include "monster-race/monster-race.h"
index 4711c47..918a506 100644 (file)
@@ -22,6 +22,7 @@
 #include "game-option/special-options.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
+#include "io/cursor.h"
 #include "io/input-key-acceptor.h"
 #include "io/targeting.h"
 #include "monster/monster-update.h"
@@ -67,48 +68,6 @@ void resize_map()
 }
 
 /*!
- * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
- * @param creature_ptr プレーヤーへの参照ポインタ
- * @param dy 変更先のフロアY座標
- * @param dx 変更先のフロアX座標
- * Handle a request to change the current panel
- * Return TRUE if the panel was changed.
- * Also used in do_cmd_locate
- * @return 実際に再描画が必要だった場合TRUEを返す
- */
-bool change_panel(player_type *player_ptr, POSITION dy, POSITION dx)
-{
-    TERM_LEN wid, hgt;
-    get_screen_size(&wid, &hgt);
-
-    POSITION y = panel_row_min + dy * hgt / 2;
-    POSITION x = panel_col_min + dx * wid / 2;
-
-    floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    if (y > floor_ptr->height - hgt)
-        y = floor_ptr->height - hgt;
-    if (y < 0)
-        y = 0;
-
-    if (x > floor_ptr->width - wid)
-        x = floor_ptr->width - wid;
-    if (x < 0)
-        x = 0;
-
-    if ((y == panel_row_min) && (x == panel_col_min))
-        return FALSE;
-
-    panel_row_min = y;
-    panel_col_min = x;
-    panel_bounds_center();
-
-    player_ptr->update |= (PU_MONSTERS);
-    player_ptr->redraw |= (PR_MAP);
-    handle_stuff(player_ptr);
-    return TRUE;
-}
-
-/*!
  * @brief 現在のコンソール表示の縦横を返す。 /
  * Get term size and calculate screen size
  * @param wid_p コンソールの表示幅文字数を返す
@@ -125,76 +84,6 @@ void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
 }
 
 /*
- * Moves the cursor to a given MAP (y,x) location
- */
-void move_cursor_relative(int row, int col)
-{
-    row -= panel_row_prt;
-    Term_gotoxy(panel_col_of(col), row);
-}
-
-/*
- * print project path
- */
-void print_path(player_type *player_ptr, POSITION y, POSITION x)
-{
-    int path_n;
-    u16b path_g[512];
-    byte default_color = TERM_SLATE;
-
-    if (!display_path)
-        return;
-    if (project_length == -1)
-        return;
-
-    floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    path_n = project_path(player_ptr, path_g, (project_length ? project_length : MAX_RANGE), player_ptr->y, player_ptr->x, y, x, PROJECT_PATH | PROJECT_THRU);
-    player_ptr->redraw |= (PR_MAP);
-    handle_stuff(player_ptr);
-    for (int i = 0; i < path_n; i++) {
-        POSITION ny = GRID_Y(path_g[i]);
-        POSITION nx = GRID_X(path_g[i]);
-        grid_type *g_ptr = &floor_ptr->grid_array[ny][nx];
-        if (panel_contains(ny, nx)) {
-            TERM_COLOR a = default_color;
-            SYMBOL_CODE c;
-
-            TERM_COLOR ta = default_color;
-            SYMBOL_CODE tc = '*';
-
-            if (g_ptr->m_idx && floor_ptr->m_list[g_ptr->m_idx].ml) {
-                map_info(player_ptr, ny, nx, &a, &c, &ta, &tc);
-
-                if (!is_ascii_graphics(a))
-                    a = default_color;
-                else if (c == '.' && (a == TERM_WHITE || a == TERM_L_WHITE))
-                    a = default_color;
-                else if (a == default_color)
-                    a = TERM_WHITE;
-            }
-
-            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;
-            }
-
-            c = '*';
-            Term_queue_bigchar(panel_col_of(nx), ny - panel_row_prt, a, c, ta, tc);
-        }
-
-        if ((g_ptr->info & CAVE_MARK) && !cave_have_flag_grid(g_ptr, FF_PROJECT))
-            break;
-
-        if (nx == x && ny == y)
-            default_color = TERM_L_DARK;
-    }
-}
-
-/*
  * Determines if a map location is currently "on screen" -RAK-
  * Note that "panel_contains(Y,X)" always implies "in_bounds2(Y,X)".
  */
index 4bc654f..c40f899 100644 (file)
@@ -3,8 +3,5 @@
 #include "system/angband.h"
 
 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p);
-void move_cursor_relative(int row, int col);
-void print_path(player_type *player_ptr, POSITION y, POSITION x);
 void resize_map(void);
-bool change_panel(player_type *player_ptr, POSITION dy, POSITION dx);
 bool panel_contains(POSITION y, POSITION x);