enhanced interactive role selection (trunk only)

[See cvs log for src/role.c for a much longer description.]

     When picking role, race, and so forth, new menu entries allow you to
pick any of the other items before the one currently being handled.  After
picking all four of race, role, gender, and alignment (or if you answered
'y' to "shall I pick for you?"), there is a followup prompt to confirm the
choices.  It's a menu which also provides a chance to rename the character.

     This has only been implemented in win/tty's player_selection(), with
some support code in the core that might be useful to other interfaces.
And so far, the chance to rename is only presented as a menu choice if
you've given an answer to "who are you?" prompt earlier during startup.
Also, ports that use pcmain.c aren't able to perform hero renaming yet.
This commit is contained in:
nethack.rankin
2009-03-22 00:23:57 +00:00
parent c35d7f42be
commit 44cc716fe4
13 changed files with 693 additions and 373 deletions

View File

@@ -80,16 +80,22 @@ main (void)
display_gamewindows();
set_playmode(); /* sets plname to "wizard" for wizard mode */
if (!*plname || !strncmp(plname, "player", 4) ||
!strncmp(plname, "games", 4))
askname();
plnamesuffix(); /* strip suffix from name; calls askname() */
/* again if suffix was whole name */
/* accepts any suffix */
/* strip role,race,&c suffix; calls askname() if plname[] is empty
or holds a generic user name like "player" or "games" */
plnamesuffix();
/* unlike Unix where the game might be invoked with a script
which forces a particular character name for each player
using a shared account, we always allow player to rename
the character during role/race/&c selection */
iflags.renameallowed = TRUE;
Sprintf (lock, "%d%s", getuid (), plname);
getlock ();
getlock();
/*
* First, try to find and restore a save file for specified character.
* We'll return here if new game player_selection() renames the hero.
*/
attempt_restore:
if ((fd = restore_saved_game()) >= 0) {
#ifdef NEWS
if(iflags.news) {
@@ -102,6 +108,8 @@ main (void)
game_active = 1;
if (dorecover(fd)) {
resuming = TRUE; /* not starting new game */
if (discover)
You("are in non-scoring discovery mode.");
if (discover || wizard) {
if(yn("Do you want to keep the save file?") == 'n')
(void) delete_savefile();
@@ -113,14 +121,27 @@ main (void)
}
if (!resuming) {
player_selection();
/* new game: start by choosing role, race, etc;
player might change the hero's name while doing that,
in which case we try to restore under the new name
and skip selection this time if that didn't succeed */
if (!iflags.renameinprogress) {
player_selection();
if (iflags.renameinprogress) {
/* player has renamed the hero while selecting role;
discard current lock file and create another for
the new character name */
delete_levelfile(0); /* remove empty lock file */
getlock();
goto attempt_restore;
}
}
game_active = 1; /* done with selection, draw active game window */
newgame();
if (discover)
You("are in non-scoring discovery mode.");
}
if (discover)
You("are in non-scoring discovery mode.");
UndimMenuBar (); /* Yes, this is the place for it (!) */
moveloop(resuming);

View File

@@ -22,7 +22,8 @@ getlock(void)
{
int fd;
int pid = getpid(); /* Process ID */
Sprintf(lock, "%d%s", getuid(), plname);
set_levelfile_name (lock, 0);
if ((fd = open (lock, O_RDWR | O_EXCL | O_CREAT, LEVL_TYPE)) == -1) {