refactor: cleanup ModLoaderType
This commit is contained in:
parent
18ac109e5a
commit
9fb5674233
@ -985,5 +985,5 @@ ModAPI::ModLoaderType PackProfile::getModLoader()
|
|||||||
{
|
{
|
||||||
return ModAPI::Quilt;
|
return ModAPI::Quilt;
|
||||||
}
|
}
|
||||||
return ModAPI::Any;
|
return ModAPI::Unspecified;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class ModAPI {
|
|||||||
virtual ~ModAPI() = default;
|
virtual ~ModAPI() = default;
|
||||||
|
|
||||||
// https://docs.curseforge.com/?http#tocS_ModLoaderType
|
// https://docs.curseforge.com/?http#tocS_ModLoaderType
|
||||||
enum ModLoaderType { Any = 0, Forge = 1, Cauldron = 2, LiteLoader = 3, Fabric = 4, Quilt = 5 };
|
enum ModLoaderType { Unspecified = 0, Forge = 1, Cauldron = 2, LiteLoader = 3, Fabric = 4, Quilt = 5 };
|
||||||
|
|
||||||
struct SearchArgs {
|
struct SearchArgs {
|
||||||
int offset;
|
int offset;
|
||||||
@ -35,4 +35,22 @@ class ModAPI {
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual void getVersions(CallerType* caller, VersionSearchArgs&& args) const = 0;
|
virtual void getVersions(CallerType* caller, VersionSearchArgs&& args) const = 0;
|
||||||
|
|
||||||
|
static auto getModLoaderString(ModLoaderType type) -> const QString {
|
||||||
|
switch (type) {
|
||||||
|
case Unspecified:
|
||||||
|
break;
|
||||||
|
case Forge:
|
||||||
|
return "forge";
|
||||||
|
case Cauldron:
|
||||||
|
return "cauldron";
|
||||||
|
case LiteLoader:
|
||||||
|
return "liteloader";
|
||||||
|
case Fabric:
|
||||||
|
return "fabric";
|
||||||
|
case Quilt:
|
||||||
|
return "quilt";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -51,25 +51,16 @@ class ModrinthAPI : public NetworkModAPI {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto getModLoaderString(ModLoaderType modLoader) const -> QString
|
static auto getModLoaderString(ModLoaderType type) -> const QString
|
||||||
{
|
{
|
||||||
switch (modLoader) {
|
if (type == Unspecified)
|
||||||
case Any:
|
return "fabric, forge, quilt";
|
||||||
return "fabric, forge, quilt";
|
return ModAPI::getModLoaderString(type);
|
||||||
case Forge:
|
|
||||||
return "forge";
|
|
||||||
case Fabric:
|
|
||||||
return "fabric";
|
|
||||||
case Quilt:
|
|
||||||
return "quilt";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto validateModLoader(ModLoaderType modLoader) const -> bool
|
inline auto validateModLoader(ModLoaderType modLoader) const -> bool
|
||||||
{
|
{
|
||||||
return modLoader == Any || modLoader == Forge || modLoader == Fabric || modLoader == Quilt;
|
return modLoader == Unspecified || modLoader == Forge || modLoader == Fabric || modLoader == Quilt;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -391,7 +391,7 @@ void ModFolderPage::on_actionInstall_mods_triggered()
|
|||||||
return; //this is a null instance or a legacy instance
|
return; //this is a null instance or a legacy instance
|
||||||
}
|
}
|
||||||
auto profile = ((MinecraftInstance *)m_inst)->getPackProfile();
|
auto profile = ((MinecraftInstance *)m_inst)->getPackProfile();
|
||||||
if (profile->getModLoader() == ModAPI::Any) {
|
if (profile->getModLoader() == ModAPI::Unspecified) {
|
||||||
QMessageBox::critical(this,tr("Error"),tr("Please install a mod loader first!"));
|
QMessageBox::critical(this,tr("Error"),tr("Please install a mod loader first!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ void ModPage::onSelectionChanged(QModelIndex first, QModelIndex second)
|
|||||||
text = name;
|
text = name;
|
||||||
else
|
else
|
||||||
text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
|
text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
|
||||||
|
|
||||||
if (!current.authors.empty()) {
|
if (!current.authors.empty()) {
|
||||||
auto authorToStr = [](ModPlatform::ModpackAuthor& author) -> QString {
|
auto authorToStr = [](ModPlatform::ModpackAuthor& author) -> QString {
|
||||||
if (author.url.isEmpty()) { return author.name; }
|
if (author.url.isEmpty()) { return author.name; }
|
||||||
@ -128,7 +128,7 @@ void ModPage::onModSelected()
|
|||||||
|
|
||||||
void ModPage::retranslate()
|
void ModPage::retranslate()
|
||||||
{
|
{
|
||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModPage::updateModVersions()
|
void ModPage::updateModVersions()
|
||||||
@ -137,26 +137,13 @@ void ModPage::updateModVersions()
|
|||||||
|
|
||||||
QString mcVersion = packProfile->getComponentVersion("net.minecraft");
|
QString mcVersion = packProfile->getComponentVersion("net.minecraft");
|
||||||
|
|
||||||
QString loaderString;
|
QString loaderString = ModAPI::getModLoaderString(packProfile->getModLoader());
|
||||||
switch (packProfile->getModLoader()) {
|
|
||||||
case ModAPI::Forge:
|
|
||||||
loaderString = "forge";
|
|
||||||
break;
|
|
||||||
case ModAPI::Fabric:
|
|
||||||
loaderString = "fabric";
|
|
||||||
break;
|
|
||||||
case ModAPI::Quilt:
|
|
||||||
loaderString = "quilt";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < current.versions.size(); i++) {
|
for (int i = 0; i < current.versions.size(); i++) {
|
||||||
auto version = current.versions[i];
|
auto version = current.versions[i];
|
||||||
//NOTE: Flame doesn't care about loaderString, so passing it changes nothing.
|
//NOTE: Flame doesn't care about loaderString, so passing it changes nothing.
|
||||||
if (!validateVersion(version, mcVersion, loaderString)) {
|
if (!validateVersion(version, mcVersion, loaderString)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ui->versionSelectionBox->addItem(version.version, QVariant(i));
|
ui->versionSelectionBox->addItem(version.version, QVariant(i));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user