Exemplo n.º 1
0
/*
 * Display known objects
 */
void textui_browse_object_knowledge(void *obj, const char *name)
{
    group_funcs kind_f = { TV_GOLD, FALSE, kind_name, o_cmp_tval, obj2gid, 0 };
    member_funcs obj_f =
	{ display_object, desc_obj_fake, o_xchar, o_xattr, o_xtra_prompt,
o_xtra_act, 0 };

    int *objects;
    int o_count = 0;
    int i;
    object_kind *k_ptr;

    objects = C_ZNEW(z_info->k_max, int);

    for (i = 0; i < z_info->k_max; i++) {
	k_ptr = &k_info[i];
	/* It's in the list if we've ever seen it, or it has a flavour, and
	 * either it's not one of the special artifacts, or if it is, we're not 
	 * aware of it yet. This way the flavour appears in the list until it
	 * is found. */
	if ((k_ptr->everseen || k_ptr->flavor || OPT(cheat_xtra))
	    && (!kf_has(k_ptr->flags_kind, KF_INSTA_ART)
		|| !artifact_is_known(get_artifact_from_kind(k_ptr)))) {
	    int c = obj_group_order[k_info[i].tval];
	    if (c >= 0)
		objects[o_count++] = i;
	}
    }

    display_knowledge("known objects", objects, o_count, kind_f, obj_f,
		      "Squelch  Inscribed          Sym");

    FREE(objects);
}
Exemplo n.º 2
0
/*
 * Describe fake object
 */
static void desc_obj_fake(int k_idx)
{
	object_kind *k_ptr = &k_info[k_idx];
	object_type object_type_body;
	object_type *o_ptr = &object_type_body;

	char header[120];

	textblock *tb;
	region area = { 0, 0, 0, 0 };

	/* Check for known artifacts, display them as artifacts */
	if (kf_has(k_ptr->flags_kind, KF_INSTA_ART)
		&& artifact_is_known(get_artifact_from_kind(k_ptr))) {
		desc_art_fake(get_artifact_from_kind(k_ptr));
		return;
	}

	/* Update the object recall window */
	track_object_kind(k_idx);
	handle_stuff(p_ptr);

	/* Wipe the object */
	object_wipe(o_ptr);

	/* Create the artifact */
	object_prep(o_ptr, k_idx, EXTREMIFY);

	/* Hack -- its in the store */
	if (k_info[k_idx].aware)
		o_ptr->ident |= (IDENT_STORE);

	/* It's fully know */
	if (!k_info[k_idx].flavor)
		object_known(o_ptr);

	/* Hack -- Handle stuff */
	handle_stuff(p_ptr);

	/* Describe */
	tb = object_info(o_ptr, OINFO_DUMMY);
	object_desc(header, sizeof(header), o_ptr,
				ODESC_PREFIX | ODESC_FULL | ODESC_CAPITAL);

	textui_textblock_show(tb, area, format("%s", header));
	textblock_free(tb);
}
Exemplo n.º 3
0
/*
 * Display the objects in a group.
 */
static void display_object(int col, int row, bool cursor, int oid)
{
    int k_idx = oid;

    object_kind *k_ptr = &k_info[k_idx];
    const char *inscrip = get_autoinscription(oid);

    char o_name[80];

    /* Choose a color */
    bool aware = (!k_ptr->flavor || k_ptr->aware);
    byte attr = curs_attrs[(int) aware][(int) cursor];

    /* Find graphics bits -- versions of the object_char and object_attr
     * defines */
    bool use_flavour = (k_ptr->flavor) && !(aware && k_ptr->tval == TV_SCROLL);

    byte a = use_flavour ? flavor_info[k_ptr->flavor].x_attr : k_ptr->x_attr;
    byte c = use_flavour ? flavor_info[k_ptr->flavor].x_char : k_ptr->x_char;

    /* Display known artifacts differently */
    if (kf_has(k_ptr->flags_kind, KF_INSTA_ART)
	&& artifact_is_known(get_artifact_from_kind(k_ptr))) {
	get_artifact_display_name(o_name, sizeof(o_name),
				  get_artifact_from_kind(k_ptr));
    } else {
	object_kind_name(o_name, sizeof(o_name), k_idx, OPT(cheat_know));
    }

    /* If the type is "tried", display that */
    if (k_ptr->tried && !aware)
	my_strcat(o_name, " {tried}", sizeof(o_name));

    /* Display the name */
    c_prt(attr, o_name, row, col);

    /* Show autoinscription if around */
    if (aware && inscrip)
	c_put_str(TERM_YELLOW, inscrip, row, 55);

    /* Hack - don't use if double tile */
    if ((tile_width > 1) || (tile_height > 1))
	return;

    /* Display symbol */
    big_pad(76, row, a, c);
}
Exemplo n.º 4
0
/*
 * Display the objects in a group.
 */
