2022-05-10 23:57:47 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
|
|
|
* PolyMC - Minecraft Launcher
|
|
|
|
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2013-08-14 07:13:41 +01:00
|
|
|
|
|
|
|
#pragma once
|
2022-04-15 04:24:57 +01:00
|
|
|
|
2016-11-17 01:55:02 +00:00
|
|
|
#include <QDateTime>
|
2022-04-15 04:24:57 +01:00
|
|
|
#include <QFileInfo>
|
2019-08-04 02:27:53 +01:00
|
|
|
#include <QList>
|
|
|
|
|
2022-12-29 15:39:20 +00:00
|
|
|
#include <optional>
|
|
|
|
|
2022-08-09 05:53:50 +01:00
|
|
|
#include "Resource.h"
|
2019-08-04 02:27:53 +01:00
|
|
|
#include "ModDetails.h"
|
2019-08-03 04:30:46 +01:00
|
|
|
|
2022-08-09 05:53:50 +01:00
|
|
|
class Mod : public Resource
|
2013-08-14 07:13:41 +01:00
|
|
|
{
|
2022-06-26 18:17:15 +01:00
|
|
|
Q_OBJECT
|
2013-08-14 07:13:41 +01:00
|
|
|
public:
|
2022-06-26 18:17:15 +01:00
|
|
|
using Ptr = shared_qobject_ptr<Mod>;
|
2022-08-11 22:24:26 +01:00
|
|
|
using WeakPtr = QPointer<Mod>;
|
2022-06-26 18:17:15 +01:00
|
|
|
|
2019-08-04 02:27:53 +01:00
|
|
|
Mod() = default;
|
2013-08-14 07:13:41 +01:00
|
|
|
Mod(const QFileInfo &file);
|
2022-08-10 18:48:34 +01:00
|
|
|
Mod(const QDir& mods_dir, const Metadata::ModStruct& metadata);
|
|
|
|
Mod(QString file_path) : Mod(QFileInfo(file_path)) {}
|
2018-07-15 13:51:05 +01:00
|
|
|
|
2022-04-20 00:19:51 +01:00
|
|
|
auto details() const -> const ModDetails&;
|
2022-08-09 05:53:50 +01:00
|
|
|
auto name() const -> QString override;
|
2022-04-20 00:19:51 +01:00
|
|
|
auto version() const -> QString;
|
|
|
|
auto homeurl() const -> QString;
|
|
|
|
auto description() const -> QString;
|
|
|
|
auto authors() const -> QStringList;
|
2022-04-20 22:45:39 +01:00
|
|
|
auto status() const -> ModStatus;
|
2022-12-29 15:39:20 +00:00
|
|
|
auto provider() const -> std::optional<QString>;
|
2019-08-03 04:30:46 +01:00
|
|
|
|
2022-06-05 03:11:25 +01:00
|
|
|
auto metadata() -> std::shared_ptr<Metadata::ModStruct>;
|
|
|
|
auto metadata() const -> const std::shared_ptr<Metadata::ModStruct>;
|
2022-04-17 13:30:32 +01:00
|
|
|
|
2022-04-20 22:45:39 +01:00
|
|
|
void setStatus(ModStatus status);
|
2022-08-12 21:06:20 +01:00
|
|
|
void setMetadata(std::shared_ptr<Metadata::ModStruct>&& metadata);
|
|
|
|
void setMetadata(const Metadata::ModStruct& metadata) { setMetadata(std::make_shared<Metadata::ModStruct>(metadata)); }
|
2022-12-10 07:52:50 +00:00
|
|
|
void setDetails(const ModDetails& details);
|
|
|
|
|
|
|
|
bool valid() const override;
|
2022-04-20 22:45:39 +01:00
|
|
|
|
2022-08-10 18:42:24 +01:00
|
|
|
[[nodiscard]] auto compare(Resource const& other, SortType type) const -> std::pair<int, bool> override;
|
|
|
|
[[nodiscard]] bool applyFilter(QRegularExpression filter) const override;
|
|
|
|
|
2022-08-09 05:53:50 +01:00
|
|
|
// Delete all the files of this mod
|
2022-06-10 23:27:25 +01:00
|
|
|
auto destroy(QDir& index_dir, bool preserve_metadata = false) -> bool;
|
2019-08-03 04:30:46 +01:00
|
|
|
|
2022-08-12 21:06:20 +01:00
|
|
|
void finishResolvingWithDetails(ModDetails&& details);
|
2019-08-04 02:27:53 +01:00
|
|
|
|
2013-08-14 07:13:41 +01:00
|
|
|
protected:
|
2022-08-12 21:06:20 +01:00
|
|
|
ModDetails m_local_details;
|
2013-08-14 07:13:41 +01:00
|
|
|
};
|