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 "system/terrain-type-definition.h"
6 #include "term/screen-processor.h"
7 #include "term/term-color-types.h"
8 #include "util/angband-files.h"
9 #include "util/int-char-converter.h"
10 #include "view/display-messages.h"
12 TERM_COLOR attr_idx = 0;
15 TERM_COLOR attr_idx_feat[F_LIT_MAX];
16 char char_idx_feat[F_LIT_MAX];
19 * @brief シンボル変更処理 / Do visual mode command -- Change symbols
21 * @param visual_list_ptr
25 * @param char_left_ptr
29 * @return 何かコマンドを入れたらTRUE
31 bool visual_mode_command(char ch, bool *visual_list_ptr,
32 int height, int width,
33 TERM_COLOR *attr_top_ptr, byte *char_left_ptr,
34 TERM_COLOR *cur_attr_ptr, char *cur_char_ptr, bool *need_redraw)
36 static TERM_COLOR attr_old = 0;
37 static char char_old = 0;
41 if (!*visual_list_ptr) {
45 *cur_attr_ptr = attr_old;
46 *cur_char_ptr = char_old;
47 *visual_list_ptr = false;
52 if (!*visual_list_ptr) {
56 *visual_list_ptr = false;
62 if (*visual_list_ptr) {
66 *visual_list_ptr = true;
67 *attr_top_ptr = std::max<byte>(0, (*cur_attr_ptr & 0x7f) - 5);
68 *char_left_ptr = std::max<byte>(0, *cur_char_ptr - 10);
69 attr_old = *cur_attr_ptr;
70 char_old = *cur_char_ptr;
75 attr_idx = *cur_attr_ptr;
76 char_idx = *cur_char_ptr;
77 for (int i = 0; i < F_LIT_MAX; i++) {
86 if (attr_idx || (!(char_idx & 0x80) && char_idx)) {
87 *cur_attr_ptr = attr_idx;
88 *attr_top_ptr = std::max<byte>(0, (*cur_attr_ptr & 0x7f) - 5);
89 if (!*visual_list_ptr) {
96 *cur_char_ptr = char_idx;
97 *char_left_ptr = std::max<byte>(0, *cur_char_ptr - 10);
98 if (!*visual_list_ptr) {
106 if (!*visual_list_ptr) {
111 int d = get_keymap_dir(ch);
112 TERM_COLOR a = (*cur_attr_ptr & 0x7f);
113 auto c = *cur_char_ptr;
116 eff_width = width / 2;
121 if ((a == 0) && (ddy[d] < 0)) {
124 if ((c == 0) && (ddx[d] < 0)) {
127 if ((a == 0x7f) && (ddy[d] > 0)) {
130 if (((byte)c == 0xff) && (ddx[d] > 0)) {
134 a += (TERM_COLOR)ddy[d];
135 c += static_cast<char>(ddx[d]);
142 if ((ddx[d] < 0) && *char_left_ptr > std::max(0, (unsigned char)c - 10)) {
145 if ((ddx[d] > 0) && *char_left_ptr + eff_width < std::min(0xff, (unsigned char)c + 10)) {
148 if ((ddy[d] < 0) && *attr_top_ptr > std::max(0, (int)(a & 0x7f) - 4)) {
151 if ((ddy[d] > 0) && *attr_top_ptr + height < std::min(0x7f, (a & 0x7f) + 4)) {
161 * @brief ダンプ用の一時ファイルを開く
162 * @param fff 一時ファイルへの参照ポインタ
163 * @param file_name ファイル名
164 * @return ファイルを開けたらTRUE、開けなかったらFALSE
167 bool open_temporary_file(FILE **fff, char *file_name)
169 *fff = angband_fopen_temp(file_name, FILE_NAME_SIZE);
170 if (*fff != nullptr) {
174 msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), file_name);
180 * @brief モンスター情報リスト中のグループを表示する /
181 * Display the object groups.
185 * @param per_page リストの表示行
186 * @param grp_idx グループのID配列
187 * @param group_text グループ名の文字列配列
188 * @param grp_cur 現在の選択ID
189 * @param grp_top 現在の選択リスト最上部ID
191 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)
193 for (int i = 0; i < per_page && (grp_idx[i] >= 0); i++) {
194 int grp = grp_idx[grp_top + i];
195 TERM_COLOR attr = (grp_top + i == grp_cur) ? TERM_L_BLUE : TERM_WHITE;
196 term_erase(col, row + i, wid);
197 c_put_str(attr, group_text[grp], row + i, col);
202 * @brief Display visuals.
204 void display_visual_list(int col, int row, int height, int width, TERM_COLOR attr_top, byte char_left)
206 for (int i = 0; i < height; i++) {
207 term_erase(col, row + i, width);
214 for (int i = 0; i < height; i++) {
215 for (int j = 0; j < width; j++) {
216 TERM_LEN x = col + j;
217 TERM_LEN y = row + i;
222 int ia = attr_top + i;
223 int ic = char_left + j;
224 if (ia > 0x7f || ic > 0xff || ic < ' ' ||
225 (!use_graphics && ic > 0x7f)) {
229 TERM_COLOR a = (TERM_COLOR)ia;
230 auto c = static_cast<char>(ic);
235 term_queue_bigchar(x, y, a, c, 0, 0);
241 * @brief Place the cursor at the collect position for visual mode
243 void place_visual_list_cursor(TERM_LEN col, TERM_LEN row, TERM_COLOR a, byte c, TERM_COLOR attr_top, byte char_left)
245 int i = (a & 0x7f) - attr_top;
246 int j = c - char_left;
248 TERM_LEN x = col + j;
249 TERM_LEN y = row + i;
258 * @brief Move the cursor in a browser window
260 void browser_cursor(char ch, int *column, IDX *grp_cur, int grp_cnt, IDX *list_cur, int list_cnt)
265 IDX list = *list_cur;
268 } else if (ch == '-') {
271 d = get_keymap_dir(ch);
278 if ((ddx[d] > 0) && ddy[d]) {
281 term_get_size(&wid, &hgt);
282 browser_rows = hgt - 8;
285 grp += ddy[d] * (browser_rows - 1);
286 if (grp >= grp_cnt) {
292 if (grp != old_grp) {
296 list += ddy[d] * browser_rows;
297 if (list >= list_cnt) {
326 if (grp >= grp_cnt) {
332 if (grp != old_grp) {
337 if (list >= list_cnt) {