/* * Display a list of commands. */ static bool cmd_menu(command_list *list, void *selection_p) { menu_type menu; menu_iter commands_menu = { NULL, NULL, cmd_sub_entry, NULL, NULL }; region area = { 23, 4, 37, 13 }; ui_event evt; struct cmd_info **selection = selection_p; /* Set up the menu */ menu_init(&menu, MN_SKIN_SCROLL, &commands_menu); menu_setpriv(&menu, list->len, list->list); menu_layout(&menu, &area); /* Set up the screen */ screen_save(); window_make(21, 3, 62, 17); /* Select an entry */ evt = menu_select(&menu, 0, TRUE); /* Load de screen */ screen_load(); if (evt.type == EVT_SELECT) *selection = &list->list[menu.cursor]; return FALSE; }
/** * Display list items to choose from */ ui_event item_menu(cmd_code cmd, int mode) { menu_type menu; menu_iter menu_f = {0, 0, get_item_display, get_item_action, 0 }; ui_event evt = { 0 }; size_t max_len = Term->wid - 1; char selections[40]; int i; /* Set up the menu */ WIPE(&menu, menu); menu_init(&menu, MN_SKIN_SCROLL, &menu_f); menu_setpriv(&menu, num_obj, items); for (i = 0; i < num_obj; i++) selections[i] = items[i].key; menu.selections = selections; menu.cmd_keys = "/-0123456789"; get_max_len(&max_len); area.page_rows = menu.count + 1; area.width = max_len; area.col = MIN(Term->wid - 1 - (int) max_len, COL_MAP + tile_width); menu_layout(&menu, &area); evt = menu_select(&menu, 0, TRUE); if (evt.type != EVT_ESCAPE) { evt.key.code = selection; } /* Result */ return (evt); }
/* * Choose and create an instance of an object kind */ static void wiz_create_artifact(void) { size_t num, i; menu_type *menu = menu_new(MN_SKIN_COLUMNS, &wiz_create_item_menu); tval_desc *a_tvals; choose_artifact = TRUE; a_tvals = C_ZNEW(N_ELEMENTS(tvals), tval_desc); for (num = i = 0; i < N_ELEMENTS(tvals); i++) { /* Don't show tvals with no artifacts. */ if (!(tvals[i].can_be_artifact)) continue; /* Increment number of items in list. */ a_tvals[num++] = tvals[i]; } menu->selections = all_letters; menu->title = "What kind of artifact?"; screen_save(); clear_from(0); menu_setpriv(menu, num, a_tvals); menu_layout(menu, &wiz_create_item_area); menu_select(menu, 0, FALSE); screen_load(); FREE(a_tvals); }
/** * Display list available specialties. */ void view_spec_menu(void) { menu_type menu; menu_iter menu_f = { view_spec_tag, 0, view_spec_display, 0, 0 }; region loc = { 0, 0, 70, -99 }; char buf[80]; /* Save the screen and clear it */ screen_save(); /* Prompt choices */ sprintf(buf, "Race, class, and specialties abilities (%c-%c, ESC=exit): ", I2A(0), I2A(spec_known - 1)); /* Set up the menu */ menu_init(&menu, MN_SKIN_SCROLL, &menu_f); menu.header = buf; menu_setpriv(&menu, spec_known, spec_list); loc.page_rows = spec_known + 1; menu.flags = MN_DBL_TAP; menu.browse_hook = view_spec_menu_browser; region_erase_bordered(&loc); menu_layout(&menu, &loc); menu_select(&menu, 0); /* Load screen */ screen_load(); return; }
/* * Display quality squelch menu. */ static void quality_menu(void *unused, const char *also_unused) { menu_type menu; menu_iter menu_f = { NULL, NULL, quality_display, quality_action }; region area = { 1, 5, -1, -1 }; /* Save screen */ screen_save(); clear_from(0); /* Help text */ prt("Quality squelch menu", 0, 0); Term_gotoxy(1, 1); text_out_to_screen(TERM_L_RED, "Use the movement keys to navigate, and Enter to change settings."); /* Set up the menu */ menu_init(&menu, MN_SKIN_SCROLL, &menu_f); menu_setpriv(&menu, TYPE_MAX, quality_values); menu_layout(&menu, &area); /* Select an entry */ menu_select(&menu, 0); /* Load screen */ screen_load(); return; }
/* * Choose and create an instance of an object kind */ static void wiz_create_item(void) { int tvals[TV_MAX]; size_t i, n; menu_type *menu = menu_new(MN_SKIN_COLUMNS, &wiz_create_item_menu); menu->selections = all_letters; menu->title = "What kind of object?"; /* Make a list of all tvals for the filter */ for (i = 0, n = 0; i < TV_MAX; i++) { if (!kb_info[i].name) continue; tvals[n++] = i; } screen_save(); clear_from(0); menu_setpriv(menu, TV_MAX, kb_info); menu_set_filter(menu, tvals, n); menu_layout(menu, &wiz_create_item_area); menu_select(menu, 0, FALSE); screen_load(); /* Redraw map */ p_ptr->redraw |= (PR_MAP | PR_ITEMLIST); handle_stuff(p_ptr); }
/* Set up one of our menus ready to display choices for a birth question. This is slightly involved. */ static void init_birth_menu(menu_type *menu, int n_choices, int initial_choice, const region *reg, bool allow_random, browse_f aux) { struct birthmenu_data *menu_data; /* Initialise a basic menu */ menu_init(menu, MN_SKIN_SCROLL, &birth_iter); /* A couple of behavioural flags - we want selections letters in lower case and a double tap to act as a selection. */ menu->selections = lower_case; menu->flags = MN_DBL_TAP; /* Copy across the game's suggested initial selection, etc. */ menu->cursor = initial_choice; /* Allocate sufficient space for our own bits of menu information. */ menu_data = mem_alloc(sizeof *menu_data); /* Allocate space for an array of menu item texts and help texts (where applicable) */ menu_data->items = mem_alloc(n_choices * sizeof *menu_data->items); menu_data->allow_random = allow_random; /* Set private data */ menu_setpriv(menu, n_choices, menu_data); /* Set up the "browse" hook to display help text (where applicable). */ menu->browse_hook = aux; /* Lay out the menu appropriately */ menu_layout(menu, reg); }
/** * Display a list of commands. */ bool show_cmd_menu(bool object) { menu_type menu; menu_iter commands_menu = { show_tag, 0, show_display, show_action, 0 }; region area = { 15, (object ? 2 : 1), 20, 0 }; ui_event evt = EVENT_EMPTY; int cursor = 0; /* Size of menu */ area.page_rows = poss + (object ? 1 : 0); /* Set up the menu */ WIPE(&menu, menu); menu_init(&menu, MN_SKIN_SCROLL, &commands_menu); menu.cmd_keys = "\x8B\x8C\n\r"; area.page_rows = poss + (object ? 1 : 0); menu_setpriv(&menu, poss, comm); menu_layout(&menu, &area); /* Select an entry */ evt = menu_select(&menu, cursor, TRUE); return (evt.type != EVT_ESCAPE); }
/** * Display list of curses to choose from */ int curse_menu(struct object *obj, char *dice_string) { menu_iter menu_f = { 0, 0, get_curse_display, get_curse_action, 0 }; struct menu *m = menu_new(MN_SKIN_SCROLL, &menu_f); int row; unsigned int length = 0; int i, count = 0; size_t array_size = z_info->curse_max * sizeof(struct curse_menu_data); struct curse_menu_data *available = mem_zalloc(array_size); static region area = { 20, 1, -1, -2 }; /* Count and then list the curses */ for (i = 1; i < z_info->curse_max; i++) { if ((obj->known->curses[i].power > 0) && (obj->known->curses[i].power < 100) && player_knows_curse(player, i)) { available[count].index = i; available[count].power = obj->curses[i].power; length = MAX(length, strlen(curses[i].name) + 13); count++; } } if (!count) { mem_free(available); return 0; } /* Set up the menu */ menu_setpriv(m, count, available); m->header = format(" Remove which curse (spell strength %s)?", dice_string); m->selections = lower_case; m->flags = (MN_PVT_TAGS); m->browse_hook = curse_menu_browser; /* Set up the item list variables */ selection = 0; /* Set up the menu region */ area.page_rows = m->count + 2; area.row = 1; area.col = (Term->wid - 1 - length) / 2; if (area.col <= 3) area.col = 0; area.width = MAX(length + 1, strlen(m->header)); for (row = area.row; row < area.row + area.page_rows; row++) prt("", row, MAX(0, area.col - 1)); menu_layout(m, &area); /* Choose */ menu_select(m, 0, true); /* Clean up */ mem_free(available); mem_free(m); /* Result */ return selection; }
/** * Handle character death */ void death_screen(void) { const region area = { 51, 2, 0, N_ELEMENTS(death_actions) }; /* Dump bones file */ make_bones(); /* Handle retirement */ if (p_ptr->total_winner) kingly(); /* Save dead player */ if (!old_save()) { msg_print("death save failed!"); message_flush(); } /* Get time of death */ #ifdef _WIN32_WCE { unsigned long fake_time(unsigned long *fake_time_t); fake_time(&death_time); } #else (void) time(&death_time); #endif /* You are dead */ print_tomb(); /* Hack - Know everything upon death */ death_knowledge(); /* Enter player in high score list */ enter_score(&death_time); /* Flush all input keys */ flush(); /* Flush messages */ msg_print(NULL); if (!death_menu) { death_menu = menu_new_action(death_actions, N_ELEMENTS(death_actions)); death_menu->flags = MN_CASELESS_TAGS; } menu_layout(death_menu, &area); do { menu_select(death_menu, 0); } while (!get_check("Do you want to quit? ")); }
/* * Handle character death */ void death_screen(void) { bool done = FALSE; const region area = { 51, 2, 0, N_ELEMENTS(death_actions) }; /* Retire in the town in a good state */ if (p_ptr->total_winner) { p_ptr->depth = 0; my_strcpy(p_ptr->died_from, "Ripe Old Age", sizeof(p_ptr->died_from)); p_ptr->exp = p_ptr->max_exp; p_ptr->lev = p_ptr->max_lev; p_ptr->au += 10000000L; display_winner(); } /* Get time of death */ (void)time(&death_time); print_tomb(); death_knowledge(); enter_score(&death_time); /* Flush all input and output */ flush(); message_flush(); /* Display and use the death menu */ if (!death_menu) { death_menu = menu_new_action(death_actions, N_ELEMENTS(death_actions)); death_menu->flags = MN_CASELESS_TAGS; } menu_layout(death_menu, &area); while (!done) { ui_event e = menu_select(death_menu, EVT_KBRD); if (e.type == EVT_KBRD) { if (e.key.code == KTRL('X')) break; } else if (e.type == EVT_SELECT) { done = get_check("Do you want to quit? "); } } /* Save dead player */ if (!savefile_save(savefile)) { msg("death save failed!"); message_flush(); } }
/** * Display list of monster traps. */ bool trap_menu(void) { menu_type menu; menu_iter menu_f = { trap_tag, 0, trap_display, trap_action, 0 }; region area = { 15, 1, 48, -1 }; ui_event_data evt = { EVT_NONE, 0, 0, 0, 0 }; size_t i, num = 0; u16b *choice; /* See how many traps available */ if (player_has(PF_EXTRA_TRAP)) num = 1 + (p_ptr->lev / 4); else num = 1 + (p_ptr->lev / 6); /* Create the array */ choice = C_ZNEW(num, u16b); /* Obvious */ for (i = 0; i < num; i++) { choice[i] = i; } /* Clear space */ area.page_rows = num + 2; /* Return here if there are no traps */ if (!num) { FREE(choice); return FALSE; } /* Save the screen and clear it */ screen_save(); /* Help text */ /* Set up the menu */ WIPE(&menu, menu); menu_init(&menu, MN_SKIN_SCROLL, &menu_f); menu.title = "Choose an advanced monster trap (ESC to cancel):"; menu_setpriv(&menu, num, choice); menu_layout(&menu, &area); prt("", area.row + 1, area.col); /* Select an entry */ evt = menu_select(&menu, 0); /* Free memory */ FREE(choice); /* Load screen */ screen_load(); return (evt.type != EVT_ESCAPE); }
/** * Display list of curses to choose from */ struct curse *curse_menu(struct object *obj) { menu_iter menu_f = { 0, 0, get_curse_display, get_curse_action, 0 }; struct menu *m = menu_new(MN_SKIN_SCROLL, &menu_f); int row; unsigned int length = 0; int count = 0; struct curse *curse = obj->curses; struct curse **available; static region area = { 20, 1, -1, -2 }; /* Count and then list the curses */ while (curse) { count++; curse = curse->next; } if (!count) { return NULL; } available = mem_zalloc(count * sizeof(struct curse *)); count = 0; for (curse = obj->curses; curse; curse = curse->next) { available[count++] = curse; length = MAX(length, strlen(curse->name)); } /* Set up the menu */ menu_setpriv(m, count, available); m->header = "Remove which curse?"; m->selections = lower_case; m->flags = (MN_PVT_TAGS); m->browse_hook = curse_menu_browser; /* Set up the item list variables */ selection = NULL; /* Set up the menu region */ area.page_rows = m->count + 1; area.row = 1; area.col = (Term->wid - 1 - length) / 2; if (area.col <= 3) area.col = 0; area.width = MAX(length + 1, strlen(m->header)); for (row = area.row; row < area.row + area.page_rows; row++) prt("", row, MAX(0, area.col - 1)); menu_layout(m, &area); /* Choose */ menu_select(m, 0, true); /* Clean up */ mem_free(m); /* Result */ return selection; }
/** * Display list of places to jump to. */ bool jump_menu(int level, int *location) { menu_type menu; menu_iter menu_f = { jump_tag, 0, jump_display, jump_action, 0 }; region area = { 15, 1, 48, -1 }; ui_event_data evt = { EVT_NONE, 0, 0, 0, 0 }; int cursor = 0, j = 0; size_t i; u16b *choice; /* Dungeon only is easy */ if (OPT(adult_dungeon)) { *location = level + 1; return TRUE; } /* Create the array */ choice = C_ZNEW(15, u16b); /* Get the possible stages */ for (i = 0; i < NUM_STAGES; i++) if ((stage_map[i][DEPTH] == level) && (stage_map[i][LOCALITY] != 0)) choice[j++] = i; /* Clear space */ area.page_rows = j + 2; /* Save the screen and clear it */ screen_save(); /* Set up the menu */ WIPE(&menu, menu); menu.title = "Which region do you want to be transported to?"; menu.cmd_keys = " \n\r"; menu_init(&menu, MN_SKIN_SCROLL, &menu_f); menu_setpriv(&menu, j, choice); menu_layout(&menu, &area); /* Select an entry */ evt = menu_select(&menu, cursor); /* Set it */ if (evt.type == EVT_SELECT) *location = place; /* Free memory */ FREE(choice); /* Load screen */ screen_load(); return (evt.type != EVT_ESCAPE); }
/** * Display list of svals to be ignored. */ static bool sval_menu(int tval, const char *desc) { struct menu *menu; region area = { 1, 2, -1, -1 }; ignore_choice *choices; int n_choices = ignore_collect_kind(tval, &choices); if (!n_choices) return false; /* Sort by name in ignore menus except for categories of items that are * aware from the start */ switch (tval) { case TV_LIGHT: case TV_MAGIC_BOOK: case TV_PRAYER_BOOK: case TV_DRAG_ARMOR: case TV_GOLD: /* leave sorted by sval */ break; default: /* sort by name */ sort(choices, n_choices, sizeof(*choices), cmp_ignore); } /* Save the screen and clear it */ screen_save(); clear_from(0); /* Help text */ prt(format("Ignore the following %s:", desc), 0, 0); /* Run menu */ menu = menu_new(MN_SKIN_COLUMNS, &ignore_sval_menu); menu_setpriv(menu, n_choices, choices); menu->cmd_keys = "Tt"; menu_layout(menu, &area); menu_set_cursor_x_offset(menu, 1); /* Place cursor in brackets. */ menu_select(menu, 0, false); /* Free memory */ mem_free(choices); /* Load screen */ screen_load(); return true; }
/* * Handle character death */ void death_screen(void) { const region area = { 51, 2, 0, N_ELEMENTS(death_actions) }; /* Retire in the town in a good state */ if (p_ptr->total_winner) { p_ptr->depth = 0; my_strcpy(p_ptr->died_from, "Ripe Old Age", sizeof(p_ptr->died_from)); p_ptr->exp = p_ptr->max_exp; p_ptr->lev = p_ptr->max_lev; p_ptr->au += 10000000L; display_winner(); } /* Save dead player */ if (!savefile_save(savefile)) { msg("death save failed!"); message_flush(); } /* Get time of death */ (void)time(&death_time); print_tomb(); death_knowledge(); enter_score(&death_time); /* Flush all input and output */ flush(); message_flush(); if (!death_menu) { death_menu = menu_new_action(death_actions, N_ELEMENTS(death_actions)); death_menu->flags = MN_CASELESS_TAGS; } menu_layout(death_menu, &area); do { menu_select(death_menu, 0); } while (!get_check("Do you want to quit? ")); }
/** * Create Spoiler files */ void do_cmd_spoilers(void) { if (!spoil_menu) { spoil_menu = menu_new_action(spoil_actions, N_ELEMENTS(spoil_actions)); spoil_menu->selections = lower_case; spoil_menu->title = "Create spoilers"; } screen_save(); clear_from(0); menu_layout(spoil_menu, &SCREEN_REGION); menu_select(spoil_menu, 0, false); screen_load(); }
static void wiz_gf_demo(void) { menu_type *m = menu_new(MN_SKIN_SCROLL, &gf_iter); region loc = { 0, 0, 0, 0 }; menu_setpriv(m, GF_MAX, NULL); m->title = "GF_ types display"; menu_layout(m, &loc); screen_save(); clear_from(0); menu_select(m, 0, FALSE); screen_load(); }
/* * Display list of svals to be squelched. */ static bool sval_menu(int tval, const char *desc) { menu_type *menu; region area = { 1, 2, -1, -1 }; squelch_choice *choices; int n_choices = squelch_collect_kind(tval, &choices); if (!n_choices) return false; /* sort by name in squelch menus except for categories of items that are aware from the start */ switch (tval) { case TV_LIGHT: case TV_MAGIC_BOOK: case TV_PRAYER_BOOK: case TV_DRAG_ARMOR: case TV_GOLD: /* leave sorted by sval */ break; default: /* sort by name */ sort(choices, n_choices, sizeof(*choices), cmp_squelch); } /* Save the screen and clear it */ screen_save(); clear_from(0); /* Help text */ prt(format("Squelch the following %s:", desc), 0, 0); /* Run menu */ menu = menu_new(MN_SKIN_COLUMNS, &squelch_sval_menu); menu_setpriv(menu, n_choices, choices); menu_layout(menu, &area); menu_select(menu, 0, false); /* Free memory */ FREE(choices); /* Load screen */ screen_load(); return true; }
/* * Choose and create an instance of an object kind */ static void wiz_create_item(void) { menu_type *menu = menu_new(MN_SKIN_COLUMNS, &wiz_create_item_menu); menu->selections = all_letters; menu->title = "What kind of object?"; screen_save(); clear_from(0); menu_setpriv(menu, N_ELEMENTS(tvals), tvals); menu_layout(menu, &wiz_create_item_area); menu_select(menu, 0); screen_load(); }
/** * Interact with some options */ static void option_toggle_menu(const char *name, int page) { int i; struct menu *m = menu_new(MN_SKIN_SCROLL, &option_toggle_iter); /* for all menus */ m->prompt = "Set option (y/n/t), '?' for information"; m->cmd_keys = "?YyNnTt"; m->selections = "abcdefghijklmopqrsuvwxz"; m->flags = MN_DBL_TAP; /* We add 10 onto the page amount to indicate we're at birth */ if (page == OPT_PAGE_BIRTH) { m->prompt = "You can only modify these options at character birth. '?' for information"; m->cmd_keys = "?"; m->flags = MN_NO_TAGS; } else if (page == OPT_PAGE_BIRTH + 10) { page -= 10; } /* for this particular menu */ m->title = name; /* Find the number of valid entries */ for (i = 0; i < OPT_PAGE_PER; i++) { if (option_page[page][i] == OPT_none) break; } /* Set the data to the player's options */ menu_setpriv(m, OPT_MAX, &op_ptr->opt); menu_set_filter(m, option_page[page], i); menu_layout(m, &SCREEN_REGION); /* Run the menu */ screen_save(); clear_from(0); menu_select(m, 0, false); screen_load(); mem_free(m); }
static bool wiz_create_item_action(menu_type *m, const ui_event *e, int oid) { ui_event ret; menu_type *menu; char buf[80]; object_kind *choice[60]; int n_choices; int i; if (e->type != EVT_SELECT) return TRUE; for (n_choices = 0, i = 1; (n_choices < 60) && (i < z_info->k_max); i++) { object_kind *kind = &k_info[i]; if (kind->tval != oid || of_has(kind->flags, OF_INSTA_ART)) continue; choice[n_choices++] = kind; } screen_save(); clear_from(0); menu = menu_new(MN_SKIN_COLUMNS, &wiz_create_item_submenu); menu->selections = all_letters; object_base_name(buf, sizeof buf, oid, TRUE); menu->title = string_make(format("What kind of %s?", buf)); menu_setpriv(menu, n_choices, choice); menu_layout(menu, &wiz_create_item_area); ret = menu_select(menu, 0, FALSE); screen_load(); string_free((char *)menu->title); return (ret.type == EVT_ESCAPE); }
/* * Display and handle the main squelching menu. */ void do_cmd_options_item(void *unused, cptr title) { menu_type menu; menu_init(&menu, MN_SKIN_SCROLL, &options_item_iter); menu_setpriv(&menu, N_ELEMENTS(sval_dependent) + N_ELEMENTS(extra_item_options) + 1, NULL); menu.title = title; menu_layout(&menu, &SCREEN_REGION); screen_save(); clear_from(0); menu_select(&menu, 0); screen_load(); p_ptr->notice |= PN_SQUELCH; return; }
/** * Display the options main menu. */ void do_cmd_options(void) { if (!option_menu) { /* Main option menu */ option_menu = menu_new_action(option_actions, N_ELEMENTS(option_actions)); option_menu->title = "Options Menu"; option_menu->flags = MN_CASELESS_TAGS; } screen_save(); clear_from(0); menu_layout(option_menu, &SCREEN_REGION); menu_select(option_menu, 0, false); screen_load(); }
/* * Display and handle the main squelching menu. */ void do_cmd_options_item(const char *title, int row) { menu_type menu; menu_init(&menu, MN_SKIN_SCROLL, &options_item_iter); menu_setpriv(&menu, N_ELEMENTS(sval_dependent) + N_ELEMENTS(extra_item_options) + 1, null); menu.title = title; menu_layout(&menu, &SCREEN_REGION); screen_save(); clear_from(0); menu_select(&menu, 0, false); screen_load(); p_ptr.notice |= PN_SQUELCH; return; }
/** * Handle character death */ void death_screen(void) { struct menu *death_menu; bool done = false; const region area = { 51, 2, 0, N_ELEMENTS(death_actions) }; /* Winner */ if (player->total_winner) { display_winner(); } /* Tombstone */ print_tomb(); /* Flush all input and output */ event_signal(EVENT_INPUT_FLUSH); event_signal(EVENT_MESSAGE_FLUSH); /* Display and use the death menu */ death_menu = menu_new_action(death_actions, N_ELEMENTS(death_actions)); death_menu->flags = MN_CASELESS_TAGS; menu_layout(death_menu, &area); while (!done) { ui_event e = menu_select(death_menu, EVT_KBRD, false); if (e.type == EVT_KBRD) { if (e.key.code == KTRL('X')) break; } else if (e.type == EVT_SELECT) { done = get_check("Do you want to quit? "); } } menu_free(death_menu); }
/** * Handle keypresses. */ static bool quality_action(struct menu *m, const ui_event *event, int oid) { struct menu menu; menu_iter menu_f = { NULL, NULL, quality_subdisplay, NULL, NULL }; region area = { 37, 2, 29, IGNORE_MAX }; ui_event evt; int count; /* Display at the right point */ area.row += oid; /* Save */ screen_save(); /* Work out how many options we have */ count = IGNORE_MAX; if ((oid == ITYPE_RING) || (oid == ITYPE_AMULET)) count = area.page_rows = IGNORE_BAD + 1; /* Run menu */ menu_init(&menu, MN_SKIN_SCROLL, &menu_f); menu_setpriv(&menu, count, quality_values); /* Stop menus from going off the bottom of the screen */ if (area.row + menu.count > Term->hgt - 1) area.row += Term->hgt - 1 - area.row - menu.count; menu_layout(&menu, &area); window_make(area.col - 2, area.row - 1, area.col + area.width + 2, area.row + area.page_rows); evt = menu_select(&menu, 0, true); /* Set the new value appropriately */ if (evt.type == EVT_SELECT) ignore_level[oid] = menu.cursor; /* Load and finish */ screen_load(); return true; }
/* * Handle keypresses. */ static bool quality_action(menu_type *m, const ui_event_data *event, int oid) { menu_type menu; menu_iter menu_f = { NULL, NULL, quality_subdisplay, NULL }; region area = { 24, 5, 29, SQUELCH_MAX }; ui_event_data evt; int cursor; /* Display at the right point */ area.row += oid; cursor = squelch_level[oid]; /* Save */ screen_save(); /* Work out how many options we have */ int count = SQUELCH_MAX; if ((oid == TYPE_RING) || (oid == TYPE_AMULET)) count = area.page_rows = SQUELCH_BAD + 1; /* Run menu */ menu_init(&menu, MN_SKIN_SCROLL, &menu_f); menu_setpriv(&menu, count, quality_values); /* Stop menus from going off the bottom of the screen */ if (area.row + menu.count > Term->hgt - 1) area.row += Term->hgt - 1 - area.row - menu.count; menu_layout(&menu, &area); window_make(area.col - 2, area.row - 1, area.col + area.width + 2, area.row + area.page_rows); evt = menu_select(&menu, 0); /* Set the new value appropriately */ if (evt.type == EVT_SELECT) squelch_level[oid] = menu.cursor; /* Load and finish */ screen_load(); return TRUE; }
/** * Interact with "colors" */ static void do_cmd_colors(const char *title, int row) { screen_save(); clear_from(0); if (!color_menu) { color_menu = menu_new_action(color_events, N_ELEMENTS(color_events)); color_menu->title = title; color_menu->selections = lower_case; color_menu->browse_hook = colors_browse_hook; } menu_layout(color_menu, &SCREEN_REGION); menu_select(color_menu, 0, false); screen_load(); }
/** * Display and handle the main ignoring menu. */ void do_cmd_options_item(const char *title, int row) { struct menu menu; menu_init(&menu, MN_SKIN_SCROLL, &options_item_iter); menu_setpriv(&menu, N_ELEMENTS(sval_dependent) + N_ELEMENTS(extra_item_options) + 1, NULL); menu.title = title; menu_layout(&menu, &SCREEN_REGION); screen_save(); clear_from(0); menu_select(&menu, 0, false); screen_load(); player->upkeep->notice |= PN_IGNORE; return; }