static void display_object(int col, int row, bool cursor, int oid)
{
	object_kind *kind = &k_info[oid];
	const char *inscrip = get_autoinscription(kind);

	char o_name[80];

	/* Choose a color */
	bool aware = (!kind->flavor || kind->aware);
	byte attr = curs_attrs[(int)aware][(int)cursor];

	/* Find graphics bits -- versions of the object_char and object_attr defines */
	bool use_flavour = (kind->flavor) && !(aware && kind->tval == TV_SCROLL);

	byte a = use_flavour ? kind->flavor->x_attr : kind->x_attr;
	byte c = use_flavour ? kind->flavor->x_char : kind->x_char;

	/* Display known artifacts differently */
	if (of_has(kind->flags, OF_INSTA_ART) && artifact_is_known(get_artifact_from_kind(kind)))
		get_artifact_display_name(o_name, sizeof(o_name), get_artifact_from_kind(kind));
	else
 		object_kind_name(o_name, sizeof(o_name), kind, OPT(cheat_know));

	/* If the type is "tried", display that */
	if (kind->tried && !aware)
		my_strcat(o_name, " {tried}", sizeof(o_name));

	/* Display the name */
	c_prt(attr, o_name, row, col);

	/* Show squelch status */
	if ((aware && kind_is_squelched_aware(kind)) ||
		(!aware && kind_is_squelched_unaware(kind)))
		c_put_str(attr, "Yes", row, 46);


	/* Show autoinscription if around */
	if (aware && inscrip)
		c_put_str(TERM_YELLOW, inscrip, row, 55);

	if (tile_height == 1) {
		big_pad(76, row, a, c);
	}
}
Exemplo n.º 5
0
/* If 'artifacts' is NULL, it counts the number of known artifacts, otherwise
   it collects the list of known artifacts into 'artifacts' as well. */
