Esempio n. 1
0
/**
 * Hack -- load a screen dump from a file
 *
 * ToDo: Add support for loading/saving screen-dumps with graphics
 * and pseudo-graphics.  Allow the player to specify the filename
 * of the dump.
 */
void do_cmd_load_screen(void)
{
	int i, y, x;
	int a = 0;
	wchar_t c = L' ';
	bool okay = TRUE;
	ang_file *fp;
	char buf[1024];

	/* Build the filename */
	path_build(buf, 1024, ANGBAND_DIR_USER, "dump.txt");
	fp = file_open(buf, MODE_READ, FTYPE_TEXT);
	if (!fp) return;

	/* Save screen */
	screen_save();

	/* Clear the screen */
	Term_clear();

	/* Load the screen */
	for (y = 0; okay && (y < 24); y++) {
		/* Get a line of data */
		if (!file_getl(fp, buf, sizeof(buf))) okay = FALSE;

		/* Show each row */
		for (x = 0; x < 79; x++) {
			text_mbstowcs(&c, &buf[x], 1);
			/* Put the attr/char */
			Term_draw(x, y, COLOUR_WHITE, c);
		}
	}

	/* Get the blank line */
	if (!file_getl(fp, buf, sizeof(buf))) okay = FALSE;

	/* Dump the screen */
	for (y = 0; okay && (y < 24); y++) {
		/* Get a line of data */
		if (!file_getl(fp, buf, sizeof(buf))) okay = FALSE;

		/* Dump each row */
		for (x = 0; x < 79; x++) {
			/* Get the attr/char */
			(void)(Term_what(x, y, &a, &c));

			/* Look up the attr */
			for (i = 0; i < BASIC_COLORS; i++)
				/* Use attr matches */
				if (hack[i] == buf[x]) a = i;

			/* Put the attr/char */
			Term_draw(x, y, a, c);
		}
	}

	/* Close it */
	file_close(fp);

	/* Message */
	msg("Screen dump loaded.");
	event_signal(EVENT_MESSAGE_FLUSH);

	/* Load screen */
	screen_load();
}
Esempio n. 2
0
/**
 * Display a "tomb-stone"
 */
