OSDN Git Service

Merge pull request #3316 from habu1010/feature/fix-consume-random-seed-when-showing...
[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     p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
74
75     handle_stuff(p_ptr);
76     term_redraw();
77
78     if (can_save) {
79         move_cursor_relative(p_ptr->y, p_ptr->x);
80     }
81
82     term_fresh();
83 }
84
85 /*!
86  * @brief 現在のコンソール表示の縦横を返す。 /
87  * Get term size and calculate screen size
88  * @param wid_p コンソールの表示幅文字数を返す
89  * @param hgt_p コンソールの表示行数を返す
90  */
91 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
92 {
93     term_get_size(wid_p, hgt_p);
94     *hgt_p -= ROW_MAP + 2;
95     *wid_p -= COL_MAP + 2;
96     if (use_bigtile) {
97         *wid_p /= 2;
98     }
99 }
100
101 /*
102  * Determines if a map location is currently "on screen" -RAK-
103  * Note that "panel_contains(Y,X)" always implies "in_bounds2(Y,X)".
104  */
105 bool panel_contains(POSITION y, POSITION x)
106 {
107     return (y >= panel_row_min) && (y <= panel_row_max) && (x >= panel_col_min) && (x <= panel_col_max);
108 }