2022-03-03 07:31:23 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QString>
|
2022-03-25 03:09:53 +05:30
|
|
|
#include <QList>
|
2022-03-03 07:31:23 +05:30
|
|
|
|
2022-04-03 03:04:26 +05:30
|
|
|
#include "Version.h"
|
|
|
|
|
2022-03-08 00:52:57 +05:30
|
|
|
namespace ModPlatform {
|
|
|
|
class ListModel;
|
|
|
|
}
|
|
|
|
|
2022-03-03 07:31:23 +05:30
|
|
|
class ModAPI {
|
2022-03-08 00:52:57 +05:30
|
|
|
protected:
|
|
|
|
using CallerType = ModPlatform::ListModel;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~ModAPI() = default;
|
|
|
|
|
2022-05-19 12:10:28 +05:30
|
|
|
enum ModLoaderType {
|
|
|
|
Unspecified = 0,
|
|
|
|
Forge = 1 << 0,
|
|
|
|
Cauldron = 1 << 1,
|
|
|
|
LiteLoader = 1 << 2,
|
|
|
|
Fabric = 1 << 3,
|
|
|
|
Quilt = 1 << 4
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(ModLoaderTypes, ModLoaderType)
|
2022-03-03 07:31:23 +05:30
|
|
|
|
2022-03-08 00:52:57 +05:30
|
|
|
struct SearchArgs {
|
|
|
|
int offset;
|
|
|
|
QString search;
|
|
|
|
QString sorting;
|
2022-05-19 12:10:28 +05:30
|
|
|
ModLoaderTypes loaders;
|
2022-04-03 03:04:26 +05:30
|
|
|
std::list<Version> versions;
|
2022-03-08 00:52:57 +05:30
|
|
|
};
|
2022-03-07 01:15:39 +05:30
|
|
|
|
2022-03-08 01:16:08 +05:30
|
|
|
virtual void searchMods(CallerType* caller, SearchArgs&& args) const = 0;
|
2022-03-25 03:09:53 +05:30
|
|
|
|
|
|
|
|
|
|
|
struct VersionSearchArgs {
|
|
|
|
QString addonId;
|
2022-04-03 03:04:26 +05:30
|
|
|
std::list<Version> mcVersions;
|
2022-05-19 12:10:28 +05:30
|
|
|
ModLoaderTypes loaders;
|
2022-03-25 03:09:53 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
virtual void getVersions(CallerType* caller, VersionSearchArgs&& args) const = 0;
|
2022-04-15 01:25:03 +05:30
|
|
|
|
|
|
|
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 "";
|
|
|
|
}
|
2022-04-03 03:04:26 +05:30
|
|
|
|
|
|
|
protected:
|
|
|
|
inline auto getGameVersionsString(std::list<Version> mcVersions) const -> QString
|
|
|
|
{
|
|
|
|
QString s;
|
|
|
|
for(auto& ver : mcVersions){
|
2022-05-29 21:53:34 +05:30
|
|
|
s += QString("\"%1\",").arg(ver.toString());
|
2022-04-03 03:04:26 +05:30
|
|
|
}
|
2022-04-03 03:51:02 +05:30
|
|
|
s.remove(s.length() - 1, 1); //remove last comma
|
2022-04-03 03:04:26 +05:30
|
|
|
return s;
|
|
|
|
}
|
2022-03-03 07:31:23 +05:30
|
|
|
};
|