18 #include "AssetsManager.h"
19 #include "Archetypes.h"
28 addSpinBox(tr(
"Chance:"),
"chance", 0, 65535,
false);
38 myArchetypes->setHeaderLabel(tr(
"Allowed/forbidden archetypes"));
41 connect(
myArchetypes, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
this, SLOT(
artifactChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
51 Q_ASSERT(artifact != NULL);
53 const recipelist* list;
55 const archetype* arch;
58 for (
int ing = 1; ; ing++)
60 list = get_formulalist(ing);
63 for (recipe = list->items; recipe; recipe = recipe->next)
65 if (recipe->title == NULL)
68 if (strcmp(recipe->title, artifact->item->name) != 0)
71 for (
size_t a = 0; a < recipe->arch_names; a++)
73 arch = find_archetype(recipe->arch_name[a]);
76 if ((arch->clone.type == artifact->item->type) && legal_artifact_combination(&arch->clone, artifact))
78 if (!possible.contains(arch->name))
79 possible.append(arch->name);
85 if (possible.isEmpty())
89 if (possible.size() ==
static_cast<int>(artifact->allowed.size()))
94 myViaAlchemy->setText(tr(
"The following archetypes can be used via alchemy: %1").arg(possible.join(tr(
", "))));
106 static void addArchetypes(
const artifact* artifact,
const char* name,
bool check, QTreeWidget* root)
108 QTreeWidgetItem* item = NULL;
110 getManager()->archetypes()->each([&artifact, &name, &check, &root, &item] (archetype *arch)
112 if (arch->head || arch->clone.type != artifact->item->type)
117 if (name == NULL || (check && arch->clone.name && (!strcmp(name, arch->clone.name) || (!strcmp(name, arch->name)))) || (!check && (arch->clone.name && strcmp(name, arch->clone.name)) && strcmp(name, arch->name)))
121 item = new QTreeWidgetItem(root, QStringList(name == NULL ?
"(all)" : name));
122 item->setCheckState(0, check ? Qt::Checked : Qt::Unchecked);
123 item->setFlags(item->flags() & ~Qt::ItemIsUserCheckable);
124 root->addTopLevelItem(item);
125 item->setExpanded(true);
143 for (
const auto allowed :
myItem->allowed) {
146 if (name[0] ==
'!') {
155 if (
myItem->allowed.empty()) {
159 StringBuffer* dump = stringbuffer_new();
160 get_ob_diff(dump,
myItem->item, &empty_archetype->clone);
161 char*
final = stringbuffer_finish(dump);
169 myFace->setVisible(
false);
171 if (!current || current->data(0, Qt::UserRole).toString().isEmpty()) {
174 archetype* arch = getManager()->archetypes()->find(current->data(0, Qt::UserRole).toString().toUtf8().constData());
180 object* obj = arch_to_object(arch);
181 SET_FLAG(obj, FLAG_IDENTIFIED);
182 give_artifact_abilities(obj,
myItem->item);
183 object_give_identified_properties(obj);
184 desc = stringbuffer_finish(describe_item(obj, NULL, 0, NULL));
188 if (obj->animation !=
nullptr) {
194 faces.append(obj->face->number);
199 object_free(obj, FREE_OBJ_FREE_INVENTORY | FREE_OBJ_NO_DESTROY_CALLBACK);