/* * Display an artifact label */ static void display_artifact(int col, int row, bool cursor, int oid) { byte attr = curs_attrs[CURS_KNOWN][(int) cursor]; char o_name[80]; get_artifact_display_name(o_name, sizeof o_name, oid); c_prt(attr, o_name, row, col); }
/* * 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); }
/* * 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); } }
// 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(); }
// Select an artifact from a list and place it in the player's inventory MakeArtifactDialog::MakeArtifactDialog(void) { int i; QPointer<QVBoxLayout> vlay = new QVBoxLayout; art_choice = new QComboBox; object_type object_type_body; object_type *i_ptr = &object_type_body; QPointer<QLabel> obj_label = new QLabel(QString("<b><big>Please select an artifact:</big></b>")); obj_label->setAlignment(Qt::AlignCenter); vlay->addWidget(obj_label); vlay->addStretch(); connect(art_choice, SIGNAL(currentIndexChanged(int)), this, SLOT(update_art_choice(int))); QPointer<QPushButton> close_button = new QPushButton(tr("&Close")); connect(close_button, SIGNAL(clicked()), this, SLOT(close())); int count = 0; art_num = 0; for (i = 1; i < z_info->art_norm_max; i++) { artifact_type *a_ptr = &a_info[i]; /* Skip "empty" items */ if (a_ptr->tval + a_ptr->sval == 0) continue; art_choice->addItem(QString("%1") .arg(i)); art_choice->setItemText(count++, get_artifact_display_name(i)); } vlay->addWidget(art_choice); vlay->addStretch(); vlay->addWidget(close_button); setLayout(vlay); setWindowTitle(tr("Make Artifact")); this->exec(); // find the artifact count = 0; for (i = 1; i < z_info->art_norm_max; i++) { artifact_type *a_ptr = &a_info[i]; /* Skip "empty" items */ if (a_ptr->tval + a_ptr->sval == 0) continue; // Found the match if (count == art_num) break; count++; } i_ptr->object_wipe(); if (!wiz_alloc_artifact(i_ptr, i)) { return; } object_history(i_ptr, ORIGIN_CHEAT, 0); identify_object(i_ptr, true); if(inven_carry(i_ptr) < 0) { drop_near(i_ptr, -1, p_ptr->py, p_ptr->px); } }