static boolean dospellmenu(const char *prompt, int splaction, /* SPELLMENU_CAST, SPELLMENU_VIEW, or spl_book[] index */ int *spell_no) { int i, n, how, count = 0; struct nh_menuitem items[MAXSPELL + 1]; const int *selected; set_menuitem(&items[count++], 0, MI_HEADING, "Name\tLevel\tCategory\tFail\tMemory", 0, FALSE); for (i = 0; i < MAXSPELL; i++) { if (spellid(i) == NO_SPELL) continue; const char *buf = SPELL_IS_FROM_SPELLBOOK(i) ? msgprintf("%s\t%-d%s\t%s\t%-d%%\t%-d%%", spellname(i), spellev(i), spellknow(i) ? " " : "*", spelltypemnemonic(spell_skilltype(spellid(i))), 100 - percent_success(i), (spellknow(i) * 100 + (KEEN - 1)) / KEEN) : msgprintf("%s\t--\t%s\t?\t--", spellname(i), (spellid(i) == SPID_PRAY || spellid(i) == SPID_TURN) ? "divine" : "ability"); set_menuitem(&items[count++], i + 1, MI_NORMAL, buf, spelllet_from_no(i), FALSE); } how = PICK_ONE; if (splaction >= 0) how = PICK_LETTER; /* We're swapping spells. */ n = display_menu(&(struct nh_menulist){.items = items, .icount = count},
static nh_bool tutorial_player_selection(int *out_role, int *out_race, int *out_gend, int *out_align) { const struct nh_roles_info *ri; struct nh_menuitem items[4]; /* 3 options + quit */ int pick_list[2]; int result; ri = nh_get_roles(); if (!ri) return FALSE; set_menuitem(&items[0], 1, MI_NORMAL, "lawful female dwarf Valkyrie (uses melee and thrown weapons)", 'v', 0); set_menuitem(&items[1], 2, MI_NORMAL, "chaotic male elf Wizard (relies mostly on spells)", 'w', 0); set_menuitem(&items[2], 3, MI_NORMAL, "neutral female human Ranger (good with ranged combat)", 'R', 0); set_menuitem(&items[3], 4, MI_NORMAL, "quit", 'q', 0); result = curses_display_menu(items, 4, "Choose a character", PICK_ONE, pick_list); if (result == -1 || pick_list[0] == -1) return FALSE; switch (pick_list[0]) { case 1: if (!find_role(ri, "Valkyrie", out_role) || !find_race(ri, "dwarf", out_race) || !find_gend(ri, "female", out_gend) || !find_align(ri, "lawful", out_align)) return FALSE; break; case 2: if (!find_role(ri, "Wizard", out_role) || !find_race(ri, "elf", out_race) || !find_gend(ri, "male", out_gend) || !find_align(ri, "chaotic", out_align)) return FALSE; break; case 3: if (!find_role(ri, "Ranger", out_role) || !find_race(ri, "human", out_race) || !find_gend(ri, "female", out_gend) || !find_align(ri, "neutral", out_align)) return FALSE; break; case 4: default: return FALSE; break; } if (!is_valid_character(ri, *out_role, *out_race, *out_gend, *out_align)) return FALSE; return TRUE; }