Exemple #1
0
/*
 * Display the inventory.  Builds a list of objects and passes them
 * off to show_obj_list() for display.  Mode flags documented in
 * object.h
 */
void show_inven(olist_detail_t mode)
{
    int i, last_slot = 0;
    int diff = weight_remaining();

    char header[80];

    object_type *o_ptr;

    bool in_term = (mode & OLIST_WINDOW) ? TRUE : FALSE;

    /* Include burden for term windows */
    if (in_term) {
	strnfmt(header, sizeof(header),
		"Burden %d.%d lb (%d.%d lb %s) ", p_ptr->total_weight / 10,
		p_ptr->total_weight % 10, abs(diff) / 10, abs(diff) % 10,
		(diff < 0 ? "overweight" : "remaining"));
	put_str(header, 0, 0);
    }

    /* Find the last occupied inventory slot */
    for (i = 0; i < INVEN_PACK; i++) {
	o_ptr = &p_ptr->inventory[i];
	if (o_ptr->k_idx)
	    last_slot = i;
    }

    /* Build the object list */
    build_obj_list(0, last_slot, NULL, mode);

    /* Display the object list */
    show_obj_list(num_obj, PW_INVEN, mode);
}
Exemple #2
0
/*
 * Display inventory
 */
void do_cmd_inven(void)
{
	ui_event e;
	int diff = weight_remaining();

	/* Hack -- Start in "inventory" mode */
	p_ptr->command_wrk = (USE_INVEN);

	/* Save screen */
	screen_save();

	/* Hack -- show empty slots */
	item_tester_full = TRUE;

	/* Display the inventory */
	show_inven(OLIST_WEIGHT | OLIST_QUIVER);

	/* Hack -- hide empty slots */
	item_tester_full = FALSE;

	/* Prompt for a command */
	prt(format("(Inventory) Burden %d.%d lb (%d.%d lb %s). Command: ",
		        p_ptr->total_weight / 10, p_ptr->total_weight % 10,
		        abs(diff) / 10, abs(diff) % 10,
		        (diff < 0 ? "overweight" : "remaining")),
	    0, 0);

	/* Get a new command */
	e = inkey_ex();
	if (!(e.type == EVT_KBRD && e.key.code == ESCAPE))
		Term_event_push(&e);

	/* Load screen */
	screen_load();
}
Exemple #3
0
/*
 * Display the inventory.  Builds a list of objects and passes them
 * off to show_obj_list() for display.  Mode flags documented in
 * object.h
 */
void show_inven(olist_detail_t mode)
{
	int i, last_slot = 0;
	int diff = weight_remaining();

	object_type *o_ptr;

   int num_obj = 0;
   char labels[50][80];
   object_type *objects[50];

   bool in_term = (mode & OLIST_WINDOW) ? TRUE : FALSE;

	/* Include burden for term windows */
	if (in_term)
	{
		strnfmt(labels[num_obj], sizeof(labels[num_obj]),
		        "Burden %d.%d lb (%d.%d lb %s) ",
		        p_ptr->total_weight / 10, p_ptr->total_weight % 10,
		        abs(diff) / 10, abs(diff) % 10,
		        (diff < 0 ? "overweight" : "remaining"));

		objects[num_obj] = NULL;
		num_obj++;
	}

	/* Find the last occupied inventory slot */
	for (i = 0; i < INVEN_PACK; i++)
	{
		o_ptr = &p_ptr->inventory[i];
		if (o_ptr->k_idx) last_slot = i;
	}

	/* Build the object list */
	for (i = 0; i <= last_slot; i++)
	{
		o_ptr = &p_ptr->inventory[i];

		/* Acceptable items get a label */
		if (item_tester_okay(o_ptr))
			strnfmt(labels[num_obj], sizeof(labels[num_obj]), "%c) ", index_to_label(i));

		/* Unacceptable items are still displayed in term windows */
		else if (in_term)
			my_strcpy(labels[num_obj], "   ", sizeof(labels[num_obj]));

		/* Unacceptable items are skipped in the main window */
		else continue;

		/* Save the object */
		objects[num_obj] = o_ptr;
		num_obj++;
	}

	/* Display the object list */
	show_obj_list(num_obj, labels, objects, mode);
}
Exemple #4
0
static struct panel *get_panel_midleft(void) {
	struct panel *p = panel_allocate(9);
	int diff = weight_remaining(player);
	byte attr = diff < 0 ? COLOUR_L_RED : COLOUR_L_GREEN;

