1 #include "window/main-window-util.h"
2 #include "flavor/flavor-describer.h"
3 #include "flavor/object-flavor-types.h"
4 #include "floor/cave.h"
5 #include "floor/geometry.h"
6 #include "game-option/map-screen-options.h"
7 #include "game-option/special-options.h"
9 #include "monster-race/monster-race.h"
10 #include "system/floor-type-definition.h"
11 #include "system/monster-race-definition.h"
12 #include "system/object-type-definition.h"
13 #include "term/gameterm.h"
14 #include "term/screen-processor.h"
15 #include "term/term-color-types.h"
16 #include "view/display-map.h"
17 #include "world/world.h"
22 POSITION panel_row_min;
23 POSITION panel_row_max;
24 POSITION panel_col_min;
25 POSITION panel_col_max;
26 POSITION panel_col_prt;
27 POSITION panel_row_prt;
30 object_type *autopick_obj; /*!< 各種自動拾い処理時に使うオブジェクトポインタ */
31 int feat_priority; /*!< マップ縮小表示時に表示すべき地形の優先度を保管する */
33 static concptr simplify_list[][2] = {
35 { "の魔法書", "" }, { NULL, NULL }
37 { "^Ring of ", "=" }, { "^Amulet of ", "\"" }, { "^Scroll of ", "?" }, { "^Scroll titled ", "?" }, { "^Wand of ", "-" }, { "^Rod of ", "-" },
38 { "^Staff of ", "_" }, { "^Potion of ", "!" }, { " Spellbook ", "" }, { "^Book of ", "" }, { " Magic [", "[" }, { " Book [", "[" }, { " Arts [", "[" },
39 { "^Set of ", "" }, { "^Pair of ", "" }, { NULL, NULL }
44 * @brief 画面左の能力値表示を行うために指定位置から13キャラ分を空白消去後指定のメッセージを明るい青で描画する /
45 * Print character info at given row, column in a 13 char field
51 void print_field(concptr info, TERM_LEN row, TERM_LEN col)
53 c_put_str(TERM_WHITE, " ", row, col);
54 c_put_str(TERM_L_BLUE, info, row, col);
58 * Prints the map of the dungeon
60 * Note that, for efficiency, we contain an "optimized" version
61 * of both "lite_spot()" and "print_rel()", and that we use the
62 * "lite_spot()" function to display the player grid, if needed.
64 void print_map(player_type *player_ptr)
67 term_get_size(&wid, &hgt);
73 (void)term_get_cursor(&v);
75 (void)term_set_cursor(0);
77 floor_type *floor_ptr = player_ptr->current_floor_ptr;
78 POSITION xmin = (0 < panel_col_min) ? panel_col_min : 0;
79 POSITION xmax = (floor_ptr->width - 1 > panel_col_max) ? panel_col_max : floor_ptr->width - 1;
80 POSITION ymin = (0 < panel_row_min) ? panel_row_min : 0;
81 POSITION ymax = (floor_ptr->height - 1 > panel_row_max) ? panel_row_max : floor_ptr->height - 1;
83 for (POSITION y = 1; y <= ymin - panel_row_prt; y++) {
84 term_erase(COL_MAP, y, wid);
87 for (POSITION y = ymax - panel_row_prt; y <= hgt; y++) {
88 term_erase(COL_MAP, y, wid);
91 for (POSITION y = ymin; y <= ymax; y++) {
92 for (POSITION x = xmin; x <= xmax; x++) {
97 map_info(player_ptr, y, x, &a, &c, &ta, &tc);
99 if (current_world_ptr->timewalk_m_idx)
101 else if (is_invuln(player_ptr) || player_ptr->timewalk)
103 else if (player_ptr->wraith_form)
107 term_queue_bigchar(panel_col_of(x), y - panel_row_prt, a, c, ta, tc);
111 lite_spot(player_ptr, player_ptr->y, player_ptr->x);
112 (void)term_set_cursor(v);
115 static void display_shortened_item_name(player_type *player_ptr, object_type *o_ptr, int y)
118 describe_flavor(player_ptr, buf, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
119 TERM_COLOR attr = tval_to_attr[o_ptr->tval % 128];
121 if (player_ptr->image) {
123 strcpy(buf, _("何か奇妙な物", "something strange"));
127 for (c = buf; *c; c++) {
128 for (int i = 0; simplify_list[i][1]; i++) {
129 concptr org_w = simplify_list[i][0];
138 if (strncmp(c, org_w, strlen(org_w)))
142 concptr tmp = simplify_list[i][1];
145 tmp = c + strlen(org_w);
173 term_putstr(0, y, 12, attr, buf);
177 * Display a "small-scale" map of the dungeon in the active Term
179 void display_map(player_type *player_ptr, int *cy, int *cx)
196 bool old_view_special_lite = view_special_lite;
197 bool old_view_granite_lite = view_granite_lite;
198 TERM_LEN hgt, wid, yrat, xrat;
199 int **match_autopick_yx;
200 object_type ***object_autopick_yx;
201 term_get_size(&wid, &hgt);
207 floor_type *floor_ptr = player_ptr->current_floor_ptr;
208 yrat = (floor_ptr->height + hgt - 1) / hgt;
209 xrat = (floor_ptr->width + wid - 1) / wid;
210 view_special_lite = FALSE;
211 view_granite_lite = FALSE;
213 C_MAKE(ma, (hgt + 2), TERM_COLOR *);
214 C_MAKE(mc, (hgt + 2), char_ptr);
215 C_MAKE(mp, (hgt + 2), byte_ptr);
216 C_MAKE(match_autopick_yx, (hgt + 2), int *);
217 C_MAKE(object_autopick_yx, (hgt + 2), object_type **);
218 for (y = 0; y < (hgt + 2); y++) {
219 C_MAKE(ma[y], (wid + 2), TERM_COLOR);
220 C_MAKE(mc[y], (wid + 2), char);
221 C_MAKE(mp[y], (wid + 2), byte);
222 C_MAKE(match_autopick_yx[y], (wid + 2), int);
223 C_MAKE(object_autopick_yx[y], (wid + 2), object_type *);
224 for (x = 0; x < wid + 2; ++x) {
225 match_autopick_yx[y][x] = -1;
226 object_autopick_yx[y][x] = NULL;
227 ma[y][x] = TERM_WHITE;
233 C_MAKE(bigma, (floor_ptr->height + 2), TERM_COLOR *);
234 C_MAKE(bigmc, (floor_ptr->height + 2), char_ptr);
235 C_MAKE(bigmp, (floor_ptr->height + 2), byte_ptr);
236 for (y = 0; y < (floor_ptr->height + 2); y++) {
237 C_MAKE(bigma[y], (floor_ptr->width + 2), TERM_COLOR);
238 C_MAKE(bigmc[y], (floor_ptr->width + 2), char);
239 C_MAKE(bigmp[y], (floor_ptr->width + 2), byte);
240 for (x = 0; x < floor_ptr->width + 2; ++x) {
241 bigma[y][x] = TERM_WHITE;
247 for (i = 0; i < floor_ptr->width; ++i) {
248 for (j = 0; j < floor_ptr->height; ++j) {
255 map_info(player_ptr, j, i, &ta, &tc, &ta, &tc);
256 tp = (byte)feat_priority;
257 if (match_autopick != -1 && (match_autopick_yx[y][x] == -1 || match_autopick_yx[y][x] > match_autopick)) {
258 match_autopick_yx[y][x] = match_autopick;
259 object_autopick_yx[y][x] = autopick_obj;
263 bigmc[j + 1][i + 1] = tc;
264 bigma[j + 1][i + 1] = ta;
265 bigmp[j + 1][i + 1] = tp;
269 for (j = 0; j < floor_ptr->height; ++j) {
270 for (i = 0; i < floor_ptr->width; ++i) {
274 tc = bigmc[j + 1][i + 1];
275 ta = bigma[j + 1][i + 1];
276 tp = bigmp[j + 1][i + 1];
277 if (mp[y][x] == tp) {
281 for (t = 0; t < 8; t++) {
282 if (tc == bigmc[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]] && ta == bigma[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]])
300 mc[0][0] = mc[0][x] = mc[y][0] = mc[y][x] = '+';
301 for (x = 1; x <= wid; x++)
302 mc[0][x] = mc[y][x] = '-';
304 for (y = 1; y <= hgt; y++)
305 mc[y][0] = mc[y][x] = '|';
307 for (y = 0; y < hgt + 2; ++y) {
308 term_gotoxy(COL_MAP, y);
309 for (x = 0; x < wid + 2; ++x) {
313 if (current_world_ptr->timewalk_m_idx)
315 else if (is_invuln(player_ptr) || player_ptr->timewalk)
317 else if (player_ptr->wraith_form)
321 term_add_bigch(ta, tc);
325 for (y = 1; y < hgt + 1; ++y) {
327 for (x = 1; x <= wid; x++) {
328 if (match_autopick_yx[y][x] != -1 && (match_autopick > match_autopick_yx[y][x] || match_autopick == -1)) {
329 match_autopick = match_autopick_yx[y][x];
330 autopick_obj = object_autopick_yx[y][x];
334 term_putstr(0, y, 12, 0, " ");
335 if (match_autopick != -1)
336 display_shortened_item_name(player_ptr, autopick_obj, y);
339 (*cy) = player_ptr->y / yrat + 1 + ROW_MAP;
341 (*cx) = player_ptr->x / xrat + 1 + COL_MAP;
343 (*cx) = (player_ptr->x / xrat + 1) * 2 + COL_MAP;
345 view_special_lite = old_view_special_lite;
346 view_granite_lite = old_view_granite_lite;
348 for (y = 0; y < (hgt + 2); y++) {
349 C_KILL(ma[y], (wid + 2), TERM_COLOR);
350 C_KILL(mc[y], (wid + 2), SYMBOL_CODE);
351 C_KILL(mp[y], (wid + 2), byte);
352 C_KILL(match_autopick_yx[y], (wid + 2), int);
353 C_KILL(object_autopick_yx[y], (wid + 2), object_type *);
356 C_KILL(ma, (hgt + 2), TERM_COLOR *);
357 C_KILL(mc, (hgt + 2), char_ptr);
358 C_KILL(mp, (hgt + 2), byte_ptr);
359 C_KILL(match_autopick_yx, (hgt + 2), int *);
360 C_KILL(object_autopick_yx, (hgt + 2), object_type **);
361 for (y = 0; y < (floor_ptr->height + 2); y++) {
362 C_KILL(bigma[y], (floor_ptr->width + 2), TERM_COLOR);
363 C_KILL(bigmc[y], (floor_ptr->width + 2), SYMBOL_CODE);
364 C_KILL(bigmp[y], (floor_ptr->width + 2), byte);
367 C_KILL(bigma, (floor_ptr->height + 2), TERM_COLOR *);
368 C_KILL(bigmc, (floor_ptr->height + 2), char_ptr);
369 C_KILL(bigmp, (floor_ptr->height + 2), byte_ptr);
372 void set_term_color(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp)
374 if (!player_bold(player_ptr, y, x))
377 monster_race *r_ptr = &r_info[0];
384 * Calculate panel colum of a location in the map
386 int panel_col_of(int col)
388 col -= panel_col_min;