GH-4699 Warn when exporting instance with custom components

This commit is contained in:
arthomnix
2023-02-05 15:55:49 +00:00
parent 82dde9f426
commit e463edb185

View File

@@ -89,23 +89,23 @@ void ModrinthExportDialog::accept()
MinecraftInstancePtr minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(m_instance); MinecraftInstancePtr minecraftInstance = std::dynamic_pointer_cast<MinecraftInstance>(m_instance);
minecraftInstance->getPackProfile()->reload(Net::Mode::Offline); minecraftInstance->getPackProfile()->reload(Net::Mode::Offline);
auto minecraftComponent = minecraftInstance->getPackProfile()->getComponent("net.minecraft"); for (int i = 0; i < minecraftInstance->getPackProfile()->rowCount(); i++) {
auto forgeComponent = minecraftInstance->getPackProfile()->getComponent("net.minecraftforge"); auto component = minecraftInstance->getPackProfile()->getComponent(i);
auto fabricComponent = minecraftInstance->getPackProfile()->getComponent("net.fabricmc.fabric-loader"); if (component->isCustom()) {
auto quiltComponent = minecraftInstance->getPackProfile()->getComponent("org.quiltmc.quilt-loader"); CustomMessageBox::selectable(
this,
tr("Warning"),
tr("Instance contains a custom component: %1\nThis cannot be exported to a Modrinth pack; the exported pack may not work correctly!")
.arg(component->getName()),
QMessageBox::Warning
)->exec();
}
}
if (minecraftComponent) { settings.gameVersion = minecraftInstance->getPackProfile()->getComponentVersion("net.minecraft");
settings.gameVersion = minecraftComponent->getVersion(); settings.forgeVersion = minecraftInstance->getPackProfile()->getComponentVersion("net.minecraftforge");
} settings.fabricVersion = minecraftInstance->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader");
if (forgeComponent) { settings.forgeVersion = minecraftInstance->getPackProfile()->getComponentVersion("org.quiltmc.quilt-loader");
settings.forgeVersion = forgeComponent->getVersion();
}
if (fabricComponent) {
settings.fabricVersion = fabricComponent->getVersion();
}
if (quiltComponent) {
settings.quiltVersion = quiltComponent->getVersion();
}
settings.exportPath = ui->file->text(); settings.exportPath = ui->file->text();