static int _prompt_tval(int tval) { int idx = -1; menu_t menu = { "Use which type of device?", NULL, NULL, _tval_menu_fn, NULL, 3}; if (tval) { int i; for (i = 0; i < 3; i++) { if (_tval_choices[i].tval == tval) { _tval_choice = _tval_choices[i].name; return tval; } } } idx = menu_choose(&menu); if (idx < 0) return 0; _tval_choice = _tval_choices[idx].name; return _tval_choices[idx].tval; }
static int _get_spells(spell_info* spells, int max) { int idx = -1; int ct = 0; menu_t menu = { "Use which group of talents?", "Browse which group of talents?", NULL, _spell_menu_fn, _groups, 3}; idx = menu_choose(&menu); if (idx < 0) return 0; /* Hack: Add innate Wonder attack to Wild Beginnings */ if (idx == 0) { spell_info* spell = &spells[ct++]; spell->level = 10; spell->cost = 10; spell->fail = calculate_fail_rate(10, 30, p_ptr->stat_ind[A_INT]); spell->fn = wonder_spell; } ct += _get_spells_imp(spells + ct, max - ct, _groups[idx].min_slot, _groups[idx].max_slot); if (ct == 0) msg_print("You don't know any of those talents yet!"); return ct; }
static int _get_spells(spell_info* spells, int max) { int idx = -1; int ct = 0; menu_t menu = { "Use which group?", NULL, NULL, _book_menu_fn, _books, 4 }; idx = menu_choose(&menu); if (idx < 0) return 0; ct = _get_spells_imp(spells, max, idx); if (ct == 0) msg_print("You don't know any of those techniques yet!"); return ct; }
static int _get_spells(spell_info* spells, int max) { int idx = -1; int ct = 0; menu_list_t list = { "Use which group of spells?", "Browse which group of spells?", NULL, _spell_group_name, _spell_group_help, _spell_group_color, _spell_groups, _MAX_SPELL_GROUPS}; idx = menu_choose(&list); if (idx < 0) return 0; ct = _get_spells_imp(spells, max, &_spell_groups[idx]); if (ct == 0) msg_print("You don't know any of those spells yet!"); return ct; }
static _spell_t *_prompt_spell(_spell_t *spells) { _spell_menu_t choices[_MAX_PER_GROUP]; int ct_total = _spells_count(spells); int ct_avail = 0; int i; for (i = 0; i < ct_total; i++) { _spell_ptr spell = &spells[i]; /*if (_calc_charges_total(spell) && !_suppress(spell))*/ { _spell_menu_t *choice = &choices[ct_avail]; choice->spell = spell; choice->charges = _calc_charges(spell); choice->total_charges = _calc_charges_total(spell); choice->fail = _calc_fail_rate(spell); ct_avail++; } } if (!ct_avail) { msg_print("You haven't absorbed any of these items yet."); } else { int idx = -1; char heading[255], prompt1[255], prompt2[255]; menu_t menu = { prompt1, prompt2, heading, _spell_menu_fn, choices, ct_avail}; sprintf(prompt1, "Use which type of %s (%s)?", _group_choice, _tval_choice); sprintf(prompt2, "Browse which type of %s (%s)?", _group_choice, _tval_choice); sprintf(heading, "%-22.22s Chg Tot Fail Info", ""); idx = menu_choose(&menu); if (idx >= 0) return choices[idx].spell; } return NULL; }
int mut_gain_choice(mut_pred pred) { int choices[MAX_MUTATIONS]; int i; int ct = 0; menu_list_t list = { "Gain which mutation?", "Browse which mutation?", NULL, _mut_name, NULL, NULL, choices, 0}; for (i = 0; i < MAX_MUTATIONS; i++) { if (!mut_present(i)) { if (pred == NULL || (pred(i))) choices[ct++] = i; } } if (ct == 0) return -1; list.count = ct; for (;;) { i = menu_choose(&list); if (i >= 0) { char buf[1024]; char buf2[1024]; int idx = choices[i]; mut_name(idx, buf2); sprintf(buf, "You will gain %s. Are you sure?", buf2); if (get_check(buf)) { mut_gain(idx); return idx; } } msg_print("Please make a choice!"); } return -1; }
static _group_t *_prompt_group(int tval) { _group_t *result = NULL; _group_t *groups = _which_groups(tval); if (groups) { int idx = -1; char prompt[255]; menu_t menu = { prompt, NULL, NULL, _group_menu_fn, groups, _groups_count(groups)}; sprintf(prompt, "Use which type of %s?", _tval_choice); idx = menu_choose(&menu); if (idx < 0) return NULL; _group_choice = groups[idx].name; return &groups[idx]; } return result; }
int menu_more() { int i = 0; menu_index = 0; while (aptMainLoop()) { hidScanInput(); u32 kDown = hidKeysDown(); if (kDown & KEY_DOWN) { menu_index++; if (menu_index >= menu_count) menu_index = 0; } if (kDown & KEY_UP) { menu_index--; if (menu_index < 0) menu_index = menu_count - 1; } if (kDown & KEY_A) { if (menu_index == 0 && menu_choose() == 0) { return 0; } else if (menu_index == 1 && menu_netloader() == 0) { return 0; } else if (menu_index == 2) { menu_config(); } else if (menu_index == 3) { reboot(); } else if (menu_index == 4) { poweroff(); } } if (kDown & KEY_B) { return -1; } drawBg(); drawTitle("*** Select an option ***"); for (i = 0; i < menu_count; i++) { drawItem(i == menu_index, 16 * i, menu_item[i]); } // draw "help" switch (menu_index) { case 0: drawInfo("Browse for a file to boot or add a boot entry"); break; case 1: drawInfo("Netload a file (3dsx) from the computer with 3dslink"); break; case 2: drawInfo("Edit boot settings"); break; case 3: drawInfo("Reboot the 3ds..."); break; case 4: drawInfo("Shutdown the 3ds..."); break; default: break; } gfxSwap(); } return -1; }
int menu_more() { menu_index = 0; while (aptMainLoop()) { hidScanInput(); u32 kDown = hidKeysDown(); if (kDown & KEY_DOWN) { menu_index++; if (menu_index >= menu_count) menu_index = 0; } if (kDown & KEY_UP) { menu_index--; if (menu_index < 0) menu_index = menu_count - 1; } if (kDown & KEY_A) { if (menu_index == 0 && menu_choose() == 0) { return 0; } else if (menu_index == 1 && menu_netloader() == 0) { return 0; } else if (menu_index == 2) { menu_config(); } else if (menu_index == 3) { reboot(); } else if (menu_index == 4) { poweroff(); } } if (kDown & KEY_B) { return -1; } gfxClear(); gfxDrawText(GFX_TOP, GFX_LEFT, &fontDefault, "*** Select an option ***", 140, 20); int minX = 16; int maxX = 400 - 16; int minY = 32; int maxY = 240 - 16; drawRect(GFX_TOP, GFX_LEFT, minX, minY, maxX, maxY, 0xFF, 0xFF, 0xFF); minY += 20; int i; for (i = 0; i < menu_count; i++) { if (i >= menu_count) break; if (i == menu_index) { gfxDrawRectangle(GFX_TOP, GFX_LEFT, (u8[]) { 0xDC, 0xDC, 0xDC }, minX + 4, minY + (16 * i), maxX - 23, 15); gfxDrawText(GFX_TOP, GFX_LEFT, &fontSelected, menu_item[i], minX + 6, minY + (16 * i)); } else gfxDrawText(GFX_TOP, GFX_LEFT, &fontDefault, menu_item[i], minX + 6, minY + (16 * i)); }