1 #include "window/display-sub-windows.h"
2 #include "core/window-redrawer.h"
3 #include "flavor/flavor-describer.h"
4 #include "floor/cave.h"
5 #include "game-option/option-flags.h"
6 #include "game-option/special-options.h"
7 #include "game-option/text-display-options.h"
8 #include "grid/feature.h"
10 #include "inventory/inventory-describer.h"
11 #include "inventory/inventory-slot-types.h"
12 #include "inventory/inventory-util.h"
13 #include "monster-race/monster-race.h"
14 #include "monster-race/race-flags1.h"
15 #include "monster/monster-flag-types.h"
16 #include "monster/monster-info.h"
17 #include "object/item-tester-hooker.h"
18 #include "object/object-info.h"
19 #include "player/player-status-flags.h"
20 #include "spell-kind/magic-item-recharger.h"
21 #include "system/floor-type-definition.h"
22 #include "system/monster-type-definition.h"
23 #include "target/target-preparation.h"
24 #include "target/target-types.h"
25 #include "term/gameterm.h"
26 #include "term/screen-processor.h"
27 #include "term/term-color-types.h"
28 #include "view/display-lore.h"
29 #include "view/display-map.h"
30 #include "view/display-messages.h"
31 #include "view/display-player.h"
32 #include "view/object-describer.h"
33 #include "window/main-window-equipments.h"
34 #include "window/main-window-util.h"
35 #include "world/world.h"
38 * @brief サブウィンドウに所持品一覧を表示する / Hack -- display inventory in sub-windows
39 * @param player_ptr プレーヤーへの参照ポインタ
42 void fix_inventory(player_type *player_ptr, tval_type item_tester_tval)
44 for (int j = 0; j < 8; j++) {
45 term_type *old = Term;
49 if (!(window_flag[j] & (PW_INVEN)))
52 term_activate(angband_term[j]);
53 display_inventory(player_ptr, item_tester_tval);
60 * @brief モンスターの現在数を一行で表現する / Print monster info in line
63 * @param m_ptr 思い出を表示するモンスター情報の参照ポインタ
64 * @param n_same モンスターの数の現在数
68 * nnn : number or unique(U) or wanted unique(W)
69 * X : symbol of monster
70 * LV : monster lv if known
71 * name: name of monster
75 static void print_monster_line(TERM_LEN x, TERM_LEN y, monster_type *m_ptr, int n_same)
78 MONRACE_IDX r_idx = m_ptr->ap_r_idx;
79 monster_race *r_ptr = &r_info[r_idx];
84 if (r_ptr->flags1 & RF1_UNIQUE) {
85 bool is_bounty = FALSE;
86 for (int i = 0; i < MAX_BOUNTY; i++) {
87 if (current_world_ptr->bounty_r_idx[i] == r_idx) {
93 term_addstr(-1, TERM_WHITE, is_bounty ? " W" : " U");
95 sprintf(buf, "%3d", n_same);
96 term_addstr(-1, TERM_WHITE, buf);
99 term_addstr(-1, TERM_WHITE, " ");
100 term_add_bigch(r_ptr->x_attr, r_ptr->x_char);
102 if (r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE)) {
103 sprintf(buf, " %2d", (int)r_ptr->level);
108 term_addstr(-1, TERM_WHITE, buf);
110 sprintf(buf, " %s ", r_name + r_ptr->name);
111 term_addstr(-1, TERM_WHITE, buf);
115 * @brief モンスターの出現リストを表示する / Print monster info in line
118 * @param max_lines 最大何行描画するか
120 void print_monster_list(floor_type *floor_ptr, TERM_LEN x, TERM_LEN y, TERM_LEN max_lines)
123 monster_type *last_mons = NULL;
124 monster_type *m_ptr = NULL;
127 for (i = 0; i < tmp_pos.n; i++) {
128 grid_type *g_ptr = &floor_ptr->grid_array[tmp_pos.y[i]][tmp_pos.x[i]];
129 if (!g_ptr->m_idx || !floor_ptr->m_list[g_ptr->m_idx].ml)
131 m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
137 //ソート済みなので同じモンスターは連続する.これを利用して同じモンスターをカウント,まとめて表示する.
146 if (last_mons->ap_r_idx == m_ptr->ap_r_idx) {
148 continue; //表示処理を次に回す
151 // print last mons info
152 print_monster_line(x, line++, last_mons, n_same);
155 if (line - y - 1 == max_lines)
159 if (line - y - 1 == max_lines && i != tmp_pos.n) {
160 term_gotoxy(x, line);
161 term_addstr(-1, TERM_WHITE, "-- and more --");
164 print_monster_line(x, line++, last_mons, n_same);
169 * @brief 出現中モンスターのリストをサブウィンドウに表示する / Hack -- display monster list in sub-windows
170 * @param player_ptr プレーヤーへの参照ポインタ
173 void fix_monster_list(player_type *player_ptr)
175 for (int j = 0; j < 8; j++) {
176 term_type *old = Term;
177 if (!angband_term[j])
179 if (!(window_flag[j] & PW_MONSTER_LIST))
182 term_activate(angband_term[j]);
184 term_get_size(&w, &h);
186 target_set_prepare(player_ptr, TARGET_LOOK);
187 print_monster_list(player_ptr->current_floor_ptr, 0, 0, h);
194 * @brief 装備アイテム一覧を表示する /
195 * Choice window "shadow" of the "show_equip()" function
198 static void display_equipment(player_type *owner_ptr, tval_type tval)
200 if (!owner_ptr || !owner_ptr->inventory_list)
204 term_get_size(&wid, &hgt);
206 TERM_COLOR attr = TERM_WHITE;
208 GAME_TEXT o_name[MAX_NLEN];
209 for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
211 o_ptr = &owner_ptr->inventory_list[i];
212 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
213 if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(owner_ptr, o_ptr, tval)) {
214 tmp_val[0] = index_to_label(i);
218 term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
219 if ((((i == INVEN_RARM) && have_left_hand_weapon(owner_ptr)) || ((i == INVEN_LARM) && have_right_hand_weapon(owner_ptr))) && have_two_handed_weapons(owner_ptr)) {
220 strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
223 describe_flavor(owner_ptr, o_name, o_ptr, 0);
224 attr = tval_to_attr[o_ptr->tval % 128];
227 int n = strlen(o_name);
231 term_putstr(3, i - INVEN_RARM, n, attr, o_name);
232 term_erase(3 + n, i - INVEN_RARM, 255);
234 int wgt = o_ptr->weight * o_ptr->number;
235 sprintf(tmp_val, _("%3d.%1d kg", "%3d.%1d lb"), _(lbtokg1(wgt), wgt / 10), _(lbtokg2(wgt), wgt % 10));
236 prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
240 term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
241 prt(mention_use(owner_ptr, i), i - INVEN_RARM, wid - 15);
245 for (int i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
246 term_erase(0, i, 255);
250 * @brief 現在の装備品をサブウィンドウに表示する /
251 * Hack -- display equipment in sub-windows
252 * @param player_ptr プレーヤーへの参照ポインタ
255 void fix_equip(player_type *player_ptr, tval_type item_tester_tval)
257 for (int j = 0; j < 8; j++) {
258 term_type *old = Term;
259 if (!angband_term[j])
261 if (!(window_flag[j] & (PW_EQUIP)))
264 term_activate(angband_term[j]);
265 display_equipment(player_ptr, item_tester_tval);
272 * @brief 現在のプレイヤーステータスをサブウィンドウに表示する /
273 * @param player_ptr プレーヤーへの参照ポインタ
274 * Hack -- display character in sub-windows
277 void fix_player(player_type *player_ptr)
279 for (int j = 0; j < 8; j++) {
280 term_type *old = Term;
281 if (!angband_term[j])
284 if (!(window_flag[j] & (PW_PLAYER)))
287 term_activate(angband_term[j]);
289 display_player(player_ptr, 0);
296 * @brief ゲームメッセージ履歴をサブウィンドウに表示する /
297 * Hack -- display recent messages in sub-windows
298 * Adjust for width and split messages
301 void fix_message(void)
303 for (int j = 0; j < 8; j++) {
304 term_type *old = Term;
305 if (!angband_term[j])
308 if (!(window_flag[j] & (PW_MESSAGE)))
311 term_activate(angband_term[j]);
313 term_get_size(&w, &h);
314 for (int i = 0; i < h; i++) {
315 term_putstr(0, (h - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), message_str((s16b)i));
318 term_erase(x, y, 255);
327 * @brief 簡易マップをサブウィンドウに表示する /
328 * Hack -- display overhead view in sub-windows
329 * Adjust for width and split messages
330 * @param player_ptr プレーヤーへの参照ポインタ
333 * Note that the "player" symbol does NOT appear on the map.
335 void fix_overhead(player_type *player_ptr)
337 for (int j = 0; j < 8; j++) {
338 term_type *old = Term;
340 if (!angband_term[j])
343 if (!(window_flag[j] & (PW_OVERHEAD)))
346 term_activate(angband_term[j]);
347 term_get_size(&wid, &hgt);
348 if (wid > COL_MAP + 2 && hgt > ROW_MAP + 2) {
350 display_map(player_ptr, &cy, &cx);
358 static void display_dungeon(player_type *player_ptr)
361 SYMBOL_CODE tc = '\0';
363 for (TERM_LEN x = player_ptr->x - Term->wid / 2 + 1; x <= player_ptr->x + Term->wid / 2; x++) {
364 for (TERM_LEN y = player_ptr->y - Term->hgt / 2 + 1; y <= player_ptr->y + Term->hgt / 2; y++) {
367 if (!in_bounds2(player_ptr->current_floor_ptr, y, x)) {
368 feature_type *f_ptr = &f_info[feat_none];
369 a = f_ptr->x_attr[F_LIT_STANDARD];
370 c = f_ptr->x_char[F_LIT_STANDARD];
371 term_queue_char(x - player_ptr->x + Term->wid / 2 - 1, y - player_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
375 map_info(player_ptr, y, x, &a, &c, &ta, &tc);
378 if (current_world_ptr->timewalk_m_idx)
380 else if (is_invuln(player_ptr) || player_ptr->timewalk)
382 else if (player_ptr->wraith_form)
386 term_queue_char(x - player_ptr->x + Term->wid / 2 - 1, y - player_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
392 * @brief ダンジョンの地形をサブウィンドウに表示する /
393 * Hack -- display dungeon view in sub-windows
394 * @param player_ptr プレーヤーへの参照ポインタ
397 void fix_dungeon(player_type *player_ptr)
399 for (int j = 0; j < 8; j++) {
400 term_type *old = Term;
401 if (!angband_term[j])
404 if (!(window_flag[j] & (PW_DUNGEON)))
407 term_activate(angband_term[j]);
408 display_dungeon(player_ptr);
415 * @brief モンスターの思い出をサブウィンドウに表示する /
416 * Hack -- display dungeon view in sub-windows
417 * @param player_ptr プレーヤーへの参照ポインタ
420 void fix_monster(player_type *player_ptr)
422 for (int j = 0; j < 8; j++) {
423 term_type *old = Term;
424 if (!angband_term[j])
427 if (!(window_flag[j] & (PW_MONSTER)))
430 term_activate(angband_term[j]);
431 if (player_ptr->monster_race_idx)
432 display_roff(player_ptr);
440 * @brief ベースアイテム情報をサブウィンドウに表示する /
441 * Hack -- display object recall in sub-windows
442 * @param player_ptr プレーヤーへの参照ポインタ
445 void fix_object(player_type *player_ptr)
447 for (int j = 0; j < 8; j++) {
448 term_type *old = Term;
449 if (!angband_term[j])
452 if (!(window_flag[j] & (PW_OBJECT)))
455 term_activate(angband_term[j]);
456 if (player_ptr->object_kind_idx)
457 display_koff(player_ptr, player_ptr->object_kind_idx);
465 * @brief サブウィンドウに所持品、装備品リストの表示を行う /
466 * Flip "inven" and "equip" in any sub-windows
469 void toggle_inventory_equipment(player_type *owner_ptr)
471 for (int j = 0; j < 8; j++) {
472 if (!angband_term[j])
475 if (window_flag[j] & (PW_INVEN)) {
476 window_flag[j] &= ~(PW_INVEN);
477 window_flag[j] |= (PW_EQUIP);
478 owner_ptr->window |= (PW_EQUIP);
482 if (window_flag[j] & PW_EQUIP) {
483 window_flag[j] &= ~(PW_EQUIP);
484 window_flag[j] |= PW_INVEN;
485 owner_ptr->window |= PW_INVEN;