refactor: cleanup ModLoaderType

This commit is contained in:
Sefa Eyeoglu
2022-04-14 21:55:03 +02:00
parent 18ac109e5a
commit 9fb5674233
5 changed files with 31 additions and 35 deletions

View File

@ -15,7 +15,7 @@ class ModAPI {
virtual ~ModAPI() = default;
// 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 {
int offset;
@ -35,4 +35,22 @@ class ModAPI {
};
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 "";
}
};

View File

@ -51,25 +51,16 @@ class ModrinthAPI : public NetworkModAPI {
return s;
}
inline auto getModLoaderString(ModLoaderType modLoader) const -> QString
static auto getModLoaderString(ModLoaderType type) -> const QString
{
switch (modLoader) {
case Any:
return "fabric, forge, quilt";
case Forge:
return "forge";
case Fabric:
return "fabric";
case Quilt:
return "quilt";
default:
return "";
}
if (type == Unspecified)
return "fabric, forge, quilt";
return ModAPI::getModLoaderString(type);
}
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;
}
};