Ejemplo n.º 1
0
void menu_dynamic_add(menu_type *m, const char *text, int value)
{
	struct menu_entry *head = menu_priv(m);
	/*struct menu_entry *new = mem_zalloc(sizeof *new);*/
	struct menu_entry *newm = ZNEW(struct menu_entry);

	assert(m->row_funcs == &dynamic_iter);

	newm->text = (char*)string_make(text);
	newm->value = value;

	if (head) {
		struct menu_entry *tail = head;
		while (1) {
			if (tail->next)
				tail = tail->next;
			else
				break;
		}

		//tail->next = new;
		tail->next = newm;
		menu_setpriv(m, m->count + 1, head);
	} else {
		//menu_setpriv(m, m->count + 1, new);
		menu_setpriv(m, m->count + 1, newm);
	}
}
Ejemplo n.º 2
0
/**
 * 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;
}
Ejemplo n.º 3
0
/*
 * 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);

}
Ejemplo n.º 4
0
/**
* 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);
}
Ejemplo n.º 5
0
/*
 * 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;
}
Ejemplo n.º 6
0
/*
 * 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);
}
Ejemplo n.º 7
0
/**
 * 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;
}
Ejemplo n.º 8
0
/**
 * 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);
}
Ejemplo n.º 9
0
/*
 * 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;
}
Ejemplo n.º 10
0
void textui_knowledge_init(void)
{
	/* Initialize the menus */
	menu_type *menu = &knowledge_menu;
	menu_init(menu, MN_SKIN_SCROLL, menu_find_iter(MN_ITER_ACTIONS));
	menu_setpriv(menu, N_ELEMENTS(knowledge_actions), knowledge_actions);

	menu->title = "Display current knowledge";
	menu->selections = lower_case;

	/* initialize other static variables */
	if (!obj_group_order) {
		int i;
		int gid = -1;

		obj_group_order = C_ZNEW(TV_GOLD + 1, int);
		atexit(cleanup_cmds);

		/* Allow for missing values */
		for (i = 0; i <= TV_GOLD; i++)
			obj_group_order[i] = -1;

		for (i = 0; 0 != object_text_order[i].tval; i++) {
			if (object_text_order[i].name)
				gid = i;
			obj_group_order[object_text_order[i].tval] = gid;
		}
	}
Ejemplo n.º 11
0
/* 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);
}
Ejemplo n.º 12
0
/**
 * 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;
}
Ejemplo n.º 13
0
/**
 * 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);
}
Ejemplo n.º 14
0
/**
 * 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);
}
Ejemplo n.º 15
0
/**
 * 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;
}
Ejemplo n.º 16
0
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();
}
Ejemplo n.º 17
0
/*
 * 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;
}
Ejemplo n.º 18
0
/*
 * 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();
}
Ejemplo n.º 19
0
/**
 * 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);
}
Ejemplo n.º 20
0
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);
}
Ejemplo n.º 21
0
/*
 * 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;
}
Ejemplo n.º 22
0
/*
 * 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;
}
Ejemplo n.º 23
0
/*
 * 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;
}
Ejemplo n.º 24
0
/**
 * 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;
}
Ejemplo n.º 25
0
/**
 * 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;
}
Ejemplo n.º 26
0
/*
 * Display a list of command types, allowing the user to select one.
 */
static struct cmd_info *textui_action_menu_choose(void)
{
	region area = { 21, 5, 37, 6 };

	struct cmd_info *chosen_command = NULL;

	if (!command_menu)
		command_menu = menu_new(MN_SKIN_SCROLL, &command_menu_iter);

	menu_setpriv(command_menu, N_ELEMENTS(cmds_all) - 1, &chosen_command);
	menu_layout(command_menu, &area);

	/* Set up the screen */
	screen_save();
	window_make(19, 4, 58, 11);

	menu_select(command_menu, 0, TRUE);

	screen_load();

	return chosen_command;
}
Ejemplo n.º 27
0
bool wiz_create_item_action(menu_type *m, const ui_event_data *e, int oid)
{
	ui_event_data ret;
	menu_type *menu;

	int 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 != tvals[oid].tval ||
				of_has(kind->flags, OF_INSTA_ART))
			continue;

		choice[n_choices++] = i;
	}

	screen_save();
	clear_from(0);

	menu = menu_new(MN_SKIN_COLUMNS, &wiz_create_item_submenu);
	menu->selections = all_letters;
	menu->title = format("What kind of %s?", tvals[oid].desc);

	menu_setpriv(menu, n_choices, choice);
	menu_layout(menu, &wiz_create_item_area);
	ret = menu_select(menu, 0);

	screen_load();

	return (ret.type == EVT_ESCAPE);
}
Ejemplo n.º 28
0
/**
 * Display quality ignore menu.
 */
static void quality_menu(void *unused, const char *also_unused)
{
	struct menu menu;
	menu_iter menu_f = { NULL, NULL, quality_display, quality_action, NULL };
	region area = { 0, 0, 0, 0 };

	/* Save screen */
	screen_save();
	clear_from(0);

	/* Set up the menu */
	menu_init(&menu, MN_SKIN_SCROLL, &menu_f);
	menu.title = "Quality ignore menu";
	menu_setpriv(&menu, ITYPE_MAX, quality_values);
	menu_layout(&menu, &area);

	/* Select an entry */
	menu_select(&menu, 0, FALSE);

	/* Load screen */
	screen_load();
	return;
}
Ejemplo n.º 29
0
/*
 * 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, null };
	region area = { 0, 0, 0, 0 };

	/* Save screen */
	screen_save();
	clear_from(0);

	/* Set up the menu */
	menu_init(&menu, MN_SKIN_SCROLL, &menu_f);
	menu.title = "Quality squelch menu";
	menu_setpriv(&menu, TYPE_MAX, quality_values);
	menu_layout(&menu, &area);

	/* Select an entry */
	menu_select(&menu, 0, false);

	/* Load screen */
	screen_load();
	return;
}
Ejemplo n.º 30
0
/** Create and initialise a spell menu, given an object and a validity hook */
static menu_type *spell_menu_new(const object_type * o_ptr,
								 bool(*is_valid) (int spell))
{
	menu_type *m = menu_new(MN_SKIN_SCROLL, &spell_menu_iter);
	struct spell_menu_data *d = mem_alloc(sizeof *d);

	region loc = { -65, 1, 65, -99 };

	/* collect spells from object */
	d->n_spells = spell_collect_from_book(o_ptr, d->spells);
	if (d->n_spells == 0
		|| !spell_okay_list(is_valid, d->spells, d->n_spells)) {
		mem_free(m);
		mem_free(d);
		return NULL;
	}

	/* copy across private data */
	d->is_valid = is_valid;
	d->selected_spell = -1;
	d->browse = FALSE;
	d->book_sval = o_ptr->sval;

	menu_setpriv(m, d->n_spells, d);

	/* set flags */
	m->header = "Name                             Lv Mana Fail Info";
	m->flags = MN_CASELESS_TAGS;
	m->selections = lower_case;
	m->browse_hook = spell_menu_browser;

	/* set size */
	loc.page_rows = d->n_spells + 1;
	menu_layout(m, &loc);

	return m;
}