コード例 #1
0
ファイル: obj-ui.c プロジェクト: kaypy/FAangband
/**
 * Display an entry on the item menu
 */
void get_item_display(menu_type *menu, int oid, bool cursor, int row, int col,
		      int width)
{
    struct object_menu_data *choice = menu_priv(menu);
    size_t max_len = Term->wid - 1;

    const object_type *o_ptr = choice[oid].object;

    int ex_width = 0;

    /* Do we even have a menu? */
    if (!show_list) return;

    /* Width of extra fields */
    if (olist_mode & OLIST_WEIGHT)
	ex_width += 9;
    if (olist_mode & OLIST_PRICE)
	ex_width += 9;
    if (olist_mode & OLIST_FAIL)
	ex_width += 10;

    /* Get max length */
    get_max_len(&max_len);

    /* Print it */
    show_obj(oid, max_len, items[oid].label, o_ptr, cursor, olist_mode);
}
コード例 #2
0
ファイル: wizard.c プロジェクト: mtadd/angband
bool wiz_create_item_subaction(menu_type *m, const ui_event *e, int oid)
{
	object_kind **choices = menu_priv(m);
	object_kind *kind = choices[oid];

	object_type *i_ptr;
	object_type object_type_body;

	if (e->type != EVT_SELECT)
		return TRUE;


	/* Get local object */
	i_ptr = &object_type_body;

	/* Create the item */
	object_prep(i_ptr, kind, p_ptr->depth, RANDOMISE);

	/* Apply magic (no messages, no artifacts) */
	apply_magic(i_ptr, p_ptr->depth, FALSE, FALSE, FALSE);

	/* Mark as cheat, and where created */
	i_ptr->origin = ORIGIN_CHEAT;
	i_ptr->origin_depth = p_ptr->depth;

	if (kind->tval == TV_GOLD)
		make_gold(i_ptr, p_ptr->depth, kind->sval);

	/* Drop the object from heaven */
	drop_near(cave, i_ptr, 0, p_ptr->py, p_ptr->px, TRUE);

	return FALSE;
}
コード例 #3
0
/* ------------------------------------------------------------------------
 * MN_STRINGS HELPER FUNCTIONS
 *
 * MN_STRINGS is the type of menu iterator that displays a simple list of 
 * strings - no action is associated, as selection will just return the index.
 * ------------------------------------------------------------------------ */
static void display_string(menu_type *m, int oid, bool cursor,
		int row, int col, int width)
{
	char **items = menu_priv(m);
	byte color = curs_attrs[CURS_KNOWN][0 != cursor];
	Term_putstr(col, row, width, color, items[oid]);
}
コード例 #4
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);
	}
}
コード例 #5
0
ファイル: cmd0.c プロジェクト: NickMcConnell/RePosBand
/* Display an entry on a command menu */
static void cmd_sub_entry(menu_type *menu, int oid, bool cursor, int row, int col, int width)
{
	byte attr = (cursor ? TERM_L_BLUE : TERM_WHITE);
	const struct generic_command *commands = menu_priv(menu);

	(void)width;

	/* Write the description */
	Term_putstr(col, row, -1, attr, commands[oid].desc);

	/* Include keypress */
	Term_addch(attr, ' ');
	Term_addch(attr, '(');

	/* KTRL()ing a control character does not alter it at all */
	if (KTRL(commands[oid].key) == commands[oid].key)
	{
		Term_addch(attr, '^');
		Term_addch(attr, UN_KTRL(commands[oid].key));
	}
	else
	{
		Term_addch(attr, commands[oid].key);
	}

	Term_addch(attr, ')');
}
コード例 #6
0
static void dynamic_display(menu_type *m, int oid, bool cursor,
		int row, int col, int width)
{
	struct menu_entry *entry;
	byte color = curs_attrs[CURS_KNOWN][0 != cursor];

	for (entry = menu_priv(m); oid; oid--) {
		entry = entry->next;
		assert(entry);
	}

	/*if ((entry->text[0] == '$')
		&& (entry->text[1] >= 'A') && (entry->text[1] < 'P'))
	{*/
		/* if the entry starts with a custom color, use it */
		/*Term_putstr(col, row, width, entry->text[1]-'A', entry->text+2);*/
	if (entry->text[0] == '$') {
		if (entry->text[1] != '$') {
			color = curs_attrs[CURS_UNKNOWN][0 != cursor];
		}
		Term_putstr(col, row, width, color, entry->text+1);
	} else {
		Term_putstr(col, row, width, color, entry->text);
	}
}
コード例 #7
0
ファイル: ui-spell.c プロジェクト: Raale/angband
/**
 * Is item oid valid?
 */
