7 #include "knowledge/knowledge-features.h"
8 #include "core/show-file.h"
9 #include "dungeon/dungeon.h"
10 #include "io-dump/dump-util.h"
11 #include "knowledge/lighting-level-table.h"
12 #include "term/term-color-types.h"
13 #include "view/display-main-window.h" // 暫定、後で消す.
14 #include "world/world.h"
17 * Build a list of feature indexes in the given group. Return the number
18 * of features in the group.
20 * mode & 0x01 : check for non-empty group
22 static FEAT_IDX collect_features(FEAT_IDX *feat_idx, BIT_FLAGS8 mode)
24 FEAT_IDX feat_cnt = 0;
25 for (FEAT_IDX i = 0; i < max_f_idx; i++)
27 feature_type *f_ptr = &f_info[i];
28 if (!f_ptr->name) continue;
29 if (f_ptr->mimic != i) continue;
31 feat_idx[feat_cnt++] = i;
32 if (mode & 0x01) break;
35 feat_idx[feat_cnt] = -1;
41 * Display the features in a group.
43 static void display_feature_list(int col, int row, int per_page, FEAT_IDX *feat_idx,
44 FEAT_IDX feat_cur, FEAT_IDX feat_top, bool visual_only, int lighting_level)
46 int lit_col[F_LIT_MAX], i;
47 int f_idx_col = use_bigtile ? 62 : 64;
49 lit_col[F_LIT_STANDARD] = use_bigtile ? (71 - F_LIT_MAX) : 71;
50 for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++)
51 lit_col[i] = lit_col[F_LIT_STANDARD] + 2 + (i - F_LIT_NS_BEGIN) * 2 + (use_bigtile ? i : 0);
53 for (i = 0; i < per_page && (feat_idx[feat_top + i] >= 0); i++)
56 FEAT_IDX f_idx = feat_idx[feat_top + i];
57 feature_type *f_ptr = &f_info[f_idx];
59 attr = ((i + feat_top == feat_cur) ? TERM_L_BLUE : TERM_WHITE);
60 c_prt(attr, f_name + f_ptr->name, row_i, col);
63 c_prt(attr, format("(%s)", lighting_level_str[lighting_level]), row_i, col + 1 + strlen(f_name + f_ptr->name));
64 c_prt(attr, format("%02x/%02x", f_ptr->x_attr[lighting_level], f_ptr->x_char[lighting_level]), row_i, f_idx_col - ((current_world_ptr->wizard || visual_only) ? 6 : 2));
66 if (current_world_ptr->wizard || visual_only)
68 c_prt(attr, format("%d", f_idx), row_i, f_idx_col);
71 Term_queue_bigchar(lit_col[F_LIT_STANDARD], row_i, f_ptr->x_attr[F_LIT_STANDARD], f_ptr->x_char[F_LIT_STANDARD], 0, 0);
72 Term_putch(lit_col[F_LIT_NS_BEGIN], row_i, TERM_SLATE, '(');
73 for (int j = F_LIT_NS_BEGIN + 1; j < F_LIT_MAX; j++)
75 Term_putch(lit_col[j], row_i, TERM_SLATE, '/');
78 Term_putch(lit_col[F_LIT_MAX - 1] + (use_bigtile ? 3 : 2), row_i, TERM_SLATE, ')');
79 for (int j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
81 Term_queue_bigchar(lit_col[j] + 1, row_i, f_ptr->x_attr[j], f_ptr->x_char[j], 0, 0);
85 for (; i < per_page; i++)
87 Term_erase(col, row + i, 255);
93 * Interact with feature visuals.
95 void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX direct_f_idx, IDX *lighting_level)
97 TERM_COLOR attr_old[F_LIT_MAX];
98 (void)C_WIPE(attr_old, F_LIT_MAX, TERM_COLOR);
99 SYMBOL_CODE char_old[F_LIT_MAX];
100 (void)C_WIPE(char_old, F_LIT_MAX, SYMBOL_CODE);
103 Term_get_size(&wid, &hgt);
106 C_MAKE(feat_idx, max_f_idx, FEAT_IDX);
108 concptr feature_group_text[] = { "terrains", NULL };
113 FEAT_IDX grp_idx[100];
114 TERM_COLOR attr_top = 0;
115 bool visual_list = FALSE;
117 TERM_LEN browser_rows = hgt - 8;
118 if (direct_f_idx < 0)
120 for (FEAT_IDX i = 0; feature_group_text[i] != NULL; i++)
122 len = strlen(feature_group_text[i]);
123 if (len > max) max = len;
125 if (collect_features(feat_idx, 0x01))
127 grp_idx[grp_cnt++] = i;
135 feature_type *f_ptr = &f_info[direct_f_idx];
137 feat_idx[0] = direct_f_idx;
141 (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
142 &attr_top, &char_left, &f_ptr->x_attr[*lighting_level], &f_ptr->x_char[*lighting_level], need_redraw);
144 for (FEAT_IDX i = 0; i < F_LIT_MAX; i++)
146 attr_old[i] = f_ptr->x_attr[i];
147 char_old[i] = f_ptr->x_char[i];
151 grp_idx[grp_cnt] = -1;
153 FEAT_IDX old_grp_cur = -1;
154 FEAT_IDX grp_cur = 0;
155 FEAT_IDX grp_top = 0;
156 FEAT_IDX feat_cur = 0;
157 FEAT_IDX feat_top = 0;
161 TERM_COLOR *cur_attr_ptr;
162 SYMBOL_CODE *cur_char_ptr;
172 prt(_("表示 - 地形", "Visuals - features"), 2, 0);
173 if (direct_f_idx < 0) prt(_("グループ", "Group"), 4, 0);
174 prt(_("名前", "Name"), 4, max + 3);
177 if (current_world_ptr->wizard || visual_only) prt("Idx", 4, 62);
178 prt(_("文字 ( l/ d)", "Sym ( l/ d)"), 4, 66);
182 if (current_world_ptr->wizard || visual_only) prt("Idx", 4, 64);
183 prt(_("文字 (l/d)", "Sym (l/d)"), 4, 68);
186 for (FEAT_IDX i = 0; i < 78; i++)
188 Term_putch(i, 5, TERM_WHITE, '=');
191 if (direct_f_idx < 0)
193 for (FEAT_IDX i = 0; i < browser_rows; i++)
195 Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
202 if (direct_f_idx < 0)
204 if (grp_cur < grp_top) grp_top = grp_cur;
205 if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
207 display_group_list(0, 6, max, browser_rows, grp_idx, feature_group_text, grp_cur, grp_top);
208 if (old_grp_cur != grp_cur)
210 old_grp_cur = grp_cur;
211 feat_cnt = collect_features(feat_idx, 0x00);
214 while (feat_cur < feat_top)
215 feat_top = MAX(0, feat_top - browser_rows / 2);
216 while (feat_cur >= feat_top + browser_rows)
217 feat_top = MIN(feat_cnt - browser_rows, feat_top + browser_rows / 2);
222 display_feature_list(max + 3, 6, browser_rows, feat_idx, feat_cur, feat_top, visual_only, F_LIT_STANDARD);
227 display_feature_list(max + 3, 6, 1, feat_idx, feat_cur, feat_top, visual_only, *lighting_level);
228 display_visual_list(max + 3, 7, browser_rows - 1, wid - (max + 3), attr_top, char_left);
231 prt(format(_("<方向>%s, 'd'で標準光源効果%s, ESC", "<dir>%s, 'd' for default lighting%s, ESC"),
232 visual_list ? _(", ENTERで決定, 'a'で対象明度変更", ", ENTER to accept, 'a' for lighting level") : _(", 'v'でシンボル変更", ", 'v' for visuals"),
233 (attr_idx || char_idx) ? _(", 'c', 'p'でペースト", ", 'c', 'p' to paste") : _(", 'c'でコピー", ", 'c' to copy")),
236 f_ptr = &f_info[feat_idx[feat_cur]];
237 cur_attr_ptr = &f_ptr->x_attr[*lighting_level];
238 cur_char_ptr = &f_ptr->x_char[*lighting_level];
242 place_visual_list_cursor(max + 3, 7, *cur_attr_ptr, *cur_char_ptr, attr_top, char_left);
246 Term_gotoxy(0, 6 + (grp_cur - grp_top));
250 Term_gotoxy(max + 3, 6 + (feat_cur - feat_top));
254 if (visual_list && ((ch == 'A') || (ch == 'a')))
256 int prev_lighting_level = *lighting_level;
260 if (*lighting_level <= 0) *lighting_level = F_LIT_MAX - 1;
261 else (*lighting_level)--;
265 if (*lighting_level >= F_LIT_MAX - 1) *lighting_level = 0;
266 else (*lighting_level)++;
269 if (f_ptr->x_attr[prev_lighting_level] != f_ptr->x_attr[*lighting_level])
270 attr_top = MAX(0, (f_ptr->x_attr[*lighting_level] & 0x7f) - 5);
272 if (f_ptr->x_char[prev_lighting_level] != f_ptr->x_char[*lighting_level])
273 char_left = MAX(0, f_ptr->x_char[*lighting_level] - 10);
277 else if ((ch == 'D') || (ch == 'd'))
279 TERM_COLOR prev_x_attr = f_ptr->x_attr[*lighting_level];
280 byte prev_x_char = f_ptr->x_char[*lighting_level];
282 apply_default_feat_lighting(f_ptr->x_attr, f_ptr->x_char);
286 if (prev_x_attr != f_ptr->x_attr[*lighting_level])
287 attr_top = MAX(0, (f_ptr->x_attr[*lighting_level] & 0x7f) - 5);
289 if (prev_x_char != f_ptr->x_char[*lighting_level])
290 char_left = MAX(0, f_ptr->x_char[*lighting_level] - 10);
292 else *need_redraw = TRUE;
296 else if (visual_mode_command(ch, &visual_list, browser_rows - 1, wid - (max + 3), &attr_top, &char_left, cur_attr_ptr, cur_char_ptr, need_redraw))
301 for (FEAT_IDX i = 0; i < F_LIT_MAX; i++)
303 f_ptr->x_attr[i] = attr_old[i];
304 f_ptr->x_char[i] = char_old[i];
310 if (direct_f_idx >= 0) flag = TRUE;
311 else *lighting_level = F_LIT_STANDARD;
315 for (FEAT_IDX i = 0; i < F_LIT_MAX; i++)
317 attr_old[i] = f_ptr->x_attr[i];
318 char_old[i] = f_ptr->x_char[i];
320 *lighting_level = F_LIT_STANDARD;
327 for (FEAT_IDX i = 0; i < F_LIT_MAX; i++)
329 attr_idx_feat[i] = f_ptr->x_attr[i];
330 char_idx_feat[i] = f_ptr->x_char[i];
339 for (FEAT_IDX i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++)
341 if (attr_idx_feat[i] || (!(char_idx_feat[i] & 0x80) && char_idx_feat[i])) f_ptr->x_attr[i] = attr_idx_feat[i];
342 if (char_idx_feat[i]) f_ptr->x_char[i] = char_idx_feat[i];
360 browser_cursor(ch, &column, &grp_cur, grp_cnt, &feat_cur, feat_cnt);
366 C_KILL(feat_idx, max_f_idx, FEAT_IDX);
373 void do_cmd_knowledge_dungeon(player_type *creature_ptr)
376 GAME_TEXT file_name[FILE_NAME_SIZE];
377 if (!open_temporary_file(&fff, file_name)) return;
379 for (int i = 1; i < current_world_ptr->max_d_idx; i++)
383 if (!d_info[i].maxdepth) continue;
384 if (!max_dlv[i]) continue;
385 if (d_info[i].final_guardian)
387 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
389 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
391 fprintf(fff, _("%c%-12s : %3d 階\n", "%c%-16s : level %3d\n"), seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
395 (void)show_file(creature_ptr, TRUE, file_name, _("今までに入ったダンジョン", "Dungeon"), 0, 0);