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 "player/player-status.h"
11 #include "system/floor-type-definition.h"
12 #include "system/monster-race-definition.h"
13 #include "system/object-type-definition.h"
14 #include "system/player-type-definition.h"
15 #include "term/gameterm.h"
16 #include "term/screen-processor.h"
17 #include "term/term-color-types.h"
18 #include "view/display-map.h"
19 #include "world/world.h"
25 POSITION panel_row_min;
26 POSITION panel_row_max;
27 POSITION panel_col_min;
28 POSITION panel_col_max;
29 POSITION panel_col_prt;
30 POSITION panel_row_prt;
33 object_type *autopick_obj; /*!< 各種自動拾い処理時に使うオブジェクトポインタ */
34 int feat_priority; /*!< マップ縮小表示時に表示すべき地形の優先度を保管する */
36 static concptr simplify_list[][2] = {
38 { "の魔法書", "" }, { nullptr, nullptr }
40 { "^Ring of ", "=" }, { "^Amulet of ", "\"" }, { "^Scroll of ", "?" }, { "^Scroll titled ", "?" }, { "^Wand of ", "-" }, { "^Rod of ", "-" },
41 { "^Staff of ", "_" }, { "^Potion of ", "!" }, { " Spellbook ", "" }, { "^Book of ", "" }, { " Magic [", "[" }, { " Book [", "[" }, { " Arts [", "[" },
42 { "^Set of ", "" }, { "^Pair of ", "" }, { nullptr, nullptr }
47 * @brief 画面左の能力値表示を行うために指定位置から13キャラ分を空白消去後指定のメッセージを明るい青で描画する /
48 * Print character info at given row, column in a 13 char field
53 void print_field(concptr info, TERM_LEN row, TERM_LEN col)
55 c_put_str(TERM_WHITE, " ", row, col);
56 c_put_str(TERM_L_BLUE, info, row, col);
60 * Prints the map of the dungeon
62 * Note that, for efficiency, we contain an "optimized" version
63 * of both "lite_spot()" and "print_rel()", and that we use the
64 * "lite_spot()" function to display the player grid, if needed.
66 void print_map(player_type *player_ptr)
69 term_get_size(&wid, &hgt);
75 (void)term_get_cursor(&v);
77 (void)term_set_cursor(0);
79 floor_type *floor_ptr = player_ptr->current_floor_ptr;
80 POSITION xmin = (0 < panel_col_min) ? panel_col_min : 0;
81 POSITION xmax = (floor_ptr->width - 1 > panel_col_max) ? panel_col_max : floor_ptr->width - 1;
82 POSITION ymin = (0 < panel_row_min) ? panel_row_min : 0;
83 POSITION ymax = (floor_ptr->height - 1 > panel_row_max) ? panel_row_max : floor_ptr->height - 1;
85 for (POSITION y = 1; y <= ymin - panel_row_prt; y++) {
86 term_erase(COL_MAP, y, wid);
89 for (POSITION y = ymax - panel_row_prt; y <= hgt; y++) {
90 term_erase(COL_MAP, y, wid);
93 for (POSITION y = ymin; y <= ymax; y++) {
94 for (POSITION x = xmin; x <= xmax; x++) {
99 map_info(player_ptr, y, x, &a, &c, &ta, &tc);
101 if (w_ptr->timewalk_m_idx)
103 else if (is_invuln(player_ptr) || player_ptr->timewalk)
105 else if (player_ptr->wraith_form)
109 term_queue_bigchar(panel_col_of(x), y - panel_row_prt, a, c, ta, tc);
113 lite_spot(player_ptr, player_ptr->y, player_ptr->x);
114 (void)term_set_cursor(v);
117 static void display_shortened_item_name(player_type *player_ptr, object_type *o_ptr, int y)
120 describe_flavor(player_ptr, buf, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
121 TERM_COLOR attr = tval_to_attr[enum2i(o_ptr->tval) % 128];
123 if (player_ptr->hallucinated) {
125 strcpy(buf, _("何か奇妙な物", "something strange"));
129 for (c = buf; *c; c++) {
130 for (int i = 0; simplify_list[i][1]; i++) {
131 concptr org_w = simplify_list[i][0];
140 if (strncmp(c, org_w, strlen(org_w)))
144 concptr tmp = simplify_list[i][1];
147 tmp = c + strlen(org_w);
175 term_putstr(0, y, 12, attr, buf);
179 * @brief 縮小マップ表示 / Display a "small-scale" map of the dungeon in the active Term
180 * @param player_ptr プレイヤー情報への参照ポインタ
181 * @param cy 縮小マップ上のプレイヤーのy座標
182 * @param cx 縮小マップ上のプレイヤーのx座標
184 * メインウィンドウ('M'コマンド)、サブウィンドウ兼(縮小図)用。
185 * use_bigtile時に横の描画列数は1/2になる。
187 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;
199 TERM_LEN border_width = use_bigtile ? 2 : 1; //!< @note 枠線幅
200 TERM_LEN hgt, wid, yrat, xrat;
201 term_get_size(&wid, &hgt);
203 wid -= 12 + border_width * 2; //!< @note 描画桁数(枠線抜)
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;
214 vector<vector<TERM_COLOR>> ma(hgt + 2, vector<TERM_COLOR>(wid + 2, TERM_WHITE));
215 vector<vector<SYMBOL_CODE>> mc(hgt + 2, vector<SYMBOL_CODE>(wid + 2, ' '));
216 vector<vector<byte>> mp(hgt + 2, vector<byte>(wid + 2, 0));
217 vector<vector<int>> match_autopick_yx(hgt + 2, vector<int>(wid + 2, -1));
218 vector<vector<object_type *>> object_autopick_yx(hgt + 2, vector<object_type *>(wid + 2, nullptr));
220 vector<vector<TERM_COLOR>> bigma(floor_ptr->height + 2, vector<TERM_COLOR>(floor_ptr->width + 2, TERM_WHITE));
221 vector<vector<SYMBOL_CODE>> bigmc(floor_ptr->height + 2, vector<SYMBOL_CODE>(floor_ptr->width + 2, ' '));
222 vector<vector<byte>> bigmp(floor_ptr->height + 2, vector<byte>(floor_ptr->width + 2, 0));
224 for (i = 0; i < floor_ptr->width; ++i) {
225 for (j = 0; j < floor_ptr->height; ++j) {
230 autopick_obj = nullptr;
232 map_info(player_ptr, j, i, &ta, &tc, &ta, &tc);
233 tp = (byte)feat_priority;
234 if (match_autopick != -1 && (match_autopick_yx[y][x] == -1 || match_autopick_yx[y][x] > match_autopick)) {
235 match_autopick_yx[y][x] = match_autopick;
236 object_autopick_yx[y][x] = autopick_obj;
240 bigmc[j + 1][i + 1] = tc;
241 bigma[j + 1][i + 1] = ta;
242 bigmp[j + 1][i + 1] = tp;
246 for (j = 0; j < floor_ptr->height; ++j) {
247 for (i = 0; i < floor_ptr->width; ++i) {
251 tc = bigmc[j + 1][i + 1];
252 ta = bigma[j + 1][i + 1];
253 tp = bigmp[j + 1][i + 1];
254 if (mp[y][x] == tp) {
258 for (t = 0; t < 8; t++) {
259 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]])
277 mc[0][0] = mc[0][x] = mc[y][0] = mc[y][x] = '+';
278 for (x = 1; x <= wid; x++)
279 mc[0][x] = mc[y][x] = '-';
281 for (y = 1; y <= hgt; y++)
282 mc[y][0] = mc[y][x] = '|';
284 for (y = 0; y < hgt + 2; ++y) {
285 term_gotoxy(COL_MAP, y);
286 for (x = 0; x < wid + 2; ++x) {
290 if (w_ptr->timewalk_m_idx)
292 else if (is_invuln(player_ptr) || player_ptr->timewalk)
294 else if (player_ptr->wraith_form)
298 term_add_bigch(ta, tc);
302 for (y = 1; y < hgt + 1; ++y) {
304 for (x = 1; x <= wid; x++) {
305 if (match_autopick_yx[y][x] != -1 && (match_autopick > match_autopick_yx[y][x] || match_autopick == -1)) {
306 match_autopick = match_autopick_yx[y][x];
307 autopick_obj = object_autopick_yx[y][x];
311 term_putstr(0, y, 12, 0, " ");
312 if (match_autopick != -1)
313 display_shortened_item_name(player_ptr, autopick_obj, y);
316 (*cy) = player_ptr->y / yrat + 1 + ROW_MAP;
318 (*cx) = player_ptr->x / xrat + 1 + COL_MAP;
320 (*cx) = (player_ptr->x / xrat + 1) * 2 + COL_MAP;
322 view_special_lite = old_view_special_lite;
323 view_granite_lite = old_view_granite_lite;
326 void set_term_color(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp)
328 if (!player_bold(player_ptr, y, x))
331 monster_race *r_ptr = &r_info[0];
338 * Calculate panel colum of a location in the map
340 int panel_col_of(int col)
342 col -= panel_col_min;