aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/mod
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/minecraft/mod')
-rw-r--r--launcher/minecraft/mod/DataPack.cpp8
-rw-r--r--launcher/minecraft/mod/MetadataHandler.h55
-rw-r--r--launcher/minecraft/mod/Mod.cpp81
-rw-r--r--launcher/minecraft/mod/Mod.h98
-rw-r--r--launcher/minecraft/mod/ModDetails.h123
-rw-r--r--launcher/minecraft/mod/ModFolderModel.cpp254
-rw-r--r--launcher/minecraft/mod/ModFolderModel.h107
-rw-r--r--launcher/minecraft/mod/Resource.cpp8
-rw-r--r--launcher/minecraft/mod/Resource.h21
-rw-r--r--launcher/minecraft/mod/ResourceFolderModel.cpp28
-rw-r--r--launcher/minecraft/mod/ResourceFolderModel.h34
-rw-r--r--launcher/minecraft/mod/ResourcePack.cpp2
-rw-r--r--launcher/minecraft/mod/ResourcePackFolderModel.cpp28
-rw-r--r--launcher/minecraft/mod/ResourcePackFolderModel.h23
-rw-r--r--launcher/minecraft/mod/ShaderPackFolderModel.h6
-rw-r--r--launcher/minecraft/mod/TexturePack.cpp4
-rw-r--r--launcher/minecraft/mod/TexturePack.h2
-rw-r--r--launcher/minecraft/mod/TexturePackFolderModel.cpp29
-rw-r--r--launcher/minecraft/mod/TexturePackFolderModel.h25
-rw-r--r--launcher/minecraft/mod/tasks/BasicFolderLoadTask.h12
-rw-r--r--launcher/minecraft/mod/tasks/GetModDependenciesTask.cpp20
-rw-r--r--launcher/minecraft/mod/tasks/LocalModParseTask.cpp62
-rw-r--r--launcher/minecraft/mod/tasks/LocalModUpdateTask.h30
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp10
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h2
-rw-r--r--launcher/minecraft/mod/tasks/LocalResourceParse.cpp29
-rw-r--r--launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp13
-rw-r--r--launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h2
-rw-r--r--launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.cpp8
-rw-r--r--launcher/minecraft/mod/tasks/LocalWorldSaveParseTask.h2
-rw-r--r--launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp77
-rw-r--r--launcher/minecraft/mod/tasks/ModFolderLoadTask.h82
32 files changed, 598 insertions, 687 deletions
diff --git a/launcher/minecraft/mod/DataPack.cpp b/launcher/minecraft/mod/DataPack.cpp
index c5754638..7bf5a311 100644
--- a/launcher/minecraft/mod/DataPack.cpp
+++ b/launcher/minecraft/mod/DataPack.cpp
@@ -30,10 +30,10 @@
// Values taken from:
// https://minecraft.fandom.com/wiki/Tutorials/Creating_a_data_pack#%22pack_format%22
static const QMap<int, std::pair<Version, Version>> s_pack_format_versions = {
- { 4, { Version("1.13"), Version("1.14.4") } }, { 5, { Version("1.15"), Version("1.16.1") } },
- { 6, { Version("1.16.2"), Version("1.16.5") } }, { 7, { Version("1.17"), Version("1.17.1") } },
- { 8, { Version("1.18"), Version("1.18.1") } }, { 9, { Version("1.18.2"), Version("1.18.2") } },
- { 10, { Version("1.19"), Version("1.19.3") } }, { 11, { Version("23w03a"), Version("23w05a") } },
+ { 4, { Version("1.13"), Version("1.14.4") } }, { 5, { Version("1.15"), Version("1.16.1") } },
+ { 6, { Version("1.16.2"), Version("1.16.5") } }, { 7, { Version("1.17"), Version("1.17.1") } },
+ { 8, { Version("1.18"), Version("1.18.1") } }, { 9, { Version("1.18.2"), Version("1.18.2") } },
+ { 10, { Version("1.19"), Version("1.19.3") } }, { 11, { Version("23w03a"), Version("23w05a") } },
{ 12, { Version("1.19.4"), Version("1.19.4") } }, { 13, { Version("23w12a"), Version("23w14a") } },
{ 14, { Version("23w16a"), Version("23w17a") } }, { 15, { Version("1.20"), Version("1.20") } },
};
diff --git a/launcher/minecraft/mod/MetadataHandler.h b/launcher/minecraft/mod/MetadataHandler.h
index 39723b49..88e9ff2b 100644
--- a/launcher/minecraft/mod/MetadataHandler.h
+++ b/launcher/minecraft/mod/MetadataHandler.h
@@ -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/>.
-*/
+ * Prism Launcher - 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
@@ -42,28 +42,13 @@ class Metadata {
return Packwiz::V1::createModFormat(index_dir, internal_mod, mod_slug);
}
- static void update(QDir& index_dir, ModStruct& mod)
- {
- Packwiz::V1::updateModIndex(index_dir, mod);
- }
+ static void update(QDir& index_dir, ModStruct& mod) { Packwiz::V1::updateModIndex(index_dir, mod); }
- static void remove(QDir& index_dir, QString mod_slug)
- {
- Packwiz::V1::deleteModIndex(index_dir, mod_slug);
- }
+ static void remove(QDir& index_dir, QString mod_slug) { Packwiz::V1::deleteModIndex(index_dir, mod_slug); }
- static void remove(QDir& index_dir, QVariant& mod_id)
- {
- Packwiz::V1::deleteModIndex(index_dir, mod_id);
- }
+ static void remove(QDir& index_dir, QVariant& mod_id) { Packwiz::V1::deleteModIndex(index_dir, mod_id); }
- static auto get(QDir& index_dir, QString mod_slug) -> ModStruct
- {
- return Packwiz::V1::getIndexForMod(index_dir, mod_slug);
- }
+ static auto get(QDir& index_dir, QString mod_slug) -> ModStruct { return Packwiz::V1::getIndexForMod(index_dir, mod_slug); }
- static auto get(QDir& index_dir, QVariant& mod_id) -> ModStruct
- {
- return Packwiz::V1::getIndexForMod(index_dir, mod_id);
- }
+ static auto get(QDir& index_dir, QVariant& mod_id) -> ModStruct { return Packwiz::V1::getIndexForMod(index_dir, mod_id); }
};
diff --git a/launcher/minecraft/mod/Mod.cpp b/launcher/minecraft/mod/Mod.cpp
index 880dacb1..ae3dea8d 100644
--- a/launcher/minecraft/mod/Mod.cpp
+++ b/launcher/minecraft/mod/Mod.cpp
@@ -1,45 +1,45 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
-* PolyMC - Minecraft Launcher
-* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
-* 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.
-*/
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
+ * 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.
+ */
#include "Mod.h"
#include <QDebug>
#include <QDir>
-#include <QString>
#include <QRegularExpression>
+#include <QString>
#include "MTPixmapCache.h"
#include "MetadataHandler.h"
@@ -54,8 +54,7 @@ Mod::Mod(const QFileInfo& file) : Resource(file), m_local_details()
m_enabled = (file.suffix() != "disabled");
}
-Mod::Mod(const QDir& mods_dir, const Metadata::ModStruct& metadata)
- : Mod(mods_dir.absoluteFilePath(metadata.filename))
+Mod::Mod(const QDir& mods_dir, const Metadata::ModStruct& metadata) : Mod(mods_dir.absoluteFilePath(metadata.filename))
{
m_name = metadata.name;
m_local_details.metadata = std::make_shared<Metadata::ModStruct>(std::move(metadata));
@@ -73,7 +72,8 @@ void Mod::setMetadata(std::shared_ptr<Metadata::ModStruct>&& metadata)
m_local_details.metadata = metadata;
}
-void Mod::setDetails(const ModDetails& details) {
+void Mod::setDetails(const ModDetails& details)
+{
m_local_details = details;
}
@@ -103,7 +103,8 @@ std::pair<int, bool> Mod::compare(const Resource& other, SortType type) const
break;
}
case SortType::PROVIDER: {
- auto compare_result = QString::compare(provider().value_or("Unknown"), cast_other->provider().value_or("Unknown"), Qt::CaseInsensitive);
+ auto compare_result =
+ QString::compare(provider().value_or("Unknown"), cast_other->provider().value_or("Unknown"), Qt::CaseInsensitive);
if (compare_result != 0)
return { compare_result, type == SortType::PROVIDER };
break;
@@ -230,7 +231,7 @@ auto Mod::licenses() const -> const QList<ModLicense>&
return details().licenses;
}
- auto Mod::issueTracker() const -> QString
+auto Mod::issueTracker() const -> QString
{
return details().issue_tracker;
}
@@ -245,7 +246,7 @@ void Mod::setIcon(QImage new_image) const
PixmapCache::remove(m_pack_image_cache_key.key);
// scale the image to avoid flooding the pixmapcache
- auto pixmap = QPixmap::fromImage(new_image.scaled({64, 64}, Qt::AspectRatioMode::KeepAspectRatioByExpanding));
+ auto pixmap = QPixmap::fromImage(new_image.scaled({ 64, 64 }, Qt::AspectRatioMode::KeepAspectRatioByExpanding));
m_pack_image_cache_key.key = PixmapCache::insert(pixmap);
m_pack_image_cache_key.was_ever_used = true;
diff --git a/launcher/minecraft/mod/Mod.h b/launcher/minecraft/mod/Mod.h
index b67bd465..6dafecfc 100644
--- a/launcher/minecraft/mod/Mod.h
+++ b/launcher/minecraft/mod/Mod.h
@@ -1,79 +1,78 @@
// 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.
-*/
+ * Prism Launcher - 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.
+ */
#pragma once
#include <QDateTime>
#include <QFileInfo>
-#include <QList>
#include <QImage>
+#include <QList>
#include <QMutex>
#include <QPixmap>
#include <QPixmapCache>
#include <optional>
-#include "Resource.h"
#include "ModDetails.h"
+#include "Resource.h"
-class Mod : public Resource
-{
+class Mod : public Resource {
Q_OBJECT
-public:
+ public:
using Ptr = shared_qobject_ptr<Mod>;
using WeakPtr = QPointer<Mod>;
Mod() = default;
- Mod(const QFileInfo &file);
+ Mod(const QFileInfo& file);
Mod(const QDir& mods_dir, const Metadata::ModStruct& metadata);
Mod(QString file_path) : Mod(QFileInfo(file_path)) {}
- auto details() const -> const ModDetails&;
- auto name() const -> QString override;
- auto version() const -> QString;
- auto homeurl() const -> QString;
+ auto details() const -> const ModDetails&;
+ auto name() const -> QString override;
+ auto version() const -> QString;
+ auto homeurl() const -> QString;
auto description() const -> QString;
- auto authors() const -> QStringList;
- auto status() const -> ModStatus;
- auto provider() const -> std::optional<QString>;
- auto licenses() const -> const QList<ModLicense>&;
+ auto authors() const -> QStringList;
+ auto status() const -> ModStatus;
+ auto provider() const -> std::optional<QString>;
+ auto licenses() const -> const QList<ModLicense>&;
auto issueTracker() const -> QString;
- auto metaurl() const -> QString;
+ auto metaurl() const -> QString;
/** Get the intneral path to the mod's icon file*/
- QString iconPath() const { return m_local_details.icon_file; };
+ QString iconPath() const { return m_local_details.icon_file; }
/** Gets the icon of the mod, converted to a QPixmap for drawing, and scaled to size. */
[[nodiscard]] QPixmap icon(QSize size, Qt::AspectRatioMode mode = Qt::AspectRatioMode::IgnoreAspectRatio) const;
/** Thread-safe. */
@@ -97,7 +96,7 @@ public:
void finishResolvingWithDetails(ModDetails&& details);
-protected:
+ protected:
ModDetails m_local_details;
mutable QMutex m_data_lock;
@@ -107,5 +106,4 @@ protected:
bool was_ever_used = false;
bool was_read_attempt = false;
} mutable m_pack_image_cache_key;
-
};
diff --git a/launcher/minecraft/mod/ModDetails.h b/launcher/minecraft/mod/ModDetails.h
index b4e59d52..a00d5a24 100644
--- a/launcher/minecraft/mod/ModDetails.h
+++ b/launcher/minecraft/mod/ModDetails.h
@@ -1,37 +1,37 @@
// 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.
-*/
+ * Prism Launcher - 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.
+ */
#pragma once
@@ -44,10 +44,10 @@
#include "minecraft/mod/MetadataHandler.h"
enum class ModStatus {
- Installed, // Both JAR and Metadata are present
- NotInstalled, // Only the Metadata is present
- NoMetadata, // Only the JAR is present
- Unknown, // Default status
+ Installed, // Both JAR and Metadata are present
+ NotInstalled, // Only the Metadata is present
+ NoMetadata, // Only the JAR is present
+ Unknown, // Default status
};
struct ModLicense {
@@ -58,18 +58,19 @@ struct ModLicense {
ModLicense() {}
- ModLicense(const QString license) {
- // FIXME: come up with a better license parseing.
+ ModLicense(const QString license)
+ {
+ // FIXME: come up with a better license parsing.
// handle SPDX identifiers? https://spdx.org/licenses/
auto parts = license.split(' ');
- QStringList notNameParts = {};
+ QStringList notNameParts = {};
for (auto part : parts) {
- auto url = QUrl(part);
+ auto _url = QUrl(part);
if (part.startsWith("(") && part.endsWith(")"))
- url = QUrl(part.mid(1, part.size() - 2));
+ _url = QUrl(part.mid(1, part.size() - 2));
- if (url.isValid() && !url.scheme().isEmpty() && !url.host().isEmpty()) {
- this->url = url.toString();
+ if (_url.isValid() && !_url.scheme().isEmpty() && !_url.host().isEmpty()) {
+ this->url = _url.toString();
notNameParts.append(part);
continue;
}
@@ -78,7 +79,7 @@ struct ModLicense {
for (auto part : notNameParts) {
parts.removeOne(part);
}
-
+
auto licensePart = parts.join(' ');
this->name = licensePart;
this->description = licensePart;
@@ -86,23 +87,14 @@ struct ModLicense {
if (parts.size() == 1) {
this->id = parts.first();
}
-
- }
-
- ModLicense(const QString name, const QString id, const QString url, const QString description) {
- this->name = name;
- this->id = id;
- this->url = url;
- this->description = description;
}
- ModLicense(const ModLicense& other)
- : name(other.name)
- , id(other.id)
- , url(other.url)
- , description(other.description)
+ ModLicense(const QString& name_, const QString& id_, const QString& url_, const QString& description_)
+ : name(name_), id(id_), url(url_), description(description_)
{}
+ ModLicense(const ModLicense& other) : name(other.name), id(other.id), url(other.url), description(other.description) {}
+
ModLicense& operator=(const ModLicense& other)
{
this->name = other.name;
@@ -123,28 +115,25 @@ struct ModLicense {
return *this;
}
- bool isEmpty() {
- return this->name.isEmpty() && this->id.isEmpty() && this->url.isEmpty() && this->description.isEmpty();
- }
+ bool isEmpty() { return this->name.isEmpty() && this->id.isEmpty() && this->url.isEmpty() && this->description.isEmpty(); }
};
-struct ModDetails
-{
+struct ModDetails {
/* Mod ID as defined in the ModLoader-specific metadata */
QString mod_id = {};
-
+
/* Human-readable name */
QString name = {};
-
+
/* Human-readable mod version */
QString version = {};
-
+
/* Human-readable minecraft version */
QString mcversion = {};
-
+
/* URL for mod's home page */
QString homeurl = {};
-
+
/* Human-readable description */
QString description = {};
diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp
index 51383edf..280e70d7 100644
--- a/launcher/minecraft/mod/ModFolderModel.cpp
+++ b/launcher/minecraft/mod/ModFolderModel.cpp
@@ -1,38 +1,38 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
-* PolyMC - Minecraft Launcher
-* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
-* 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.
-*/
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
+ * 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.
+ */
#include "ModFolderModel.h"
@@ -59,11 +59,13 @@ ModFolderModel::ModFolderModel(const QString& dir, BaseInstance* instance, bool
{
m_column_names = QStringList({ "Enable", "Image", "Name", "Version", "Last Modified", "Provider" });
m_column_names_translated = QStringList({ tr("Enable"), tr("Image"), tr("Name"), tr("Version"), tr("Last Modified"), tr("Provider") });
- m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME , SortType::VERSION, SortType::DATE, SortType::PROVIDER};
- m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Interactive, QHeaderView::Stretch, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents};
+ m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME, SortType::VERSION, SortType::DATE, SortType::PROVIDER };
+ m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Interactive, QHeaderView::Stretch,
+ QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents };
+ m_columnsHideable = { false, true, false, true, true, true };
}
-QVariant ModFolderModel::data(const QModelIndex &index, int role) const
+QVariant ModFolderModel::data(const QModelIndex& index, int role) const
{
if (!validateIndex(index))
return {};
@@ -71,115 +73,109 @@ QVariant ModFolderModel::data(const QModelIndex &index, int role) const
int row = index.row();
int column = index.column();
- switch (role)
- {
- case Qt::DisplayRole:
- switch (column)
- {
- case NameColumn:
- return m_resources[row]->name();
- case VersionColumn: {
- switch(m_resources[row]->type()) {
- case ResourceType::FOLDER:
- return tr("Folder");
- case ResourceType::SINGLEFILE:
- return tr("File");
+ switch (role) {
+ case Qt::DisplayRole:
+ switch (column) {
+ case NameColumn:
+ return m_resources[row]->name();
+ case VersionColumn: {
+ switch (m_resources[row]->type()) {
+ case ResourceType::FOLDER:
+ return tr("Folder");
+ case ResourceType::SINGLEFILE:
+ return tr("File");
+ default:
+ break;
+ }
+ return at(row)->version();
+ }
+ case DateColumn:
+ return m_resources[row]->dateTimeChanged();
+ case ProviderColumn: {