static void print_tomb(void)
{
    cptr p;

    int offset = 12;

    char tmp[160];

    char buf[1024];

    ang_file *fp;

#ifdef _WIN32_WCE
    time_t ct = fake_time((time_t) 0);
#else
    time_t ct = time((time_t) 0);
#endif

    bool boat = ((p_ptr->total_winner) && (player_has(PF_ELVEN)));
    bool tree = ((p_ptr->total_winner)
		 && (player_has(PF_WOODEN) || player_has(PF_DIVINE)));

    /* Clear screen */
    Term_clear();

    /* Build the filename */
    if (tree)
	path_build(buf, 1024, ANGBAND_DIR_FILE, "tree.txt");
    else if (boat)
	path_build(buf, 1024, ANGBAND_DIR_FILE, "boat.txt");
    else
	path_build(buf, 1024, ANGBAND_DIR_FILE, "dead.txt");

    /* Open the News file */
    fp = file_open(buf, MODE_READ, FTYPE_TEXT);

    /* Dump */
    if (fp) {
	int i, y, x;

	byte a = 0;
	char c = ' ';

	bool okay = TRUE;

	int len;


	/* Load the screen */
	for (y = 0; okay; y++) {
	    /* Get a line of data */
	    if (!file_getl(fp, buf, 1024))
		okay = FALSE;

	    /* Stop on blank line */
	    if (!buf[0])
		break;

	    /* Get the width */
	    len = strlen(buf);

	    /* XXX Restrict to current screen size */
	    if (len >= Term->wid)
		len = Term->wid;

	    /* Show each row */
	    for (x = 0; x < len; x++) {
		/* Put the attr/char */
		Term_draw(x, y, TERM_WHITE, buf[x]);
	    }
	}

	/* Get the blank line */
	/* if (my_fgets(fp, buf, 1024)) okay = FALSE; */


	/* Load the screen */
	for (y = 0; okay; y++) {
	    /* Get a line of data */
	    if (!file_getl(fp, buf, 1024))
		okay = FALSE;

	    /* Stop on blank line */
	    if (!buf[0])
		break;

	    /* Get the width */
	    len = strlen(buf);

	    /* XXX Restrict to current screen size */
	    if (len >= Term->wid)
		len = Term->wid;

	    /* Show each row */
	    for (x = 0; x < len; x++) {
		/* Get the attr/char */
		(void) (Term_what(x, y, &a, &c));

		/* Look up the attr */
		for (i = 0; i < 16; i++) {
		    /* Use attr matches */
		    if (hack[i] == buf[x])
			a = i;
		}

		/* Put the attr/char */
		Term_draw(x, y, a, c);
	    }

	    /* Place the cursor */
	    Term_gotoxy(x, y);

	}


	/* Get the blank line */
	/* if (my_fgets(fp, buf, 1024)) okay = FALSE; */


	/* Close it */
	file_close(fp);
    }

    /* King or Queen */
    if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL)) {
	p = "Magnificent";
    }

    /* Normal */
    else {
	p = cp_ptr->title[(p_ptr->lev - 1) / 5];
    }

    /* Set offset */
    offset = 11;

    center_string(buf, op_ptr->full_name);
    put_str(buf, 6, offset);

    center_string(buf, "the");
    put_str(buf, 7, offset);

    center_string(buf, p);
    put_str(buf, 8, offset);


    center_string(buf, cp_ptr->name);
    put_str(buf, 10, offset);

    sprintf(tmp, "Level: %d", (int) p_ptr->lev);
    center_string(buf, tmp);
    put_str(buf, 11, offset);

    sprintf(tmp, "Exp: %ld", (long) p_ptr->exp);
    center_string(buf, tmp);
    put_str(buf, 12, offset);

    sprintf(tmp, "AU: %ld", (long) p_ptr->au);
    center_string(buf, tmp);
    put_str(buf, 13, offset);

    if (p_ptr->depth)
	sprintf(tmp, "Killed in %s level %d",
		locality_name[stage_map[p_ptr->stage][LOCALITY]], p_ptr->depth);
    else if (boat)
	sprintf(tmp, "Sailed victorious to Aman.");
    else if (tree)
	sprintf(tmp, "Retired to Fangorn Forest.");
    else
	sprintf(tmp, "Killed in %s town",
		locality_name[stage_map[p_ptr->stage][LOCALITY]]);
    center_string(buf, tmp);
    put_str(buf, 14, offset);

    if (!(boat || tree)) {
	sprintf(tmp, "by %s.", p_ptr->died_from);
	center_string(buf, tmp);
	put_str(buf, 15, offset);
    }
#ifdef _WIN32_WCE
    {
	char *fake_ctime(const unsigned long *fake_time_t);
	sprintf(tmp, "%-.24s", fake_ctime(&ct));
    }
#else
    sprintf(tmp, "%-.24s", ctime(&ct));
#endif
    center_string(buf, tmp);
    put_str(buf, 17, offset);
}
Esempio n. 3
0
/*
 * Hack -- load a screen dump from a file
 *
 * ToDo: Add support for loading/saving screen-dumps with graphics
 * and pseudo-graphics.  Allow the player to specify the filename
 * of the dump.
 */
