OSDN Git Service

Merge pull request #3569 from sikabane-works/release/3.0.0.88-alpha
[hengbandforosx/hengbandosx.git] / src / io / screen-util.cpp
1 /*!
2  * @brief 画面描画のユーティリティ
3  * @date 2018/09/25
4  * @author
5  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
6  * This software may be copied and distributed for educational, research, and\n
7  * not for profit purposes provided that this copyright and statement are\n
8  * included in all such copies.\n
9  * 2014 Deskull rearranged comment for Doxygen.
10  */
11
12 #include "io/screen-util.h"
13 #include "core/player-processor.h"
14 #include "core/stuff-handler.h"
15 #include "dungeon/quest.h"
16 #include "effect/effect-characteristics.h"
17 #include "effect/spells-effect-util.h"
18 #include "floor/floor-town.h"
19 #include "game-option/map-screen-options.h"
20 #include "game-option/special-options.h"
21 #include "grid/feature.h"
22 #include "grid/grid.h"
23 #include "io/cursor.h"
24 #include "io/input-key-acceptor.h"
25 #include "monster/monster-update.h"
26 #include "player-info/mimic-info-table.h"
27 #include "system/dungeon-info.h"
28 #include "system/floor-type-definition.h"
29 #include "system/player-type-definition.h"
30 #include "system/redrawing-flags-updater.h"
31 #include "target/target-checker.h"
32 #include "term/screen-processor.h"
33 #include "term/term-color-types.h"
34 #include "util/bit-flags-calculator.h"
35 #include "view/display-map.h"
36 #include "window/main-window-row-column.h"
37 #include "window/main-window-util.h"
38 #include "world/world.h"
39
40 /*!
41  * @brief コンソールのリサイズに合わせてマップを再描画する /
42  * Map resizing whenever the main term changes size
43  * @todo ここにPlayerType を追加するとz-termに影響が行くので保留
44  */
45 void resize_map()
46 {
47     if (!w_ptr->character_dungeon) {
48         return;
49     }
50
51     panel_row_max = 0;
52     panel_col_max = 0;
53     panel_row_min = p_ptr->current_floor_ptr->height;
54     panel_col_min = p_ptr->current_floor_ptr->width;
55     verify_panel(p_ptr);
56
57     auto &rfu = RedrawingFlagsUpdater::get_instance();
58     static constexpr auto flags_srf = {
59         StatusRecalculatingFlag::TORCH,
60         StatusRecalculatingFlag::BONUS,
61         StatusRecalculatingFlag::HP,
62         StatusRecalculatingFlag::MP,
63         StatusRecalculatingFlag::SPELLS,
64         StatusRecalculatingFlag::UN_VIEW,
65         StatusRecalculatingFlag::UN_LITE,
66         StatusRecalculatingFlag::VIEW,
67         StatusRecalculatingFlag::LITE,
68         StatusRecalculatingFlag::MONSTER_LITE,
69         StatusRecalculatingFlag::MONSTER_STATUSES,
70     };
71     rfu.set_flags(flags_srf);
72     static constexpr auto flags_mwrf = {
73         MainWindowRedrawingFlag::WIPE,
74         MainWindowRedrawingFlag::BASIC,
75         MainWindowRedrawingFlag::EXTRA,
76         MainWindowRedrawingFlag::MAP,
77         MainWindowRedrawingFlag::EQUIPPY,
78     };
79     rfu.set_flags(flags_mwrf);
80     handle_stuff(p_ptr);
81     term_redraw();
82
83     if (can_save) {
84         move_cursor_relative(p_ptr->y, p_ptr->x);
85     }
86
87     term_fresh();
88 }
89
90 /*!
91  * @brief 現在のコンソール表示の縦横を返す
92  */
93 std::pair<int, int> get_screen_size()
94 {
95     auto [width, height] = term_get_size();
96     height -= ROW_MAP + 2;
97     width -= COL_MAP + 2;
98     if (use_bigtile) {
99         width /= 2;
100     }
101
102     return { width, height };
103 }
104
105 /*
106  * Determines if a map location is currently "on screen" -RAK-
107  * Note that "panel_contains(Y,X)" always implies "in_bounds2(Y,X)".
108  */
109 bool panel_contains(int y, int x)
110 {
111     return (y >= panel_row_min) && (y <= panel_row_max) && (x >= panel_col_min) && (x <= panel_col_max);
112 }