2022-05-27 02:48:54 +05:30
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
|
|
|
* PolyMC - Minecraft Launcher
|
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following copyright and
|
|
|
|
* permission notice:
|
|
|
|
*
|
|
|
|
* Copyright 2013-2021 MultiMC Contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-03-03 07:31:23 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QString>
|
2022-03-25 03:09:53 +05:30
|
|
|
#include <QList>
|
2022-05-03 01:04:55 +05:30
|
|
|
#include <list>
|
2022-03-03 07:31:23 +05:30
|
|
|
|
2022-04-03 03:04:26 +05:30
|
|
|
#include "Version.h"
|
2022-06-19 22:59:21 +05:30
|
|
|
#include "net/NetJob.h"
|
2022-04-03 03:04:26 +05:30
|
|
|
|
2022-03-08 00:52:57 +05:30
|
|
|
namespace ModPlatform {
|
|
|
|
class ListModel;
|
2022-05-24 18:08:48 +05:30
|
|
|
struct IndexedPack;
|
2022-03-08 00:52:57 +05:30
|
|
|
}
|
|
|
|
|
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-05-24 18:08:48 +05:30
|
|
|
virtual void getModInfo(CallerType* caller, ModPlatform::IndexedPack& pack) = 0;
|
2022-06-19 22:59:21 +05:30
|
|
|
|
|
|
|
virtual auto getProject(QString addonId, QByteArray* response) const -> NetJob::Ptr = 0;
|
|
|
|
virtual auto getProjects(QStringList addonIds, QByteArray* response) const -> NetJob::Ptr = 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
|
|
|
};
|