1 #include "io-dump/dump-util.h"
2 #include "floor/geometry.h"
3 #include "game-option/keymap-directory-getter.h"
4 #include "game-option/special-options.h"
5 #include "term/term-color-types.h"
6 #include "term/screen-processor.h"
7 #include "util/angband-files.h"
8 #include "util/int-char-converter.h"
9 #include "view/display-messages.h"
11 TERM_COLOR attr_idx = 0;
12 SYMBOL_CODE char_idx = 0;
14 TERM_COLOR attr_idx_feat[F_LIT_MAX];
15 SYMBOL_CODE char_idx_feat[F_LIT_MAX];
18 * @brief シンボル変更処理 / Do visual mode command -- Change symbols
20 * @param visual_list_ptr
24 * @param char_left_ptr
28 * @return 何かコマンドを入れたらTRUE
30 bool visual_mode_command(char ch, bool *visual_list_ptr,
31 int height, int width,
32 TERM_COLOR *attr_top_ptr, byte *char_left_ptr,
33 TERM_COLOR *cur_attr_ptr, SYMBOL_CODE *cur_char_ptr, bool *need_redraw)
35 static TERM_COLOR attr_old = 0;
36 static SYMBOL_CODE char_old = 0;
42 if (!*visual_list_ptr) return FALSE;
44 *cur_attr_ptr = attr_old;
45 *cur_char_ptr = char_old;
46 *visual_list_ptr = FALSE;
52 if (!*visual_list_ptr) return FALSE;
54 *visual_list_ptr = FALSE;
61 if (*visual_list_ptr) return FALSE;
63 *visual_list_ptr = TRUE;
64 *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
65 *char_left_ptr = MAX(0, *cur_char_ptr - 10);
66 attr_old = *cur_attr_ptr;
67 char_old = *cur_char_ptr;
73 attr_idx = *cur_attr_ptr;
74 char_idx = *cur_char_ptr;
75 for (int i = 0; i < F_LIT_MAX; i++)
86 if (attr_idx || (!(char_idx & 0x80) && char_idx))
88 *cur_attr_ptr = attr_idx;
89 *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
90 if (!*visual_list_ptr) *need_redraw = TRUE;
96 *cur_char_ptr = char_idx;
97 *char_left_ptr = MAX(0, *cur_char_ptr - 10);
98 if (!*visual_list_ptr) *need_redraw = TRUE;
105 if (!*visual_list_ptr) return FALSE;
108 int d = get_keymap_dir(ch);
109 TERM_COLOR a = (*cur_attr_ptr & 0x7f);
110 SYMBOL_CODE c = *cur_char_ptr;
112 if (use_bigtile) eff_width = width / 2;
113 else eff_width = width;
115 if ((a == 0) && (ddy[d] < 0)) d = 0;
116 if ((c == 0) && (ddx[d] < 0)) d = 0;
117 if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
118 if (((byte)c == 0xff) && (ddx[d] > 0)) d = 0;
120 a += (TERM_COLOR)ddy[d];
121 c += (SYMBOL_CODE)ddx[d];
122 if (c & 0x80) a |= 0x80;
126 if ((ddx[d] < 0) && *char_left_ptr > MAX(0, (int)c - 10)) (*char_left_ptr)--;
127 if ((ddx[d] > 0) && *char_left_ptr + eff_width < MIN(0xff, (int)c + 10)) (*char_left_ptr)++;
128 if ((ddy[d] < 0) && *attr_top_ptr > MAX(0, (int)(a & 0x7f) - 4)) (*attr_top_ptr)--;
129 if ((ddy[d] > 0) && *attr_top_ptr + height < MIN(0x7f, (a & 0x7f) + 4)) (*attr_top_ptr)++;
138 * @brief ダンプ用の一時ファイルを開く
139 * @param fff 一時ファイルへの参照ポインタ
140 * @param file_name ファイル名
141 * @return ファイルを開けたらTRUE、開けなかったらFALSE
144 bool open_temporary_file(FILE **fff, char *file_name)
146 *fff = angband_fopen_temp(file_name, FILE_NAME_SIZE);
147 if (*fff != NULL) return TRUE;
149 msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
156 * @brief モンスター情報リスト中のグループを表示する /
157 * Display the object groups.
161 * @param per_page リストの表示行
162 * @param grp_idx グループのID配列
163 * @param group_text グループ名の文字列配列
164 * @param grp_cur 現在の選択ID
165 * @param grp_top 現在の選択リスト最上部ID
168 void display_group_list(int col, int row, int wid, int per_page, IDX grp_idx[], concptr group_text[], int grp_cur, int grp_top)
170 for (int i = 0; i < per_page && (grp_idx[i] >= 0); i++)
172 int grp = grp_idx[grp_top + i];
173 TERM_COLOR attr = (grp_top + i == grp_cur) ? TERM_L_BLUE : TERM_WHITE;
174 term_erase(col, row + i, wid);
175 c_put_str(attr, group_text[grp], row + i, col);
183 void display_visual_list(int col, int row, int height, int width, TERM_COLOR attr_top, byte char_left)
185 for (int i = 0; i < height; i++)
187 term_erase(col, row + i, width);
190 if (use_bigtile) width /= 2;
192 for (int i = 0; i < height; i++)
194 for (int j = 0; j < width; j++)
196 TERM_LEN x = col + j;
197 TERM_LEN y = row + i;
198 if (use_bigtile) x += j;
200 int ia = attr_top + i;
201 int ic = char_left + j;
202 if (ia > 0x7f || ic > 0xff || ic < ' ' ||
203 (!use_graphics && ic > 0x7f))
206 TERM_COLOR a = (TERM_COLOR)ia;
207 SYMBOL_CODE c = (SYMBOL_CODE)ic;
208 if (c & 0x80) a |= 0x80;
210 term_queue_bigchar(x, y, a, c, 0, 0);
217 * Place the cursor at the collect position for visual mode
219 void place_visual_list_cursor(TERM_LEN col, TERM_LEN row, TERM_COLOR a, byte c, TERM_COLOR attr_top, byte char_left)
221 int i = (a & 0x7f) - attr_top;
222 int j = c - char_left;
224 TERM_LEN x = col + j;
225 TERM_LEN y = row + i;
226 if (use_bigtile) x += j;
233 * Move the cursor in a browser window
235 void browser_cursor(char ch, int *column, IDX *grp_cur, int grp_cnt, IDX *list_cur, int list_cnt)
240 IDX list = *list_cur;
246 d = get_keymap_dir(ch);
250 if ((ddx[d] > 0) && ddy[d])
254 term_get_size(&wid, &hgt);
255 browser_rows = hgt - 8;
259 grp += ddy[d] * (browser_rows - 1);
260 if (grp >= grp_cnt) grp = grp_cnt - 1;
261 if (grp < 0) grp = 0;
262 if (grp != old_grp) list = 0;
266 list += ddy[d] * browser_rows;
267 if (list >= list_cnt) list = list_cnt - 1;
268 if (list < 0) list = 0;
279 if (col < 0) col = 0;
280 if (col > 1) col = 1;
290 if (grp >= grp_cnt) grp = grp_cnt - 1;
291 if (grp < 0) grp = 0;
292 if (grp != old_grp) list = 0;
297 if (list >= list_cnt) list = list_cnt - 1;
298 if (list < 0) list = 0;