void do_cmd_load_screen(void)
{
	int i, y, x;

	byte a = 0;
	char c = ' ';

	bool okay = TRUE;

	ang_file *fp;

	char buf[1024];


	/* Build the filename */
	path_build(buf, 1024, ANGBAND_DIR_USER, "dump.txt");
	fp = file_open(buf, MODE_READ, -1);
	if (!fp) return;


	/* Save screen */
	screen_save();


	/* Clear the screen */
	Term_clear();


	/* Load the screen */
	for (y = 0; okay && (y < 24); y++)
	{
		/* Get a line of data */
		if (!file_getl(fp, buf, sizeof(buf))) okay = FALSE;


		/* Show each row */
		for (x = 0; x < 79; x++)
		{
			/* Put the attr/char */
			Term_draw(x, y, TERM_WHITE, buf[x]);
		}
	}

	/* Get the blank line */
	if (!file_getl(fp, buf, sizeof(buf))) okay = FALSE;


	/* Dump the screen */
	for (y = 0; okay && (y < 24); y++)
	{
		/* Get a line of data */
		if (!file_getl(fp, buf, sizeof(buf))) okay = FALSE;

		/* Dump each row */
		for (x = 0; x < 79; x++)
		{
			/* Get the attr/char */
			(void)(Term_what(x, y, &a, &c));

			/* Look up the attr */
			for (i = 0; i < BASIC_COLORS; i++)
			{
				/* Use attr matches */
				if (hack[i] == buf[x]) a = i;
			}

			/* Put the attr/char */
			Term_draw(x, y, a, c);
		}
	}


	/* Close it */
	file_close(fp);


	/* Message */
	msg("Screen dump loaded.");
	message_flush();


	/* Load screen */
	screen_load();
}
Esempio n. 4
0
File: cmd4.c Progetto: jcubic/ToME
/*
 * Hack -- load a screen dump from a file
 */
void do_cmd_load_screen(void)
{
	s32b i, y, x;

	s32b wid, hgt;
	s32b len;

	byte a = 0;
	char c = ' ';

	bool okay = TRUE;

	PHYSFS_file *fff;

	char buf[1024];


	/* Build the filename */
	path_build(buf, 1024, TENGINE_DIR_USER, "dump.txt");

	/* Append to the file */
	fff = my_fopen(buf, "r");

	/* Oops */
	if (!fff) return;


	/* Retrieve the current screen size */
	Term_get_size(&wid, &hgt);

	/* Enter "icky" mode */
	character_icky++;

	/* Save the screen */
	Term_save();

	/* Clear the screen */
	Term_clear();


	/* Load the screen */
	for (y = 0; okay; y++)
	{
		/* Get a line of data */
		if (my_fgets(fff, buf, 1024)) okay = FALSE;

		/* Stop on blank line */
		if (!buf[0]) break;

		/* Ignore off screen lines */
		if (y >= hgt) continue;

		/* Get width */
		len = strlen(buf);

		/* Truncate if it's longer than current screen width */
		if (len > wid) len = wid;

		/* Show each row */
		for (x = 0; x < len; x++)
		{
			/* Put the attr/char */
			Term_draw(x, y, TERM_WHITE, buf[x]);
		}
	}

	/* Dump the screen */
	for (y = 0; okay; y++)
	{
		/* Get a line of data */
		if (my_fgets(fff, buf, 1024)) okay = FALSE;

		/* Stop on blank line */
		if (!buf[0]) break;

		/* Ignore off screen lines */
		if (y >= hgt) continue;

		/* Get width */
		len = strlen(buf);

		/* Truncate if it's longer than current screen width */
		if (len > wid) len = wid;

		/* Dump each row */
		for (x = 0; x < len; x++)
		{
			/* Get the attr/char */
			(void)(Term_what(x, y, &a, &c));

			/* Look up the attr */
			for (i = 0; i < 16; i++)
			{
				/* Use attr matches */
				if (hack[i] == buf[x]) a = i;
			}

			/* Hack -- fake monochrome */
			if (!use_color) a = TERM_WHITE;

			/* Put the attr/char */
			Term_draw(x, y, a, c);
		}
	}


	/* Close it */
	my_fclose(fff);


	/* Message */
	msg_print("Screen dump loaded.");
	msg_print(NULL);


	/* Restore the screen */
	Term_load();

	/* Leave "icky" mode */
	character_icky--;
}