Beispiel #1
0
/*
 * Menu command: dump character dump to file.
 */
static void death_file(const char *title, int row)
{
	char buf[1024];
	char ftmp[80];

	strnfmt(ftmp, sizeof(ftmp), "%s.txt", op_ptr->base_name);

	if (get_file(ftmp, buf, sizeof buf))
	{
		errr err;

		/* Dump a character file */
		screen_save();
		err = file_character(buf, FALSE);
		screen_load();

		/* Check result */
		if (err)
			msg("Character dump failed!");
		else
			msg("Character dump successful.");

		/* Flush messages */
		message_flush();
	}
}
Beispiel #2
0
void print_dead_character()
{
  /*{ Allow the bozo to print out his dead character...	-KRC-	}*/
  char  command;

  if (get_com("Print character sheet to file? (Y/N)",&command)) {
    if (command == 'y' || command == 'Y') {
      file_character();
    }
  }
};
Beispiel #3
0
/*
 * Hack -- change name
 */
void do_cmd_change_name(void)
{
	ui_event ke;
	int mode = 0;

	const char *p;

	bool more = TRUE;

	/* Prompt */
	p = "['c' to change name, 'f' to file, 'h' to change mode, or ESC]";

	/* Save screen */
	screen_save();

	/* Forever */
	while (more)
	{
		/* Display the player */
		display_player(mode);

		/* Prompt */
		Term_putstr(2, 23, -1, TERM_WHITE, p);

		/* Query */
		ke = inkey_ex();

		if (ke.type == EVT_KBRD) {
			switch (ke.key.code) {
				case ESCAPE: more = FALSE; break;
				case 'c': {
					char namebuf[32] = "";

					if (get_name(namebuf, sizeof namebuf))
					{
						/* Set player name */
						my_strcpy(op_ptr->full_name, namebuf,
								  sizeof(op_ptr->full_name));

						/* Don't change savefile name. */
						process_player_name(FALSE);
					}
					break;
				}

				case 'f': {
					char buf[1024];
					char fname[80];

					strnfmt(fname, sizeof fname, "%s.txt", op_ptr->base_name);

					if (get_file(fname, buf, sizeof buf))
					{
						if (file_character(buf, FALSE) != 0)
							msg("Character dump failed!");
						else
							msg("Character dump successful.");
					}
				}
				
				case 'h':
				case ARROW_LEFT:
				case ' ':
					mode = (mode + 1) % INFO_SCREENS;
					break;

				case 'l':
				case ARROW_RIGHT:
					mode = (mode - 1) % INFO_SCREENS;
					break;
			}
		} else if (ke.type == EVT_MOUSE) {
			/* Just flip through the screens */			
			mode = (mode + 1) % INFO_SCREENS;
		}

		/* Flush messages */
		message_flush();
	}

	/* Load screen */
	screen_load();
}
Beispiel #4
0
/**
 * Hack -- change name
 */
void do_cmd_change_name(void)
{
  ui_event ke;
  
  int col = 0;
  int last_line = 0;
  int top_line = 0;

  const char *p;

  /* Prompt */
  p = "['c' change name, 'f' to file, scroll, or ESC]";
  
  /* Save screen */
  screen_save();

  /* Adjust the buttons */
  button_backup_all();
  button_kill_all();
  button_add("ESC", ESCAPE);
  button_add("Spc", ' ');
  button_add("-", '-');
  button_add("c", 'c');
  button_add("f", 'f');
  button_add("->", ARROW_RIGHT);
  button_add("<-", ARROW_LEFT);
  p_ptr->redraw |= PR_BUTTONS;

  /* Make the array of lines */
  C_WIPE(dumpline, DUMP_MAX_LINES, char_attr_line);
  last_line = make_dump(dumpline, 2);

  /* Forever */
  while (1)
    {
      /* Display the player */
      display_dump(dumpline, top_line, top_line + Term->hgt - 1, col);

      redraw_stuff(p_ptr);

      /* Clear the bottom line */
      prt("", Term->hgt - 1, 0);
      
      /* Prompt */
      Term_putstr(0, Term->hgt - 1, -1, TERM_WHITE, p);
     
      /* Query */
      ke = inkey_ex();
      
      /* Exit */
      if (ke.key.code == ESCAPE) break;
      
      /* Change name */
      if (ke.key.code == 'c')
        {
	  char namebuf[32] = "";

	  if (get_name(namebuf, sizeof namebuf))
	  {
	      /* Set player name */
	      my_strcpy(op_ptr->full_name, namebuf,
			sizeof(op_ptr->full_name));
	      
	      /* Don't change savefile name. */
	      process_player_name(FALSE);
	  }
	  //(void) get_name(namebuf, sizeof namebuf);
	  (void) make_dump(dumpline, 2);
        }
      
      /* File dump */
      else if (ke.key.code == 'f')
	{
	  char ftmp[80];
	  
	  strnfmt(ftmp, sizeof ftmp, "%s.txt", op_ptr->base_name);
	  
	  if (get_string("File name: ", ftmp, 80))
	    {
	      if (ftmp[0] && (ftmp[0] != ' '))
		{
		  if (file_character(ftmp, dumpline, last_line))
		    msg("Character dump failed!");
		  else
		    msg("Character dump successful.");
		}
	    }
	}
      
      /* Scroll down */
      else if (ke.key.code == ARROW_DOWN)
	{
	  if (top_line + Term->hgt - 2 < last_line)
	    top_line++;
	}
      
      /* Page down */
      else if (ke.key.code == ' ')
	{
	  top_line = MIN(last_line - Term->hgt + 2, 
			 top_line + (Term->hgt - 2));
	}
      
      /* Scroll up */
      else if (ke.key.code == ARROW_UP)
	{
	  if (top_line)
	    top_line--;
	}
      
      /* Page up */
      else if (ke.key.code == '-')
	{
	  top_line -= (Term->hgt - 2) / 2;
	  if (top_line < 0) top_line = 0;
	}
      
      /* Scroll left */
      else if (ke.key.code == ARROW_LEFT)
	{
	  if (col)
	    col--;
	}
      
      /* Scroll right */
      else if (ke.key.code == ARROW_RIGHT)
	{
	  if (col < 32)
	    col++;
	}
      
      
      /* Oops */
      else
	{
	  bell(NULL);
	}
      
      /* Flush messages */
      message_flush();
    }

  /* Adjust the buttons */
  button_restore();

  /* Load screen */
  screen_load();
}