OSDN Git Service

bcacb57b06d87da09da506f68100fc8c67e5ddae
[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/player-redraw-types.h"
15 #include "core/stuff-handler.h"
16 #include "dungeon/quest.h"
17 #include "effect/effect-characteristics.h"
18 #include "effect/spells-effect-util.h"
19 #include "floor/floor-town.h"
20 #include "game-option/map-screen-options.h"
21 #include "game-option/special-options.h"
22 #include "grid/feature.h"
23 #include "grid/grid.h"
24 #include "io/cursor.h"
25 #include "io/input-key-acceptor.h"
26 #include "monster/monster-update.h"
27 #include "player-info/mimic-info-table.h"
28 #include "system/dungeon-info.h"
29 #include "system/floor-type-definition.h"
30 #include "system/player-type-definition.h"
31 #include "system/redrawing-flags-updater.h"
32 #include "target/target-checker.h"
33 #include "term/screen-processor.h"
34 #include "term/term-color-types.h"
35 #include "util/bit-flags-calculator.h"
36 #include "view/display-map.h"
37 #include "window/main-window-row-column.h"
38 #include "window/main-window-util.h"
39 #include "world/world.h"
40
41 /*!
42  * @brief コンソールのリサイズに合わせてマップを再描画する /
43  * Map resizing whenever the main term changes size
44  * @todo ここにPlayerType を追加するとz-termに影響が行くので保留
45  */
46 void resize_map()
47 {
48     if (!w_ptr->character_dungeon) {
49         return;
50     }
51
52     panel_row_max = 0;
53     panel_col_max = 0;
54     panel_row_min = p_ptr->current_floor_ptr->height;
55     panel_col_min = p_ptr->current_floor_ptr->width;
56     verify_panel(p_ptr);
57
58     auto &rfu = RedrawingFlagsUpdater::get_instance();
59     const auto flags_srf = {
60         StatusRedrawingFlag::TORCH,
61         StatusRedrawingFlag::BONUS,
62         StatusRedrawingFlag::HP,
63         StatusRedrawingFlag::MP,
64         StatusRedrawingFlag::SPELLS,
65         StatusRedrawingFlag::UN_VIEW,
66         StatusRedrawingFlag::UN_LITE,
67         StatusRedrawingFlag::VIEW,
68         StatusRedrawingFlag::LITE,
69         StatusRedrawingFlag::MONSTER_LITE,
70         StatusRedrawingFlag::MONSTER_STATUSES,
71     };
72     rfu.set_flags(flags_srf);
73     const auto flags_mwrf = {
74         MainWindowRedrawingFlag::WIPE,
75         MainWindowRedrawingFlag::BASIC,
76         MainWindowRedrawingFlag::EXTRA,
77         MainWindowRedrawingFlag::MAP,
78         MainWindowRedrawingFlag::EQUIPPY,
79     };
80     rfu.set_flags(flags_mwrf);
81     handle_stuff(p_ptr);
82     term_redraw();
83
84     if (can_save) {
85         move_cursor_relative(p_ptr->y, p_ptr->x);
86     }
87
88     term_fresh();
89 }
90
91 /*!
92  * @brief 現在のコンソール表示の縦横を返す。 /
93  * Get term size and calculate screen size
94  * @param wid_p コンソールの表示幅文字数を返す
95  * @param hgt_p コンソールの表示行数を返す
96  */
97 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
98 {
99     term_get_size(wid_p, hgt_p);
100     *hgt_p -= ROW_MAP + 2;
101     *wid_p -= COL_MAP + 2;
102     if (use_bigtile) {
103         *wid_p /= 2;
104     }
105 }
106
107 /*
108  * Determines if a map location is currently "on screen" -RAK-
109  * Note that "panel_contains(Y,X)" always implies "in_bounds2(Y,X)".
110  */
111 bool panel_contains(POSITION y, POSITION x)
112 {
113     return (y >= panel_row_min) && (y <= panel_row_max) && (x >= panel_col_min) && (x <= panel_col_max);
114 }