tty role selection - 'random' default
Instead of just using 'random' as the default choice if the user hits <return> when picking role, race, gender, or alignment, flag it as pre-selected in the menu so that it can be seen to be the default. Someday somebody is going to have to fix up the interaction between PICK_ONE menu and pre-selected choice....
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 extern.h $NHDT-Date: 1452123455 2016/01/06 23:37:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.535 $ */
|
||||
/* NetHack 3.6 extern.h $NHDT-Date: 1453514592 2016/01/23 02:03:12 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.542 $ */
|
||||
/* Copyright (c) Steve Creps, 1988. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -2025,7 +2025,7 @@ E char *FDECL(build_plselection_prompt, (char *, int, int, int, int, int));
|
||||
E char *FDECL(root_plselection_prompt, (char *, int, int, int, int, int));
|
||||
E void NDECL(plnamesuffix);
|
||||
E void FDECL(role_selection_prolog, (int, winid));
|
||||
E void FDECL(role_menu_extra, (int, winid));
|
||||
E void FDECL(role_menu_extra, (int, winid, BOOLEAN_P));
|
||||
E void NDECL(role_init);
|
||||
E const char *FDECL(Hello, (struct monst *));
|
||||
E const char *NDECL(Goodbye);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 role.c $NHDT-Date: 1450320155 2015/12/17 02:42:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.35 $ */
|
||||
/* NetHack 3.6 role.c $NHDT-Date: 1453514597 2016/01/23 02:03:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.36 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985-1999. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -1809,9 +1809,10 @@ winid where;
|
||||
|
||||
/* add a "pick alignment first"-type entry to the specified menu */
|
||||
void
|
||||
role_menu_extra(which, where)
|
||||
role_menu_extra(which, where, preselect)
|
||||
int which;
|
||||
winid where;
|
||||
boolean preselect;
|
||||
{
|
||||
static NEARDATA const char RS_menu_let[] = {
|
||||
'=', /* name */
|
||||
@@ -1941,11 +1942,11 @@ winid where;
|
||||
} else if (which == ROLE_RANDOM) {
|
||||
any.a_int = ROLE_RANDOM;
|
||||
add_menu(where, NO_GLYPH, &any, '*', 0, ATR_NONE, "Random",
|
||||
MENU_UNSELECTED);
|
||||
preselect ? MENU_SELECTED : MENU_UNSELECTED);
|
||||
} else if (which == ROLE_NONE) {
|
||||
any.a_int = ROLE_NONE;
|
||||
add_menu(where, NO_GLYPH, &any, 'q', 0, ATR_NONE, "Quit",
|
||||
MENU_UNSELECTED);
|
||||
preselect ? MENU_SELECTED : MENU_UNSELECTED);
|
||||
} else {
|
||||
impossible("role_menu_extra: bad arg (%d)", which);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 wintty.c $NHDT-Date: 1450363024 2015/12/17 14:37:04 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.118 $ */
|
||||
/* NetHack 3.6 wintty.c $NHDT-Date: 1453514601 2016/01/23 02:03:21 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.124 $ */
|
||||
/* Copyright (c) David Cohrs, 1991 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -467,21 +467,35 @@ makepicks:
|
||||
/* populate the menu with role choices */
|
||||
setup_rolemenu(win, TRUE, RACE, GEND, ALGN);
|
||||
/* add miscellaneous menu entries */
|
||||
role_menu_extra(ROLE_RANDOM, win);
|
||||
role_menu_extra(ROLE_RANDOM, win, TRUE);
|
||||
any.a_int = 0; /* separator, not a choice */
|
||||
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "",
|
||||
MENU_UNSELECTED);
|
||||
role_menu_extra(RS_RACE, win);
|
||||
role_menu_extra(RS_GENDER, win);
|
||||
role_menu_extra(RS_ALGNMNT, win);
|
||||
role_menu_extra(RS_RACE, win, FALSE);
|
||||
role_menu_extra(RS_GENDER, win, FALSE);
|
||||
role_menu_extra(RS_ALGNMNT, win, FALSE);
|
||||
if (gotrolefilter())
|
||||
role_menu_extra(RS_filter, win);
|
||||
role_menu_extra(ROLE_NONE, win); /* quit */
|
||||
role_menu_extra(RS_filter, win, FALSE);
|
||||
role_menu_extra(ROLE_NONE, win, FALSE); /* quit */
|
||||
Strcpy(pbuf, "Pick a role or profession");
|
||||
end_menu(win, pbuf);
|
||||
n = select_menu(win, PICK_ONE, &selected);
|
||||
choice = (n == 1) ? selected[0].item.a_int
|
||||
: (n == 0) ? ROLE_RANDOM : ROLE_NONE;
|
||||
/*
|
||||
* PICK_ONE with preselected choice behaves strangely:
|
||||
* n == -1 -- <escape>, so use quit choice;
|
||||
* n == 0 -- explicitly chose preselected entry,
|
||||
* toggling it off, so use it;
|
||||
* n == 1 -- implicitly chose preselected entry
|
||||
* with <space> or <return>;
|
||||
* n == 2 -- explicitly chose a different entry, so
|
||||
* both it and preselected one are in list.
|
||||
*/
|
||||
if (n > 0) {
|
||||
choice = selected[0].item.a_int;
|
||||
if (n > 1 && choice == ROLE_RANDOM)
|
||||
choice = selected[1].item.a_int;
|
||||
} else
|
||||
choice = (n == 0) ? ROLE_RANDOM : ROLE_NONE;
|
||||
if (selected)
|
||||
free((genericptr_t) selected), selected = 0;
|
||||
destroy_nhwindow(win);
|
||||
@@ -552,21 +566,25 @@ makepicks:
|
||||
/* populate the menu with role choices */
|
||||
setup_racemenu(win, TRUE, ROLE, GEND, ALGN);
|
||||
/* add miscellaneous menu entries */
|
||||
role_menu_extra(ROLE_RANDOM, win);
|
||||
role_menu_extra(ROLE_RANDOM, win, TRUE);
|
||||
any.a_int = 0; /* separator, not a choice */
|
||||
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "",
|
||||
MENU_UNSELECTED);
|
||||
role_menu_extra(RS_ROLE, win);
|
||||
role_menu_extra(RS_GENDER, win);
|
||||
role_menu_extra(RS_ALGNMNT, win);
|
||||
role_menu_extra(RS_ROLE, win, FALSE);
|
||||
role_menu_extra(RS_GENDER, win, FALSE);
|
||||
role_menu_extra(RS_ALGNMNT, win, FALSE);
|
||||
if (gotrolefilter())
|
||||
role_menu_extra(RS_filter, win);
|
||||
role_menu_extra(ROLE_NONE, win); /* quit */
|
||||
role_menu_extra(RS_filter, win, FALSE);
|
||||
role_menu_extra(ROLE_NONE, win, FALSE); /* quit */
|
||||
Strcpy(pbuf, "Pick a race or species");
|
||||
end_menu(win, pbuf);
|
||||
n = select_menu(win, PICK_ONE, &selected);
|
||||
choice = (n == 1) ? selected[0].item.a_int
|
||||
: (n == 0) ? ROLE_RANDOM : ROLE_NONE;
|
||||
if (n > 0) {
|
||||
choice = selected[0].item.a_int;
|
||||
if (n > 1 && choice == ROLE_RANDOM)
|
||||
choice = selected[1].item.a_int;
|
||||
} else
|
||||
choice = (n == 0) ? ROLE_RANDOM : ROLE_NONE;
|
||||
if (selected)
|
||||
free((genericptr_t) selected), selected = 0;
|
||||
destroy_nhwindow(win);
|
||||
@@ -641,21 +659,25 @@ makepicks:
|
||||
/* populate the menu with gender choices */
|
||||
setup_gendmenu(win, TRUE, ROLE, RACE, ALGN);
|
||||
/* add miscellaneous menu entries */
|
||||
role_menu_extra(ROLE_RANDOM, win);
|
||||
role_menu_extra(ROLE_RANDOM, win, TRUE);
|
||||
any.a_int = 0; /* separator, not a choice */
|
||||
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "",
|
||||
MENU_UNSELECTED);
|
||||
role_menu_extra(RS_ROLE, win);
|
||||
role_menu_extra(RS_RACE, win);
|
||||
role_menu_extra(RS_ALGNMNT, win);
|
||||
role_menu_extra(RS_ROLE, win, FALSE);
|
||||
role_menu_extra(RS_RACE, win, FALSE);
|
||||
role_menu_extra(RS_ALGNMNT, win, FALSE);
|
||||
if (gotrolefilter())
|
||||
role_menu_extra(RS_filter, win);
|
||||
role_menu_extra(ROLE_NONE, win); /* quit */
|
||||
role_menu_extra(RS_filter, win, FALSE);
|
||||
role_menu_extra(ROLE_NONE, win, FALSE); /* quit */
|
||||
Strcpy(pbuf, "Pick a gender or sex");
|
||||
end_menu(win, pbuf);
|
||||
n = select_menu(win, PICK_ONE, &selected);
|
||||
choice = (n == 1) ? selected[0].item.a_int
|
||||
: (n == 0) ? ROLE_RANDOM : ROLE_NONE;
|
||||
if (n > 0) {
|
||||
choice = selected[0].item.a_int;
|
||||
if (n > 1 && choice == ROLE_RANDOM)
|
||||
choice = selected[1].item.a_int;
|
||||
} else
|
||||
choice = (n == 0) ? ROLE_RANDOM : ROLE_NONE;
|
||||
if (selected)
|
||||
free((genericptr_t) selected), selected = 0;
|
||||
destroy_nhwindow(win);
|
||||
@@ -726,21 +748,25 @@ makepicks:
|
||||
start_menu(win);
|
||||
any = zeroany; /* zero out all bits */
|
||||
setup_algnmenu(win, TRUE, ROLE, RACE, GEND);
|
||||
role_menu_extra(ROLE_RANDOM, win);
|
||||
role_menu_extra(ROLE_RANDOM, win, TRUE);
|
||||
any.a_int = 0; /* separator, not a choice */
|
||||
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "",
|
||||
MENU_UNSELECTED);
|
||||
role_menu_extra(RS_ROLE, win);
|
||||
role_menu_extra(RS_RACE, win);
|
||||
role_menu_extra(RS_GENDER, win);
|
||||
role_menu_extra(RS_ROLE, win, FALSE);
|
||||
role_menu_extra(RS_RACE, win, FALSE);
|
||||
role_menu_extra(RS_GENDER, win, FALSE);
|
||||
if (gotrolefilter())
|
||||
role_menu_extra(RS_filter, win);
|
||||
role_menu_extra(ROLE_NONE, win); /* quit */
|
||||
role_menu_extra(RS_filter, win, FALSE);
|
||||
role_menu_extra(ROLE_NONE, win, FALSE); /* quit */
|
||||
Strcpy(pbuf, "Pick an alignment or creed");
|
||||
end_menu(win, pbuf);
|
||||
n = select_menu(win, PICK_ONE, &selected);
|
||||
choice = (n == 1) ? selected[0].item.a_int
|
||||
: (n == 0) ? ROLE_RANDOM : ROLE_NONE;
|
||||
if (n > 0) {
|
||||
choice = selected[0].item.a_int;
|
||||
if (n > 1 && choice == ROLE_RANDOM)
|
||||
choice = selected[1].item.a_int;
|
||||
} else
|
||||
choice = (n == 0) ? ROLE_RANDOM : ROLE_NONE;
|
||||
if (selected)
|
||||
free((genericptr_t) selected), selected = 0;
|
||||
destroy_nhwindow(win);
|
||||
|
||||
Reference in New Issue
Block a user