static int spell_menu_valid(menu_type *m, int oid)
{
	struct spell_menu_data *d = menu_priv(m);
	int *spells = d->spells;

	return d->is_valid(spells[oid]);
}
コード例 #8
0
ファイル: cmd-process.c プロジェクト: KertaLosataure/angband
static bool cmd_list_action(menu_type *m, const ui_event *event, int oid)
{
	if (event->type == EVT_SELECT)
		return cmd_menu(&cmds_all[oid], menu_priv(m));
	else
		return FALSE;
}
コード例 #9
0
ファイル: ui-spell.c プロジェクト: Raale/angband
/**
 * Display a row of the spell menu
 */
static void spell_menu_display(menu_type *m, int oid, bool cursor,
		int row, int col, int wid)
{
	struct spell_menu_data *d = menu_priv(m);
	int spell = d->spells[oid];
	const magic_type *s_ptr = &p_ptr->class->spells.info[spell];

	char help[30];
	char out[80];

	int attr;
	const char *illegible = NULL;
	const char *comment = NULL;

	if (s_ptr->slevel >= 99) {
		illegible = "(illegible)";
		attr = TERM_L_DARK;
	} else if (p_ptr->spell_flags[spell] & PY_SPELL_FORGOTTEN) {
		comment = " forgotten";
		attr = TERM_YELLOW;
	} else if (p_ptr->spell_flags[spell] & PY_SPELL_LEARNED) {
		if (p_ptr->spell_flags[spell] & PY_SPELL_WORKED) {
			/* Get extra info */
			get_spell_info(p_ptr->class->spell_book, spell, help, sizeof(help));
			comment = help;
			attr = TERM_WHITE;
		} else {
コード例 #10
0
static void menu_action_display(menu_type *m, int oid, bool cursor, int row, int col, int width)
{
	menu_action *acts = menu_priv(m);
	/*byte color = curs_attrs[!(acts[oid].flags & (MN_ACT_GRAYED))][0 != cursor];*/
	byte color = curs_attrs[(acts[oid].flags & (MN_ACTIVE))][0 != cursor];

	display_action_aux(&acts[oid], color, row, col, width);
}
コード例 #11
0
ファイル: wizard.c プロジェクト: mtadd/angband
/** Object kind selection */
void wiz_create_item_subdisplay(menu_type *m, int oid, bool cursor,
		int row, int col, int width)
{
	object_kind **choices = menu_priv(m);
	char buf[80];

	object_kind_name(buf, sizeof buf, choices[oid], TRUE);
	c_prt(curs_attrs[CURS_KNOWN][0 != cursor], buf, row, col);
}
コード例 #12
0
ファイル: ui-options.c プロジェクト: CrypticGator/angband
/**
 * Displays an option entry.
 */
static void option_toggle_display(struct menu *m, int oid, bool cursor,
		int row, int col, int width)
{
	byte attr = curs_attrs[CURS_KNOWN][cursor != 0];
	bool *options = menu_priv(m);

	c_prt(attr, format("%-45s: %s  (%s)", option_desc(oid),
			options[oid] ? "yes" : "no ", option_name(oid)), row, col);
}
コード例 #13
0
ファイル: trap.c プロジェクト: artes-liberales/FAangband
/**
 * Deal with events on the trap menu
 */
bool trap_action(menu_type *menu, const ui_event_data *db, int oid)
{
    u16b *choice = menu_priv(menu);

    int idx = choice[oid];
    cave_set_feat(trap_y, trap_x, FEAT_MTRAP_BASE + 1 + idx);

    return FALSE;
}
コード例 #14
0
ファイル: ui-curse.c プロジェクト: takkaria/angband
/**
 * Deal with events on the get_item menu
 */
bool get_curse_action(struct menu *menu, const ui_event *event, int oid)
{
	struct curse_menu_data *choice = menu_priv(menu);
	if (event->type == EVT_SELECT) {
		selection = choice[oid].index;
	}

	return false;
}
コード例 #15
0
ファイル: wizard2.c プロジェクト: NickMcConnell/Beleriand
/**
 * Display an entry on the jump menu
 */
void jump_display(menu_type * menu, int oid, bool cursor, int row, int col,
				  int width)
{
	const u16b *choice = menu_priv(menu);

	byte attr = (cursor ? TERM_L_BLUE : TERM_WHITE);

	//c_prt(attr, locality_name[stage_map[choice[oid]][LOCALITY]], row, col);

}
コード例 #16
0
ファイル: ui-curse.c プロジェクト: fe051/angband
/**
 * Display an entry on the item menu
 */
void get_curse_display(struct menu *menu, int oid, bool cursor, int row,
					  int col, int width)
{
	struct curse **choice = menu_priv(menu);
	int attr = cursor ? COLOUR_L_BLUE : COLOUR_WHITE;
	char buf[80];
	int power = choice[oid]->power;
	strnfmt(buf, sizeof(buf), "%s (power %d)", choice[oid]->name, power);
	c_put_str(attr, buf, row + oid, col);
}
コード例 #17
0
ファイル: trap.c プロジェクト: artes-liberales/FAangband
/**
 * Display an entry on the sval menu
 */
void trap_display(menu_type * menu, int oid, bool cursor, int row, int col,
                  int width)
{
    const u16b *choice = menu_priv(menu);
    int idx = choice[oid];

    byte attr = (cursor ? TERM_L_BLUE : TERM_WHITE);

    /* Print it */
    c_put_str(attr, format("%s", trap_type[idx]), row, col);
}
コード例 #18
0
static int menu_action_valid(menu_type *m, int oid)
{
	menu_action *acts = menu_priv(m);

	/*if (acts[oid].flags & MN_ACT_HIDDEN)*/
	if (!(acts[oid].flags & MN_ACTIVE) && (acts[oid].flags & MN_SELECT))
		return 2;

	/*return acts[oid].name ? TRUE : FALSE;*/
	return acts[oid].text ? TRUE : FALSE;
}
コード例 #19
0
ファイル: ui-spell.c プロジェクト: NickMcConnell/Beleriand
/**
 * Handle an event on a menu row.
 */
static bool spell_menu_handler(menu_type * m, const ui_event * e, int oid)
{
	struct spell_menu_data *d = menu_priv(m);

	if (e->type == EVT_SELECT) {
		d->selected_spell = d->spells[oid];
		return d->browse ? TRUE : FALSE;
	}

	return TRUE;
}
コード例 #20
0
ファイル: ui-object.c プロジェクト: angband/angband
/**
 * Deal with events on the get_item menu
 */
bool get_item_action(struct menu *menu, const ui_event *event, int oid)
{
	struct object_menu_data *choice = menu_priv(menu);
	char key = event->key.code;
	bool is_harmless = item_mode & IS_HARMLESS ? true : false;
	int mode = OPT(player, rogue_like_commands) ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG;

	if (event->type == EVT_SELECT) {
		if (get_item_allow(choice[oid].object, cmd_lookup_key(item_cmd, mode),
						   item_cmd, is_harmless))
			selection = choice[oid].object;
	}

	if (event->type == EVT_KBRD) {
		if (key == '/') {
			/* Toggle if allowed */
			if (((item_mode & USE_INVEN) || allow_all)
				&& (player->upkeep->command_wrk != USE_INVEN)) {
				player->upkeep->command_wrk = USE_INVEN;
				newmenu = true;
			} else if (((item_mode & USE_EQUIP) || allow_all) &&
					   (player->upkeep->command_wrk != USE_EQUIP)) {
				player->upkeep->command_wrk = USE_EQUIP;
				newmenu = true;
			} else {
				bell("Cannot switch item selector!");
			}
		}

		else if (key == '|') {
			/* No toggle allowed */
			if ((q1 > q2) && !allow_all){
				bell("Cannot select quiver!");
			} else {
				/* Toggle to quiver */
				player->upkeep->command_wrk = (USE_QUIVER);
				newmenu = true;
			}
		}

		else if (key == '-') {
			/* No toggle allowed */
			if ((f1 > f2) && !allow_all) {
				bell("Cannot select floor!");
			} else {
				/* Toggle to floor */
				player->upkeep->command_wrk = (USE_FLOOR);
				newmenu = true;
			}
		}
	}

	return false;
}
コード例 #21
0
ファイル: specialty.c プロジェクト: artes-liberales/FAangband
/**
 * Display an entry on the gain specialty menu
 */
void gain_spec_display(menu_type * menu, int oid, bool cursor, int row, int col,
		       int width)
{
    struct spec_menu_data *d = menu_priv(menu);
    int idx = d->specialties[oid];

    byte attr = (cursor ? TERM_L_GREEN : TERM_GREEN);

    /* Print it */
    c_put_str(attr, abilities[idx].name, row, col);

}
コード例 #22
0
ファイル: ui-curse.c プロジェクト: NickMcConnell/angband
/**
 * Display an entry on the item menu
 */
void get_curse_display(struct menu *menu, int oid, bool cursor, int row,
					  int col, int width)
{
	struct curse_menu_data *choice = menu_priv(menu);
	int attr = cursor ? COLOUR_L_BLUE : COLOUR_WHITE;
	char buf[80];
	int power = choice[oid].power;
	char *name = curses[choice[oid].index].name;

	strnfmt(buf, sizeof(buf), "  %s (curse strength %d)", name, power);
	c_put_str(attr, buf, row, col);
}
コード例 #23
0
void menu_dynamic_free(menu_type *m)
{
	struct menu_entry *entry = menu_priv(m);
	while (entry) {
		struct menu_entry *next = entry->next;
		string_free(entry->text);
		//mem_free(entry);
		FREE(entry);
		entry = next;
	}
	//mem_free(m);
	FREE(m);
}
コード例 #24
0
ファイル: specialty.c プロジェクト: artes-liberales/FAangband
/**
 * Deal with events on the gain specialty menu
 */
bool gain_spec_action(menu_type * menu, const ui_event_data * e, int oid)
{
    struct spec_menu_data *d = menu_priv(menu);
    static int i;
    if (oid) i = oid;

    if (e->type == EVT_SELECT)
    {
	d->selected_spec = d->specialties[i];
	return FALSE;
    }

    return TRUE;
}
コード例 #25
0
/**
 * Run the spell menu, without selections.
 */
static void spell_menu_browse(struct menu *m, const char *noun)
{
	struct spell_menu_data *d = menu_priv(m);

	screen_save();

	region_erase_bordered(&m->active);
	prt(format("Browsing %ss. ('?' to toggle description)", noun), 0, 0);

	d->browse = TRUE;
	menu_select(m, 0, TRUE);

	screen_load();
}
コード例 #26
0
ファイル: ui-spell.c プロジェクト: NickMcConnell/Beleriand
/**
 * Run the spell menu, without selections.
 */
static void spell_menu_browse(menu_type * m, const char *noun)
{
	struct spell_menu_data *d = menu_priv(m);

	screen_save();

	region_erase_bordered(&m->active);
	prt(format("Browsing %ss.  Press Escape to exit.", noun), 0, 0);

	d->browse = TRUE;
	menu_select(m, 0, TRUE);

	screen_load();
}
コード例 #27
0
size_t menu_dynamic_longest_entry(menu_type *m)
{
	size_t biggest = 0;
	size_t current;

	struct menu_entry *entry;

	for (entry = menu_priv(m); entry; entry = entry->next) {
		current = strlen(entry->text);
		if (current > biggest)
			biggest = current;
	}

	return biggest;
}
コード例 #28
0
/**
 * Handle an event on a menu row.
 */
static bool spell_menu_handler(struct menu *m, const ui_event *e, int oid)
{
	struct spell_menu_data *d = menu_priv(m);

	if (e->type == EVT_SELECT) {
		d->selected_spell = d->spells[oid];
		return d->browse ? TRUE : FALSE;
	}
	else if (e->type == EVT_KBRD) {
		if (e->key.code == '?') {
			d->show_description = !d->show_description;
		}
	}

	return FALSE;
}
コード例 #29
0
ファイル: ui-spell.c プロジェクト: artes-liberales/FAangband
/**
 * Run the spell menu to select a spell.
 */
static int spell_menu_select(menu_type *m, const char *noun, const char *verb)
{
    struct spell_menu_data *d = menu_priv(m);

    screen_save();

    region_erase_bordered(&m->active);
    prt(format("%^s which %s? ", verb, noun), 0, 0);

    screen_save();
    menu_select(m, 0);
    screen_load();

    screen_load();

    return d->selected_spell;
}
コード例 #30
0
int menu_dynamic_select(menu_type *m)
{
	ui_event e = menu_select(m, 0, TRUE);
	struct menu_entry *entry;
	int cursor = m->cursor;

	//if (e.type == EVT_ESCAPE)
	if (e == EVT_ESCAPE)
		return -1;

	for (entry = menu_priv(m); cursor; cursor--) {
		entry = entry->next;
		assert(entry);
	}	

	return entry->value;
}