static int collect_known_artifacts(int *artifacts, size_t artifacts_len)
{
	int a_count = 0;
	int j;

	if (artifacts)
		assert(artifacts_len >= z_info->a_max);

	for (j = 0; j < z_info->a_max; j++) {
		/* Artifact doesn't exist */
		if (!a_info[j].name)
			continue;

		if (OPT(cheat_xtra) || artifact_is_known(j)) {
			if (artifacts)
				artifacts[a_count++] = j;
			else
				a_count++;
		}
	}

	return a_count;
}
// Set up the artifact knowledge table
// Note the code handling creating a group for special artifacts
DisplayArtifactKnowledge::DisplayArtifactKnowledge(void)
{
    artifact_proxy_model = new QSortFilterProxyModel;
    artifact_proxy_model->setSortCaseSensitivity(Qt::CaseSensitive);
    QPointer<QVBoxLayout> main_layout = new QVBoxLayout;
    QPointer<QHBoxLayout> artifact_knowledge_hlay = new QHBoxLayout;
    main_layout->addLayout(artifact_knowledge_hlay);

    // To track the artifact info button
    artifact_button_group = new QButtonGroup(this);
    artifact_button_group->setExclusive(FALSE);

    // To track the artifact settings button
    artifact_settings_group = new QButtonGroup(this);
    artifact_settings_group->setExclusive(FALSE);

    // Set the table and headers
    artifact_group_table = new QTableWidget(0, 1, this);
    artifact_group_table->setAlternatingRowColors(FALSE);

    QTableWidgetItem *artifact_group_header = new QTableWidgetItem("Object Kinds");
    artifact_group_header->setTextAlignment(Qt::AlignLeft);
    artifact_group_table->setHorizontalHeaderItem(0, artifact_group_header);

    artifact_table = new QTableWidget(0, 4, this);
    artifact_table->setAlternatingRowColors(FALSE);

    qtablewidget_add_palette(artifact_group_table);
    qtablewidget_add_palette(artifact_table);

    artifact_group_table->verticalHeader()->setVisible(FALSE);
    artifact_table->verticalHeader()->setVisible(FALSE);

    do_spoiler = FALSE;

    int row = 0;
    int col = 0;

    QTableWidgetItem *art_header = new QTableWidgetItem("Object");
    art_header->setTextAlignment(Qt::AlignLeft);
    artifact_table->setHorizontalHeaderItem(col++, art_header);
    QTableWidgetItem *info_header = new QTableWidgetItem("Info");
    info_header->setTextAlignment(Qt::AlignCenter);
    artifact_table->setHorizontalHeaderItem(col++, info_header);
    QTableWidgetItem *settings_header = new QTableWidgetItem("settings");
    settings_header->setTextAlignment(Qt::AlignCenter);
    artifact_table->setHorizontalHeaderItem(col++, settings_header);
    //This column will be hidden, but is used in filter_rows
    QTableWidgetItem *a_idx_header = new QTableWidgetItem("s_idx");
    a_idx_header->setTextAlignment(Qt::AlignCenter);
    artifact_table->setHorizontalHeaderItem(col++, a_idx_header);

    //Gather information to populate the object kind groups
    // First, add one for the special artifacts
    artifact_group_info.clear();
    artifact_group_info.append(FALSE);
    for (int x = 0; x < NUM_OBJECT_GROUPS; x++) artifact_group_info.append(FALSE);

    //  Populate the table
    for (int i = 0; i < z_info->art_rand_max; i++)
    {
        artifact_type *a_ptr = &a_info[i];

        /* This slot is already being used */
        if ((a_ptr->tval + a_ptr->sval) == 0) continue;
        if (!artifact_is_known(i)) continue;

        /*  Don't do quest artifacts*/
        if (i == QUEST_ART_SLOT) continue;

        artifact_table->insertRow(row);
        col = 0;

        int k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);

        // artifact kind
        QString this_art = get_artifact_display_name(i);
        QTableWidgetItem *art_kind = new QTableWidgetItem(this_art);
        art_kind->setData(Qt::ForegroundRole, k_info[k_idx].get_color());
        art_kind->setTextAlignment(Qt::AlignLeft);
        artifact_table->setItem(row, col++, art_kind);

        // artifact info
        QPointer<QPushButton> info_button = new QPushButton();
        qpushbutton_dark_background(info_button);
        info_button->setIcon(QIcon(":/icons/lib/icons/help_dark.png"));
        artifact_table->setCellWidget(row, col++, info_button);
        artifact_button_group->addButton(info_button, i);

        // artifact settings
        QPointer<QPushButton> settings_button = new QPushButton();
        qpushbutton_dark_background(settings_button);
        settings_button->setIcon(QIcon(":/icons/lib/icons/settings_dark.png"));
        artifact_table->setCellWidget(row, col++, settings_button);
        artifact_settings_group->addButton(settings_button, i);

        // a_idx
        QString this_a_idx = (QString("%1") .arg(i));
        QTableWidgetItem *a_idx = new QTableWidgetItem(this_a_idx);
        a_idx->setTextAlignment(Qt::AlignRight);
        artifact_table->setItem(row, col++, a_idx);

        row++;

        // Now make sure the artifact type is added to the table.
        artifact_group_info[artifact_matches_group(i)] = TRUE;
    }

    connect(artifact_button_group, SIGNAL(buttonClicked(int)), this, SLOT(button_press(int)));
    connect(artifact_settings_group, SIGNAL(buttonClicked(int)), this, SLOT(settings_press(int)));

    row = col = 0;

    //Now populate the artifact group table
    for (int i = 0; i < artifact_group_info.size(); i++)
    {
        if (!artifact_group_info[i]) continue;
        artifact_group_table->insertRow(row);

        // artifact Group
        QString group_name = QString("Special");
        if (i) group_name = QString(object_text_order[i-1].name);
        QTableWidgetItem *artifact_group_label = new QTableWidgetItem(group_name);
        artifact_group_label->setTextAlignment(Qt::AlignLeft);
        artifact_group_table->setItem(row++, 0, artifact_group_label);
    }

    artifact_group_table->resizeColumnsToContents();
    artifact_group_table->resizeRowsToContents();
    artifact_group_table->setSortingEnabled(FALSE);
    artifact_group_table->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
    artifact_group_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
    connect(artifact_group_table, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(filter_rows(int,int,int,int)));
    artifact_knowledge_hlay->addWidget(artifact_group_table);

    artifact_table->setSortingEnabled(TRUE);
    artifact_table->resizeColumnsToContents();
    artifact_table->resizeRowsToContents();
    artifact_table->sortByColumn(0, Qt::AscendingOrder);
    // Hide the a_idx column
    artifact_table->setColumnHidden(3, TRUE);
    artifact_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
    artifact_table->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
    artifact_knowledge_hlay->addWidget(artifact_table);

    //Add a close button on the right side
    QDialogButtonBox buttons;
    buttons.setStandardButtons(QDialogButtonBox::Close);
    connect(&buttons, SIGNAL(rejected()), this, SLOT(close()));
    main_layout->addWidget(&buttons);

    //Filter for the first monster group.
    filter_rows(0,0,0,0);

    QSize this_size = QSize(width()* 7 / 5, height() * 4 / 3);
    resize(ui_max_widget_size(this_size));
    updateGeometry();

    setLayout(main_layout);
    setWindowTitle(tr("Object Knowledge"));

    /*
     * We make this check here after the dialog box is fully
     * created to avoid any potential memory leaks.
     */
    if (!artifact_table->rowCount())
    {
        pop_up_message_box("You are not currently aware of any artifacts");
    }
    else this->exec();
}