	panel_line(p, max_color(player->lev, player->max_lev),
			"Level", "%d", player->lev);
	panel_line(p, max_color(player->exp, player->max_exp),
			"Cur Exp", "%d", player->exp);
	panel_line(p, COLOUR_L_GREEN, "Max Exp", "%d", player->max_exp);
	panel_line(p, COLOUR_L_GREEN, "Adv Exp", "%s", show_adv_exp());
	panel_space(p);
	panel_line(p, COLOUR_L_GREEN, "Gold", "%d", player->au);
	panel_line(p, attr, "Burden", "%.1f lb",
			   player->upkeep->total_weight / 10.0F);
	panel_line(p, attr, "Overweight", "%d.%d lb", -diff / 10, abs(diff) % 10);
	panel_line(p, COLOUR_L_GREEN, "Max Depth", "%s", show_depth());

	return p;
}
Exemple #5
0
static void context_menu_player_display_floor(void)
{
	/* there is an item on the floor, show the inventory screen starting
	 * from the floor */
	//Term_keypress('i',0);
	int diff = weight_remaining();

	/* Hack -- Start in "inventory" mode */
	p_ptr->command_wrk = (USE_FLOOR);

	/* Save screen */
	screen_save();

	/* Prompt for a command */
	prt(format("(Inventory) Burden %d.%d lb (%d.%d lb %s). Item for command: ",
			   p_ptr->total_weight / 10, p_ptr->total_weight % 10,
			   abs(diff) / 10, abs(diff) % 10,
			   (diff < 0 ? "overweight" : "remaining")),
		0, 0);


	/* Get an item to use a context command on */
	if (get_item(&diff, NULL, NULL, CMD_NULL, USE_EQUIP|USE_INVEN|USE_FLOOR|SHOW_EMPTY|IS_HARMLESS)) {
		object_type *o_ptr;

		/* Track the object kind */
		track_object(diff);

		o_ptr = object_from_item_idx(diff);

		context_menu_object(o_ptr, diff);
	}

	/* Load screen */
	screen_load();
}
Exemple #6
0
/**
 * Display the inventory.  Builds a list of objects and passes them
 * off to show_obj_list() for display.  Mode flags documented in
 * object.h
 */
void show_inven(int mode, item_tester tester)
{
	int i, last_slot = -1;
	int diff = weight_remaining(player);

	bool in_term = (mode & OLIST_WINDOW) ? true : false;

	/* Intialize */
	wipe_obj_list();

	/* Include burden for term windows */
	if (in_term) {
		strnfmt(items[num_obj].label, sizeof(items[num_obj].label),
		        "Burden %d.%d lb (%d.%d lb %s) ",
		        player->upkeep->total_weight / 10,
				player->upkeep->total_weight % 10,
		        abs(diff) / 10, abs(diff) % 10,
		        (diff < 0 ? "overweight" : "remaining"));

		items[num_obj].object = NULL;
		num_obj++;
	}

	/* Find the last occupied inventory slot */
	for (i = 0; i < z_info->pack_size; i++)
		if (player->upkeep->inven[i] != NULL) last_slot = i;

	/* Build the object list */
	build_obj_list(last_slot, player->upkeep->inven, tester, mode);

	/* Term window starts with a burden header */
	num_head = in_term ? 1 : 0;

	/* Display the object list */
	show_obj_list(mode);
}