OSDN Git Service

For clarity, reworded English prompt for selecting the cards to keep in poker.
[hengband/hengband.git] / src / core / window-redrawer.c
1 /*!
2  * @brief ウィンドウの再描画処理
3  * @date 2020/06/27
4  * @author Hourier
5  */
6 #include "core/window-redrawer.h"
7 #include "core/player-redraw-types.h"
8 #include "core/stuff-handler.h"
9 #include "floor/floor-util.h"
10 #include "game-option/option-flags.h"
11 #include "player/player-race.h"
12 #include "term/gameterm.h"
13 #include "term/screen-processor.h"
14 #include "term/term-color-types.h"
15 #include "view/display-messages.h"
16 #include "view/display-player.h"
17 #include "window/display-sub-window-spells.h"
18 #include "window/display-sub-windows.h"
19 #include "window/main-window-left-frame.h"
20 #include "window/main-window-row-column.h"
21 #include "window/main-window-stat-poster.h"
22 #include "window/main-window-util.h"
23 #include "world/world-turn-processor.h"
24 #include "world/world.h"
25
26 /*!
27  * todo ここにplayer_type を追加するとz-termに影響が行くので保留
28  * @brief コンソールを再描画する /
29  * Redraw a term when it is resized
30  * @return なし
31  */
32 void redraw_window(void)
33 {
34     if (!current_world_ptr->character_dungeon)
35         return;
36
37     p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
38     p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
39
40     handle_stuff(p_ptr);
41     term_redraw();
42 }
43
44 /*!
45  * @brief 現在のマップ名を描画する / Print dungeon
46  * @param creature_ptr プレーヤーへの参照ポインタ
47  * @return なし
48  */
49 static void print_dungeon(player_type *creature_ptr)
50 {
51     c_put_str(TERM_WHITE, "             ", ROW_DUNGEON, COL_DUNGEON);
52     concptr dungeon_name = map_name(creature_ptr);
53     TERM_LEN col = COL_DUNGEON + 6 - strlen(dungeon_name) / 2;
54     if (col < 0)
55         col = 0;
56
57     c_put_str(TERM_L_UMBER, format("%s", dungeon_name), ROW_DUNGEON, col);
58 }
59
60 /*!
61  * @brief redraw のフラグに応じた更新をまとめて行う / Handle "redraw"
62  * @return なし
63  * @details 更新処理の対象はゲーム中の全描画処理
64  */
65 void redraw_stuff(player_type *creature_ptr)
66 {
67     if (!creature_ptr->redraw)
68         return;
69
70     if (!current_world_ptr->character_generated)
71         return;
72
73     if (current_world_ptr->character_icky)
74         return;
75
76     if (creature_ptr->redraw & (PR_WIPE)) {
77         creature_ptr->redraw &= ~(PR_WIPE);
78         msg_print(NULL);
79         term_clear();
80     }
81
82     if (creature_ptr->redraw & (PR_MAP)) {
83         creature_ptr->redraw &= ~(PR_MAP);
84         print_map(creature_ptr);
85     }
86
87     if (creature_ptr->redraw & (PR_BASIC)) {
88         creature_ptr->redraw &= ~(PR_BASIC);
89         creature_ptr->redraw &= ~(PR_MISC | PR_TITLE | PR_STATS);
90         creature_ptr->redraw &= ~(PR_LEV | PR_EXP | PR_GOLD);
91         creature_ptr->redraw &= ~(PR_ARMOR | PR_HP | PR_MANA);
92         creature_ptr->redraw &= ~(PR_DEPTH | PR_HEALTH | PR_UHEALTH);
93         print_frame_basic(creature_ptr);
94         print_time(creature_ptr);
95         print_dungeon(creature_ptr);
96     }
97
98     if (creature_ptr->redraw & (PR_EQUIPPY)) {
99         creature_ptr->redraw &= ~(PR_EQUIPPY);
100         display_player_equippy(creature_ptr, ROW_EQUIPPY, COL_EQUIPPY, 0);
101     }
102
103     if (creature_ptr->redraw & (PR_MISC)) {
104         creature_ptr->redraw &= ~(PR_MISC);
105         print_field(rp_ptr->title, ROW_RACE, COL_RACE);
106     }
107
108     if (creature_ptr->redraw & (PR_TITLE)) {
109         creature_ptr->redraw &= ~(PR_TITLE);
110         print_title(creature_ptr);
111     }
112
113     if (creature_ptr->redraw & (PR_LEV)) {
114         creature_ptr->redraw &= ~(PR_LEV);
115         print_level(creature_ptr);
116     }
117
118     if (creature_ptr->redraw & (PR_EXP)) {
119         creature_ptr->redraw &= ~(PR_EXP);
120         print_exp(creature_ptr);
121     }
122
123     if (creature_ptr->redraw & (PR_STATS)) {
124         creature_ptr->redraw &= ~(PR_STATS);
125         print_stat(creature_ptr, A_STR);
126         print_stat(creature_ptr, A_INT);
127         print_stat(creature_ptr, A_WIS);
128         print_stat(creature_ptr, A_DEX);
129         print_stat(creature_ptr, A_CON);
130         print_stat(creature_ptr, A_CHR);
131     }
132
133     if (creature_ptr->redraw & (PR_STATUS)) {
134         creature_ptr->redraw &= ~(PR_STATUS);
135         print_status(creature_ptr);
136     }
137
138     if (creature_ptr->redraw & (PR_ARMOR)) {
139         creature_ptr->redraw &= ~(PR_ARMOR);
140         print_ac(creature_ptr);
141     }
142
143     if (creature_ptr->redraw & (PR_HP)) {
144         creature_ptr->redraw &= ~(PR_HP);
145         print_hp(creature_ptr);
146     }
147
148     if (creature_ptr->redraw & (PR_MANA)) {
149         creature_ptr->redraw &= ~(PR_MANA);
150         print_sp(creature_ptr);
151     }
152
153     if (creature_ptr->redraw & (PR_GOLD)) {
154         creature_ptr->redraw &= ~(PR_GOLD);
155         print_gold(creature_ptr);
156     }
157
158     if (creature_ptr->redraw & (PR_DEPTH)) {
159         creature_ptr->redraw &= ~(PR_DEPTH);
160         print_depth(creature_ptr);
161     }
162
163     if (creature_ptr->redraw & (PR_HEALTH)) {
164         creature_ptr->redraw &= ~(PR_HEALTH);
165         health_redraw(creature_ptr, FALSE);
166     }
167
168     if (creature_ptr->redraw & (PR_UHEALTH)) {
169         creature_ptr->redraw &= ~(PR_UHEALTH);
170         health_redraw(creature_ptr, TRUE);
171     }
172
173     if (creature_ptr->redraw & (PR_EXTRA)) {
174         creature_ptr->redraw &= ~(PR_EXTRA);
175         creature_ptr->redraw &= ~(PR_CUT | PR_STUN);
176         creature_ptr->redraw &= ~(PR_HUNGER);
177         creature_ptr->redraw &= ~(PR_STATE | PR_SPEED | PR_STUDY | PR_IMITATION | PR_STATUS);
178         print_frame_extra(creature_ptr);
179     }
180
181     if (creature_ptr->redraw & (PR_CUT)) {
182         creature_ptr->redraw &= ~(PR_CUT);
183         print_cut(creature_ptr);
184     }
185
186     if (creature_ptr->redraw & (PR_STUN)) {
187         creature_ptr->redraw &= ~(PR_STUN);
188         print_stun(creature_ptr);
189     }
190
191     if (creature_ptr->redraw & (PR_HUNGER)) {
192         creature_ptr->redraw &= ~(PR_HUNGER);
193         print_hunger(creature_ptr);
194     }
195
196     if (creature_ptr->redraw & (PR_STATE)) {
197         creature_ptr->redraw &= ~(PR_STATE);
198         print_state(creature_ptr);
199     }
200
201     if (creature_ptr->redraw & (PR_SPEED)) {
202         creature_ptr->redraw &= ~(PR_SPEED);
203         print_speed(creature_ptr);
204     }
205
206     if (creature_ptr->pclass == CLASS_IMITATOR) {
207         if (creature_ptr->redraw & (PR_IMITATION)) {
208             creature_ptr->redraw &= ~(PR_IMITATION);
209             print_imitation(creature_ptr);
210         }
211
212         return;
213     }
214
215     if (creature_ptr->redraw & (PR_STUDY)) {
216         creature_ptr->redraw &= ~(PR_STUDY);
217         print_study(creature_ptr);
218     }
219 }
220
221 /*!
222  * @brief player_ptr->window のフラグに応じた更新をまとめて行う / Handle "player_ptr->window"
223  * @param player_ptr プレーヤーへの参照ポインタ
224  * @return なし
225  * @details 更新処理の対象はサブウィンドウ全般
226  */
227 void window_stuff(player_type *player_ptr)
228 {
229     if (!player_ptr->window)
230         return;
231
232     if (!need_term_fresh())
233         return;
234
235     BIT_FLAGS mask = 0L;
236     for (int j = 0; j < 8; j++) {
237         if (angband_term[j])
238             mask |= window_flag[j];
239     }
240
241     player_ptr->window &= mask;
242
243     if (!player_ptr->window)
244         return;
245
246     if (player_ptr->window & (PW_INVEN)) {
247         player_ptr->window &= ~(PW_INVEN);
248         fix_inventory(player_ptr, 0); // TODO:2.2.2 まともなtval参照手段を確保
249     }
250
251     if (player_ptr->window & (PW_EQUIP)) {
252         player_ptr->window &= ~(PW_EQUIP);
253         fix_equip(player_ptr, 0); // TODO:2.2.2 まともなtval参照手段を確保
254     }
255
256     if (player_ptr->window & (PW_SPELL)) {
257         player_ptr->window &= ~(PW_SPELL);
258         fix_spell(player_ptr);
259     }
260
261     if (player_ptr->window & (PW_PLAYER)) {
262         player_ptr->window &= ~(PW_PLAYER);
263         fix_player(player_ptr);
264     }
265
266     if (player_ptr->window & (PW_MONSTER_LIST)) {
267         player_ptr->window &= ~(PW_MONSTER_LIST);
268         fix_monster_list(player_ptr);
269     }
270
271     if (player_ptr->window & (PW_MESSAGE)) {
272         player_ptr->window &= ~(PW_MESSAGE);
273         fix_message();
274     }
275
276     if (player_ptr->window & (PW_OVERHEAD)) {
277         player_ptr->window &= ~(PW_OVERHEAD);
278         fix_overhead(player_ptr);
279     }
280
281     if (player_ptr->window & (PW_DUNGEON)) {
282         player_ptr->window &= ~(PW_DUNGEON);
283         fix_dungeon(player_ptr);
284     }
285
286     if (player_ptr->window & (PW_MONSTER)) {
287         player_ptr->window &= ~(PW_MONSTER);
288         fix_monster(player_ptr);
289     }
290
291     if (player_ptr->window & (PW_OBJECT)) {
292         player_ptr->window &= ~(PW_OBJECT);
293         fix_object(player_ptr);
294     }
295 }