Implement config-driven unlock groups so that multiple things can be unlocked at once (including buildings)

This commit is contained in:
2026-07-22 21:34:59 +02:00
parent a8a6a04f1e
commit a9082c57f3
36 changed files with 1005 additions and 543 deletions

View File

@@ -21,6 +21,18 @@ const RecipeDef* findRecipe(const RecipesConfig& recipes, const std::string& id)
return nullptr;
}
QString grantKindLabel(SchematicType type)
{
switch (type)
{
case SchematicType::Ship: return SchematicChoiceDialog::tr("Ship");
case SchematicType::Module: return SchematicChoiceDialog::tr("Module");
case SchematicType::Building: return SchematicChoiceDialog::tr("Building");
case SchematicType::Recipe: return SchematicChoiceDialog::tr("Recipe");
}
return QString();
}
} // namespace
SchematicChoiceDialog::SchematicChoiceDialog(
@@ -63,7 +75,7 @@ SchematicChoiceDialog::SchematicChoiceDialog(
nameLabel->setAlignment(Qt::AlignCenter);
cardLayout->addWidget(nameLabel);
if (option.type == SchematicType::Artifact)
if (option.isArtifact)
{
QLabel* artifactTypeLabel = new QLabel(tr("Artifact"), card);
artifactTypeLabel->setAlignment(Qt::AlignCenter);
@@ -71,22 +83,22 @@ SchematicChoiceDialog::SchematicChoiceDialog(
}
else
{
QString typeText;
if (option.type == SchematicType::Ship)
QLabel* grantsHeaderLabel = new QLabel(tr("Unlocks:"), card);
QFont grantsHeaderFont = grantsHeaderLabel->font();
grantsHeaderFont.setBold(true);
grantsHeaderLabel->setFont(grantsHeaderFont);
grantsHeaderLabel->setAlignment(Qt::AlignCenter);
cardLayout->addWidget(grantsHeaderLabel);
for (const GrantedSchematic& grant : option.grantedItems)
{
typeText = tr("Ship");
QLabel* grantLabel = new QLabel(
grantKindLabel(grant.type) + ": "
+ QString::fromStdString(grant.displayName),
card);
grantLabel->setAlignment(Qt::AlignCenter);
cardLayout->addWidget(grantLabel);
}
else if (option.type == SchematicType::Module)
{
typeText = tr("Module");
}
else
{
typeText = tr("Recipe");
}
QLabel* typeLabel = new QLabel(typeText, card);
typeLabel->setAlignment(Qt::AlignCenter);
cardLayout->addWidget(typeLabel);
QLabel* unlocksHeaderLabel = new QLabel(tr("Unlocks recipes:"), card);
QFont unlocksHeaderFont = unlocksHeaderLabel->font();