2022-03-03 02:01:23 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QString>
|
2022-03-24 21:39:53 +00:00
|
|
|
#include <QList>
|
2022-03-03 02:01:23 +00:00
|
|
|
|
2022-04-02 22:34:26 +01:00
|
|
|
#include "Version.h"
|
|
|
|
|
2022-03-07 19:22:57 +00:00
|
|
|
namespace ModPlatform {
|
|
|
|
class ListModel;
|
2022-05-24 13:38:48 +01:00
|
|
|
struct IndexedPack;
|
2022-03-07 19:22:57 +00:00
|
|
|
}
|
|
|
|
|
2022-03-03 02:01:23 +00:00
|
|
|
class ModAPI {
|
2022-03-07 19:22:57 +00:00
|
|
|
protected:
|
|
|
|
using CallerType = ModPlatform::ListModel;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~ModAPI() = default;
|
|
|
|
|
2022-05-19 07:40:28 +01:00
|
|
|
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 02:01:23 +00:00
|
|
|
|
2022-03-07 19:22:57 +00:00
|
|
|
struct SearchArgs {
|
|
|
|
int offset;
|
|
|
|
QString search;
|
|
|
|
QString sorting;
|
2022-05-19 07:40:28 +01:00
|
|
|
ModLoaderTypes loaders;
|
2022-04-02 22:34:26 +01:00
|
|
|
std::list<Version> versions;
|
2022-03-07 19:22:57 +00:00
|
|
|
};
|
2022-03-06 19:45:39 +00:00
|
|
|
|
2022-03-07 19:46:08 +00:00
|
|
|
virtual void searchMods(CallerType* caller, SearchArgs&& args) const = 0;
|
2022-05-24 13:38:48 +01:00
|
|
|
virtual void getModInfo(CallerType* caller, ModPlatform::IndexedPack& pack) = 0;
|
2022-03-24 21:39:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct VersionSearchArgs {
|
|
|
|
QString addonId;
|
2022-04-02 22:34:26 +01:00
|
|
|
std::list<Version> mcVersions;
|
2022-05-19 07:40:28 +01:00
|
|
|
ModLoaderTypes loaders;
|
2022-03-24 21:39:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual void getVersions(CallerType* caller, VersionSearchArgs&& args) const = 0;
|
2022-04-14 20:55:03 +01:00
|
|
|
|
|
|
|
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-02 22:34:26 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
inline auto getGameVersionsString(std::list<Version> mcVersions) const -> QString
|
|
|
|
{
|
|
|
|
QString s;
|
|
|
|
for(auto& ver : mcVersions){
|
2022-05-29 17:23:34 +01:00
|
|
|
s += QString("\"%1\",").arg(ver.toString());
|
2022-04-02 22:34:26 +01:00
|
|
|
}
|
2022-04-02 23:21:02 +01:00
|
|
|
s.remove(s.length() - 1, 1); //remove last comma
|
2022-04-02 22:34:26 +01:00
|
|
|
return s;
|
|
|
|
}
|
2022-03-03 02:01:23 +00:00
|
|
|
};
|