Added task to load dependencies

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2023-04-12 00:45:44 +03:00
parent d524935b67
commit 4fbd5abe41
7 changed files with 254 additions and 74 deletions

View File

@ -21,6 +21,8 @@
#include <QDebug>
#include <QDir>
#include <QObject>
#include <algorithm>
#include <iterator>
#include "FileSystem.h"
#include "StringUtils.h"
@ -311,4 +313,13 @@ auto V1::getIndexForMod(QDir& index_dir, QVariant& mod_id) -> Mod
return {};
}
auto V1::getAllMods(QDir& index_dir) -> QList<Mod>
{
auto files = index_dir.entryList(QDir::Filter::Files);
auto mods = QList<Mod>();
std::transform(files.begin(), files.end(), std::back_inserter(mods),
[index_dir](auto file_name) { return getIndexForMod(index_dir, file_name); });
return mods;
}
} // namespace Packwiz

View File

@ -1,20 +1,20 @@
// 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/>.
*/
* 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/>.
*/
#pragma once
@ -36,22 +36,22 @@ auto getRealIndexName(QDir& index_dir, QString normalized_index_name, bool shoul
class V1 {
public:
struct Mod {
QString slug {};
QString name {};
QString filename {};
QString slug{};
QString name{};
QString filename{};
// FIXME: make side an enum
QString side {"both"};
QString side{ "both" };
// [download]
QString mode {};
QUrl url {};
QString hash_format {};
QString hash {};
QString mode{};
QUrl url{};
QString hash_format{};
QString hash{};
// [update]
ModPlatform::ResourceProvider provider {};
QVariant file_id {};
QVariant project_id {};
ModPlatform::ResourceProvider provider{};
QVariant file_id{};
QVariant project_id{};
public:
// This is a totally heuristic, but should work for now.
@ -93,6 +93,9 @@ class V1 {
* If the mod doesn't have a metadata, it simply returns an empty Mod object.
* */
static auto getIndexForMod(QDir& index_dir, QVariant& mod_id) -> Mod;
/* Gets the metadata for all the mods */
static auto getAllMods(QDir& index_dir) -> QList<Mod>;
};
} // namespace Packwiz
} // namespace Packwiz