2 * @file cmd-process-screen.c
9 #include "cmd/cmd-process-screen.h"
10 #include "cmd/cmd-draw.h"
14 // Encode the screen colors
15 static char hack[17] = "dwsorgbuDWvyRGBU";
17 void do_cmd_save_screen_html_aux(char *filename, int message)
25 concptr html_head[] = {
26 "<html>\n<body text=\"#ffffff\" bgcolor=\"#000000\">\n",
30 concptr html_foot[] = {
37 Term_get_size(&wid, &hgt);
38 FILE_TYPE(FILE_TYPE_TEXT);
40 fff = my_fopen(filename, "w");
45 msg_format(_("ファイル %s を開けませんでした。", "Failed to open file %s."), filename);
52 if (message) screen_save();
55 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "htmldump.prf");
57 tmpfff = my_fopen(buf, "r");
60 for (int i = 0; html_head[i]; i++)
61 fputs(html_head[i], fff);
65 bool is_first_line = TRUE;
66 while (!my_fgets(tmpfff, buf, sizeof(buf)))
70 if (strncmp(buf, tags[0], strlen(tags[0])) == 0)
71 is_first_line = FALSE;
75 if (strncmp(buf, tags[1], strlen(tags[1])) == 0)
77 fprintf(fff, "%s\n", buf);
82 for (TERM_LEN y = 0; y < hgt; y++)
84 if (y != 0) fprintf(fff, "\n");
86 TERM_COLOR a = 0, old_a = 0;
88 for (TERM_LEN x = 0; x < wid - 1; x++)
91 (void)(Term_what(x, y, &a, &c));
94 case '&': cc = "&"; break;
95 case '<': cc = "<"; break;
96 case '>': cc = ">"; break;
98 case 0x1f: c = '.'; break;
99 case 0x7f: c = (a == 0x09) ? '%' : '#'; break;
104 if ((y == 0 && x == 0) || a != old_a)
106 int rv = angband_color_table[a][1];
107 int gv = angband_color_table[a][2];
108 int bv = angband_color_table[a][3];
109 fprintf(fff, "%s<font color=\"#%02x%02x%02x\">",
110 ((y == 0 && x == 0) ? "" : "</font>"), rv, gv, bv);
115 fprintf(fff, "%s", cc);
117 fprintf(fff, "%c", c);
121 fprintf(fff, "</font>");
124 for (int i = 0; html_foot[i]; i++)
125 fputs(html_foot[i], fff);
130 bool is_first_line = TRUE;
131 while (!my_fgets(tmpfff, buf, sizeof(buf)))
135 if (strncmp(buf, tags[2], strlen(tags[2])) == 0)
136 is_first_line = FALSE;
140 if (strncmp(buf, tags[3], strlen(tags[3])) == 0)
142 fprintf(fff, "%s\n", buf);
153 msg_print(_("画面(記念撮影)をファイルに書き出しました。", "Screen dump saved."));
163 * Hack -- save a screen dump to a file
165 static void do_cmd_save_screen_html(void)
167 char buf[1024], tmp[256] = "screen.html";
169 if (!get_string(_("ファイル名: ", "File name: "), tmp, 80))
171 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
175 do_cmd_save_screen_html_aux(buf, 1);
180 * Save a screen dump to a file
181 * @param creature_ptr プレーヤーへの参照ポインタ
184 void do_cmd_save_screen(player_type *creature_ptr, void(*handle_stuff)(player_type*))
186 prt(_("記念撮影しますか? [(y)es/(h)tml/(n)o] ", "Save screen dump? [(y)es/(h)tml/(n)o] "), 0, 0);
187 bool html_dump = FALSE;
191 if (c == 'Y' || c == 'y')
193 else if (c == 'H' || c == 'h')
206 Term_get_size(&wid, &hgt);
208 bool old_use_graphics = use_graphics;
209 if (old_use_graphics)
211 use_graphics = FALSE;
212 reset_visuals(creature_ptr);
213 creature_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
214 (*handle_stuff)(creature_ptr);
219 do_cmd_save_screen_html();
220 do_cmd_redraw(creature_ptr);
229 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
230 FILE_TYPE(FILE_TYPE_TEXT);
231 fff = my_fopen(buf, "w");
234 msg_format(_("ファイル %s を開けませんでした。", "Failed to open file %s."), buf);
240 for (y = 0; y < hgt; y++)
242 for (x = 0; x < wid - 1; x++)
244 (void)(Term_what(x, y, &a, &c));
249 fprintf(fff, "%s\n", buf);
253 for (y = 0; y < hgt; y++)
255 for (x = 0; x < wid - 1; x++)
257 (void)(Term_what(x, y, &a, &c));
258 buf[x] = hack[a & 0x0F];
262 fprintf(fff, "%s\n", buf);
267 msg_print(_("画面(記念撮影)をファイルに書き出しました。", "Screen dump saved."));
272 if (!old_use_graphics) return;
275 reset_visuals(creature_ptr);
276 creature_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
277 handle_stuff(creature_ptr);
282 * @brief Load a screen dump from a file
284 void do_cmd_load_screen(void)
292 Term_get_size(&wid, &hgt);
293 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
294 fff = my_fopen(buf, "r");
297 msg_format(_("%s を開くことができませんでした。", "Failed to open %s."), buf);
304 for (TERM_LEN y = 0; okay; y++)
306 if (!fgets(buf, 1024, fff)) okay = FALSE;
308 if (buf[0] == '\n' || buf[0] == '\0') break;
309 if (y >= hgt) continue;
311 for (TERM_LEN x = 0; x < wid - 1; x++)
313 if (buf[x] == '\n' || buf[x] == '\0') break;
315 Term_draw(x, y, TERM_WHITE, buf[x]);
319 for (TERM_LEN y = 0; okay; y++)
321 if (!fgets(buf, 1024, fff)) okay = FALSE;
323 if (buf[0] == '\n' || buf[0] == '\0') break;
324 if (y >= hgt) continue;
326 for (TERM_LEN x = 0; x < wid - 1; x++)
328 if (buf[x] == '\n' || buf[x] == '\0') break;
330 (void)(Term_what(x, y, &a, &c));
331 for (int i = 0; i < 16; i++)
333 if (hack[i] == buf[x]) a = (byte)i;
336 Term_draw(x, y, a, c);
341 prt(_("ファイルに書き出された画面(記念撮影)をロードしました。", "Screen dump loaded."), 0, 0);