Added optional mods dialog
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
|
||||
#include "modplatform/helpers/OverrideUtils.h"
|
||||
|
||||
#include "modplatform/modrinth/ModrinthPackManifest.h"
|
||||
#include "net/ChecksumValidator.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
@ -16,8 +17,10 @@
|
||||
#include "settings/INISettingsObject.h"
|
||||
|
||||
#include "ui/dialogs/CustomMessageBox.h"
|
||||
#include "ui/pages/modplatform/OptionalModDialog.h"
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <vector>
|
||||
|
||||
bool ModrinthCreationTask::abort()
|
||||
{
|
||||
@ -319,7 +322,7 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path,
|
||||
}
|
||||
|
||||
auto jsonFiles = Json::requireIsArrayOf<QJsonObject>(obj, "files", "modrinth.index.json");
|
||||
bool had_optional = false;
|
||||
std::vector<Modrinth::File> optionalFiles;
|
||||
for (const auto& modInfo : jsonFiles) {
|
||||
Modrinth::File file;
|
||||
file.path = Json::requireString(modInfo, "path").replace("\\", "/");
|
||||
@ -331,18 +334,7 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path,
|
||||
if (support == "unsupported") {
|
||||
continue;
|
||||
} else if (support == "optional") {
|
||||
// TODO: Make a review dialog for choosing which ones the user wants!
|
||||
if (!had_optional && show_optional_dialog) {
|
||||
had_optional = true;
|
||||
auto info = CustomMessageBox::selectable(
|
||||
m_parent, tr("Optional mod detected!"),
|
||||
tr("One or more mods from this modpack are optional. They will be downloaded, but disabled by default!"),
|
||||
QMessageBox::Information);
|
||||
info->exec();
|
||||
}
|
||||
|
||||
if (file.path.endsWith(".jar"))
|
||||
file.path += ".disabled";
|
||||
file.required = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -385,9 +377,29 @@ bool ModrinthCreationTask::parseManifest(const QString& index_path,
|
||||
}
|
||||
}
|
||||
|
||||
files.push_back(file);
|
||||
(file.required ? files : optionalFiles).push_back(file);
|
||||
}
|
||||
|
||||
if (!optionalFiles.empty()) {
|
||||
QStringList oFiles;
|
||||
for (auto file : optionalFiles)
|
||||
oFiles.push_back(file.path);
|
||||
OptionalModDialog optionalModDialog(m_parent, oFiles);
|
||||
if (optionalModDialog.exec() == QDialog::Rejected) {
|
||||
emitAborted();
|
||||
return false;
|
||||
}
|
||||
|
||||
auto selectedMods = optionalModDialog.getResult();
|
||||
for (auto file : optionalFiles) {
|
||||
if (selectedMods.contains(file.path)) {
|
||||
file.required = true;
|
||||
} else if (file.path.endsWith(".jar")) {
|
||||
file.path += ".disabled";
|
||||
}
|
||||
files.push_back(file);
|
||||
}
|
||||
}
|
||||
if (set_internal_data) {
|
||||
auto dependencies = Json::requireObject(obj, "dependencies", "modrinth.index.json");
|
||||
for (auto it = dependencies.begin(), end = dependencies.end(); it != end; ++it) {
|
||||
|
@ -55,6 +55,7 @@ struct File {
|
||||
QCryptographicHash::Algorithm hashAlgorithm;
|
||||
QByteArray hash;
|
||||
QQueue<QUrl> downloads;
|
||||
bool required = true;
|
||||
};
|
||||
|
||||
struct DonationData {
|
||||
|
Reference in New Issue
Block a user