review suggestions + spelling
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
492c78a570
commit
8488d11c69
@ -38,7 +38,6 @@
|
|||||||
#include <meta/VersionList.h>
|
#include <meta/VersionList.h>
|
||||||
|
|
||||||
#include <QSaveFile>
|
#include <QSaveFile>
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
@ -50,6 +49,14 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
const QMap<QString, ModloaderMapEntry> Component::KNOWN_MODLOADERS = {
|
||||||
|
{ "net.neoforged", { ModPlatform::NeoForge, { "net.minecraftforge", "net.fabricmc.fabric-loader", "net.fabricmc.fabric-loader" } } },
|
||||||
|
{ "net.minecraftforge", { ModPlatform::Forge, { "net.neoforged", "net.fabricmc.fabric-loader", "net.fabricmc.fabric-loader" } } },
|
||||||
|
{ "net.fabricmc.fabric-loader", { ModPlatform::Fabric, { "net.minecraftforge", "net.neoforged", "org.quiltmc.quilt-loader" } } },
|
||||||
|
{ "org.quiltmc.quilt-loader", { ModPlatform::Quilt, { "net.minecraftforge", "net.neoforged", "net.fabricmc.fabric-loader" } } },
|
||||||
|
{ "com.mumfrey.liteloader", { ModPlatform::LiteLoader, {} } }
|
||||||
|
};
|
||||||
|
|
||||||
Component::Component(PackProfile* parent, const QString& uid)
|
Component::Component(PackProfile* parent, const QString& uid)
|
||||||
{
|
{
|
||||||
assert(parent);
|
assert(parent);
|
||||||
@ -231,11 +238,11 @@ bool Component::isKnownModloader()
|
|||||||
return iter != KNOWN_MODLOADERS.cend();
|
return iter != KNOWN_MODLOADERS.cend();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Component::knownConfictingComponents()
|
QStringList Component::knownConflictingComponents()
|
||||||
{
|
{
|
||||||
auto iter = KNOWN_MODLOADERS.find(m_uid);
|
auto iter = KNOWN_MODLOADERS.find(m_uid);
|
||||||
if (iter != KNOWN_MODLOADERS.cend()) {
|
if (iter != KNOWN_MODLOADERS.cend()) {
|
||||||
return (*iter).knownConfictingComponents;
|
return (*iter).knownConflictingComponents;
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -276,12 +283,16 @@ void Component::addComponentProblem(ProblemSeverity severity, const QString& des
|
|||||||
m_componentProblemSeverity = severity;
|
m_componentProblemSeverity = severity;
|
||||||
}
|
}
|
||||||
m_componentProblems.append({ severity, description });
|
m_componentProblems.append({ severity, description });
|
||||||
|
|
||||||
|
emit dataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Component::resetComponentProblems()
|
void Component::resetComponentProblems()
|
||||||
{
|
{
|
||||||
m_componentProblems.clear();
|
m_componentProblems.clear();
|
||||||
m_componentProblemSeverity = ProblemSeverity::None;
|
m_componentProblemSeverity = ProblemSeverity::None;
|
||||||
|
|
||||||
|
emit dataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Component::setVersion(const QString& version)
|
void Component::setVersion(const QString& version)
|
||||||
|
@ -23,7 +23,7 @@ struct UpdateActionChangeVersion {
|
|||||||
/// version to change to
|
/// version to change to
|
||||||
QString targetVersion;
|
QString targetVersion;
|
||||||
};
|
};
|
||||||
struct UpdateActionLatestRecommendedCompatable {
|
struct UpdateActionLatestRecommendedCompatible {
|
||||||
/// Parent uid
|
/// Parent uid
|
||||||
QString parentUid;
|
QString parentUid;
|
||||||
QString parentName;
|
QString parentName;
|
||||||
@ -40,20 +40,13 @@ using UpdateActionNone = std::monostate;
|
|||||||
|
|
||||||
using UpdateAction = std::variant<UpdateActionNone,
|
using UpdateAction = std::variant<UpdateActionNone,
|
||||||
UpdateActionChangeVersion,
|
UpdateActionChangeVersion,
|
||||||
UpdateActionLatestRecommendedCompatable,
|
UpdateActionLatestRecommendedCompatible,
|
||||||
UpdateActionRemove,
|
UpdateActionRemove,
|
||||||
UpdateActionImportantChanged>;
|
UpdateActionImportantChanged>;
|
||||||
|
|
||||||
struct ModloaderMapEntry {
|
struct ModloaderMapEntry {
|
||||||
ModPlatform::ModLoaderType type;
|
ModPlatform::ModLoaderType type;
|
||||||
QStringList knownConfictingComponents;
|
QStringList knownConflictingComponents;
|
||||||
};
|
|
||||||
static const QMap<QString, ModloaderMapEntry> KNOWN_MODLOADERS{
|
|
||||||
{ "net.neoforged", { ModPlatform::NeoForge, { "net.minecraftforge", "net.fabricmc.fabric-loader", "net.fabricmc.fabric-loader" } } },
|
|
||||||
{ "net.minecraftforge", { ModPlatform::Forge, { "net.neoforged", "net.fabricmc.fabric-loader", "net.fabricmc.fabric-loader" } } },
|
|
||||||
{ "net.fabricmc.fabric-loader", { ModPlatform::Fabric, { "net.minecraftforge", "net.neoforged", "org.quiltmc.quilt-loader" } } },
|
|
||||||
{ "org.quiltmc.quilt-loader", { ModPlatform::Quilt, { "net.minecraftforge", "net.neoforged", "net.fabricmc.fabric-loader" } } },
|
|
||||||
{ "com.mumfrey.liteloader", { ModPlatform::LiteLoader, {} } }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Component : public QObject, public ProblemProvider {
|
class Component : public QObject, public ProblemProvider {
|
||||||
@ -66,6 +59,8 @@ class Component : public QObject, public ProblemProvider {
|
|||||||
|
|
||||||
virtual ~Component() {}
|
virtual ~Component() {}
|
||||||
|
|
||||||
|
static const QMap<QString, ModloaderMapEntry> KNOWN_MODLOADERS;
|
||||||
|
|
||||||
void applyTo(LaunchProfile* profile);
|
void applyTo(LaunchProfile* profile);
|
||||||
|
|
||||||
bool isEnabled();
|
bool isEnabled();
|
||||||
@ -79,7 +74,7 @@ class Component : public QObject, public ProblemProvider {
|
|||||||
bool isCustom();
|
bool isCustom();
|
||||||
bool isVersionChangeable();
|
bool isVersionChangeable();
|
||||||
bool isKnownModloader();
|
bool isKnownModloader();
|
||||||
QStringList knownConfictingComponents();
|
QStringList knownConflictingComponents();
|
||||||
|
|
||||||
// DEPRECATED: explicit numeric order values, used for loading old non-component config. TODO: refactor and move to migration code
|
// DEPRECATED: explicit numeric order values, used for loading old non-component config. TODO: refactor and move to migration code
|
||||||
void setOrder(int order);
|
void setOrder(int order);
|
||||||
|
@ -570,25 +570,22 @@ void ComponentUpdateTask::performUpdateActions()
|
|||||||
component->setVersion(cv.targetVersion);
|
component->setVersion(cv.targetVersion);
|
||||||
component->waitLoadMeta();
|
component->waitLoadMeta();
|
||||||
},
|
},
|
||||||
[&component, &instance](const UpdateActionLatestRecommendedCompatable lrc) {
|
[&component, &instance](const UpdateActionLatestRecommendedCompatible lrc) {
|
||||||
qCDebug(instanceProfileResolveC)
|
qCDebug(instanceProfileResolveC)
|
||||||
<< instance->name() << "|"
|
<< instance->name() << "|"
|
||||||
<< "UpdateActionLatestRecommendedCompatable" << component->getID() << ":" << component->getVersion()
|
<< "UpdateActionLatestRecommendedCompatible" << component->getID() << ":" << component->getVersion()
|
||||||
<< "updating to latest recommend or compatible with" << lrc.parentUid << lrc.version;
|
<< "updating to latest recommend or compatible with" << lrc.parentUid << lrc.version;
|
||||||
auto versionList = APPLICATION->metadataIndex()->get(component->getID());
|
auto versionList = APPLICATION->metadataIndex()->get(component->getID());
|
||||||
versionList->waitToLoad();
|
|
||||||
if (versionList) {
|
if (versionList) {
|
||||||
|
versionList->waitToLoad();
|
||||||
auto recommended = versionList->getRecommendedForParent(lrc.parentUid, lrc.version);
|
auto recommended = versionList->getRecommendedForParent(lrc.parentUid, lrc.version);
|
||||||
|
if (!recommended) {
|
||||||
|
recommended = versionList->getLatestForParent(lrc.parentUid, lrc.version);
|
||||||
|
}
|
||||||
if (recommended) {
|
if (recommended) {
|
||||||
component->setVersion(recommended->version());
|
component->setVersion(recommended->version());
|
||||||
component->waitLoadMeta();
|
component->waitLoadMeta();
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
auto latest = versionList->getLatestForParent(lrc.parentUid, lrc.version);
|
|
||||||
if (latest) {
|
|
||||||
component->setVersion(latest->version());
|
|
||||||
component->waitLoadMeta();
|
|
||||||
} else {
|
} else {
|
||||||
component->addComponentProblem(ProblemSeverity::Error,
|
component->addComponentProblem(ProblemSeverity::Error,
|
||||||
QObject::tr("No compatible version of %1 found for %2 %3")
|
QObject::tr("No compatible version of %1 found for %2 %3")
|
||||||
@ -635,14 +632,14 @@ void ComponentUpdateTask::performUpdateActions()
|
|||||||
if (!newVersion.isEmpty()) {
|
if (!newVersion.isEmpty()) {
|
||||||
comp->setUpdateAction(UpdateAction{ UpdateActionChangeVersion{ newVersion } });
|
comp->setUpdateAction(UpdateAction{ UpdateActionChangeVersion{ newVersion } });
|
||||||
} else {
|
} else {
|
||||||
comp->setUpdateAction(UpdateAction{ UpdateActionLatestRecommendedCompatable{
|
comp->setUpdateAction(UpdateAction{ UpdateActionLatestRecommendedCompatible{
|
||||||
component->getID(),
|
component->getID(),
|
||||||
component->getName(),
|
component->getName(),
|
||||||
component->getVersion(),
|
component->getVersion(),
|
||||||
} });
|
} });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
comp->setUpdateAction(UpdateAction{ UpdateActionLatestRecommendedCompatable{
|
comp->setUpdateAction(UpdateAction{ UpdateActionLatestRecommendedCompatible{
|
||||||
component->getID(),
|
component->getID(),
|
||||||
component->getName(),
|
component->getName(),
|
||||||
component->getVersion(),
|
component->getVersion(),
|
||||||
@ -690,7 +687,7 @@ void ComponentUpdateTask::finalizeComponents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto conflict : component->knownConfictingComponents()) {
|
for (auto conflict : component->knownConflictingComponents()) {
|
||||||
auto found = componentIndex.find(conflict);
|
auto found = componentIndex.find(conflict);
|
||||||
if (found != componentIndex.cend()) {
|
if (found != componentIndex.cend()) {
|
||||||
auto foundComp = *found;
|
auto foundComp = *found;
|
||||||
|
@ -1034,7 +1034,7 @@ std::optional<ModPlatform::ModLoaderTypes> PackProfile::getModLoaders()
|
|||||||
ModPlatform::ModLoaderTypes result;
|
ModPlatform::ModLoaderTypes result;
|
||||||
bool has_any_loader = false;
|
bool has_any_loader = false;
|
||||||
|
|
||||||
QMapIterator<QString, ModloaderMapEntry> i(KNOWN_MODLOADERS);
|
QMapIterator<QString, ModloaderMapEntry> i(Component::KNOWN_MODLOADERS);
|
||||||
|
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
i.next();
|
i.next();
|
||||||
|
Loading…
Reference in New Issue
Block a user