feat+fix: allow forwarding extra info to InstanceImportTask

This allows us to pass to the creation instances their actual pack ID
and version ID, that in Flame's case, are only available before starting
to create an instance.

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-11-12 11:42:07 -03:00
parent 7f5dea28bb
commit 968366c2ae
No known key found for this signature in database
GPG key ID: 8D0F221F0A59F469
9 changed files with 56 additions and 33 deletions

View file

@ -211,7 +211,7 @@ bool ModrinthCreationTask::createInstance()
instance.setIconKey("modrinth");
}
instance.setManagedPack("modrinth", getManagedPackID(), m_managed_name, m_managed_version_id, version());
instance.setManagedPack("modrinth", m_managed_id, m_managed_name, m_managed_version_id, version());
instance.setName(name());
instance.saveNow();
@ -284,7 +284,8 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path, std::vector<
}
if (set_managed_info) {
m_managed_version_id = Json::ensureString(obj, "versionId", {}, "Managed ID");
if (m_managed_version_id.isEmpty())
m_managed_version_id = Json::ensureString(obj, "versionId", {}, "Managed ID");
m_managed_name = Json::ensureString(obj, "name", {}, "Managed Name");
}
@ -384,13 +385,3 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path, std::vector<
return true;
}
QString ModrinthCreationTask::getManagedPackID() const
{
if (!m_source_url.isEmpty()) {
QRegularExpression regex(R"(data\/(.*)\/versions)");
return regex.match(m_source_url).captured(1);
}
return {};
}