From 25ffc4c4b0239ba782a5d10397965a6a61885d82 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 29 Jun 2023 17:58:09 +0300 Subject: [PATCH 01/79] Refactor ImgurUpload Signed-off-by: Trial97 --- launcher/CMakeLists.txt | 1 + launcher/net/NetRequest.cpp | 2 + launcher/net/StaticHeaderProxy.h | 39 ++++++ launcher/screenshots/ImgurAlbumCreation.cpp | 123 ++++++++---------- launcher/screenshots/ImgurAlbumCreation.h | 60 ++++----- launcher/screenshots/ImgurUpload.cpp | 119 +++++++---------- launcher/screenshots/ImgurUpload.h | 47 ++++--- .../ui/pages/instance/ScreenshotsPage.cpp | 70 ++++------ 8 files changed, 224 insertions(+), 237 deletions(-) create mode 100644 launcher/net/StaticHeaderProxy.h diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 44988db20..e5fb815c3 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -139,6 +139,7 @@ set(NET_SOURCES net/HeaderProxy.h net/RawHeaderProxy.h net/ApiHeaderProxy.h + net/StaticHeaderProxy.h net/ApiDownload.h net/ApiDownload.cpp net/ApiUpload.cpp diff --git a/launcher/net/NetRequest.cpp b/launcher/net/NetRequest.cpp index 304577121..35072d355 100644 --- a/launcher/net/NetRequest.cpp +++ b/launcher/net/NetRequest.cpp @@ -111,6 +111,8 @@ void NetRequest::executeTask() m_last_progress_bytes = 0; QNetworkReply* rep = getReply(request); + if (rep == nullptr) // it failed + return; m_reply.reset(rep); connect(rep, &QNetworkReply::downloadProgress, this, &NetRequest::downloadProgress); connect(rep, &QNetworkReply::finished, this, &NetRequest::downloadFinished); diff --git a/launcher/net/StaticHeaderProxy.h b/launcher/net/StaticHeaderProxy.h new file mode 100644 index 000000000..8af7d203d --- /dev/null +++ b/launcher/net/StaticHeaderProxy.h @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.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 . + * + */ + +#pragma once + +#include "net/HeaderProxy.h" + +namespace Net { + +class StaticHeaderProxy : public HeaderProxy { + public: + StaticHeaderProxy(QList hdrs = {}) : HeaderProxy(), m_hdrs(hdrs){}; + virtual ~StaticHeaderProxy() = default; + + public: + virtual QList headers(const QNetworkRequest&) const override { return m_hdrs; }; + void setHeaders(QList hdrs) { m_hdrs = hdrs; }; + + private: + QList m_hdrs; +}; + +} // namespace Net diff --git a/launcher/screenshots/ImgurAlbumCreation.cpp b/launcher/screenshots/ImgurAlbumCreation.cpp index ab425f1a0..c9d73b8d4 100644 --- a/launcher/screenshots/ImgurAlbumCreation.cpp +++ b/launcher/screenshots/ImgurAlbumCreation.cpp @@ -36,96 +36,79 @@ #include "ImgurAlbumCreation.h" -#include +#include #include #include -#include +#include +#include #include -#include +#include +#include #include "BuildConfig.h" -#include "Application.h" +#include "net/StaticHeaderProxy.h" -ImgurAlbumCreation::ImgurAlbumCreation(QList screenshots) : NetAction(), m_screenshots(screenshots) +Net::NetRequest::Ptr ImgurAlbumCreation::make(std::shared_ptr output, QList screenshots) { - m_url = BuildConfig.IMGUR_BASE_URL + "album.json"; - m_state = State::Inactive; + auto up = makeShared(); + up->m_url = BuildConfig.IMGUR_BASE_URL + "album.json"; + up->m_sink.reset(new Sink(output)); + up->m_screenshots = screenshots; + return up; } -void ImgurAlbumCreation::executeTask() +QNetworkReply* ImgurAlbumCreation::getReply(QNetworkRequest& request) { - m_state = State::Running; - QNetworkRequest request(m_url); - request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgentUncached().toUtf8()); - request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); - request.setRawHeader("Authorization", QString("Client-ID %1").arg(BuildConfig.IMGUR_CLIENT_ID).toStdString().c_str()); - request.setRawHeader("Accept", "application/json"); - QStringList hashes; - for (auto shot : m_screenshots) - { + for (auto shot : m_screenshots) { hashes.append(shot->m_imgurDeleteHash); } - const QByteArray data = "deletehashes=" + hashes.join(',').toUtf8() + "&title=Minecraft%20Screenshots&privacy=hidden"; + return m_network->post(request, data); +}; - QNetworkReply *rep = APPLICATION->network()->post(request, data); - - m_reply.reset(rep); - connect(rep, &QNetworkReply::uploadProgress, this, &ImgurAlbumCreation::downloadProgress); - connect(rep, &QNetworkReply::finished, this, &ImgurAlbumCreation::downloadFinished); -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15 - connect(rep, &QNetworkReply::errorOccurred, this, &ImgurAlbumCreation::downloadError); -#else - connect(rep, QOverload::of(&QNetworkReply::error), this, &ImgurAlbumCreation::downloadError); -#endif - connect(rep, &QNetworkReply::sslErrors, this, &ImgurAlbumCreation::sslErrors); +void ImgurAlbumCreation::init() +{ + qDebug() << "Setting up imgur upload"; + auto api_headers = new Net::StaticHeaderProxy( + QList{ { "Content-Type", "application/x-www-form-urlencoded" }, + { "Authorization", QString("Client-ID %1").arg(BuildConfig.IMGUR_CLIENT_ID).toStdString().c_str() }, + { "Accept", "application/json" } }); + addHeaderProxy(api_headers); } -void ImgurAlbumCreation::downloadError(QNetworkReply::NetworkError error) +auto ImgurAlbumCreation::Sink::init(QNetworkRequest& request) -> Task::State { - qDebug() << m_reply->errorString(); - m_state = State::Failed; + m_output.clear(); + return Task::State::Running; +}; + +auto ImgurAlbumCreation::Sink::write(QByteArray& data) -> Task::State +{ + m_output.append(data); + return Task::State::Running; } -void ImgurAlbumCreation::downloadFinished() +auto ImgurAlbumCreation::Sink::abort() -> Task::State { - if (m_state != State::Failed) - { - QByteArray data = m_reply->readAll(); - m_reply.reset(); - QJsonParseError jsonError; - QJsonDocument doc = QJsonDocument::fromJson(data, &jsonError); - if (jsonError.error != QJsonParseError::NoError) - { - qDebug() << jsonError.errorString(); - emitFailed(); - return; - } - auto object = doc.object(); - if (!object.value("success").toBool()) - { - qDebug() << doc.toJson(); - emitFailed(); - return; - } - m_deleteHash = object.value("data").toObject().value("deletehash").toString(); - m_id = object.value("data").toObject().value("id").toString(); - m_state = State::Succeeded; - emit succeeded(); - return; + m_output.clear(); + return Task::State::Failed; +} + +auto ImgurAlbumCreation::Sink::finalize(QNetworkReply&) -> Task::State +{ + QJsonParseError jsonError; + QJsonDocument doc = QJsonDocument::fromJson(m_output, &jsonError); + if (jsonError.error != QJsonParseError::NoError) { + qDebug() << jsonError.errorString(); + return Task::State::Failed; } - else - { - qDebug() << m_reply->readAll(); - m_reply.reset(); - emitFailed(); - return; + auto object = doc.object(); + if (!object.value("success").toBool()) { + qDebug() << doc.toJson(); + return Task::State::Failed; } -} - -void ImgurAlbumCreation::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) -{ - setProgress(bytesReceived, bytesTotal); - emit progress(bytesReceived, bytesTotal); -} + m_result->deleteHash = object.value("data").toObject().value("deletehash").toString(); + m_result->id = object.value("data").toObject().value("id").toString(); + return Task::State::Succeeded; +} \ No newline at end of file diff --git a/launcher/screenshots/ImgurAlbumCreation.h b/launcher/screenshots/ImgurAlbumCreation.h index a2b70d8b0..670c35eb3 100644 --- a/launcher/screenshots/ImgurAlbumCreation.h +++ b/launcher/screenshots/ImgurAlbumCreation.h @@ -35,44 +35,40 @@ #pragma once -#include "net/NetAction.h" #include "Screenshot.h" +#include "net/NetRequest.h" -typedef shared_qobject_ptr ImgurAlbumCreationPtr; -class ImgurAlbumCreation : public NetAction -{ -public: - explicit ImgurAlbumCreation(QList screenshots); - static ImgurAlbumCreationPtr make(QList screenshots) - { - return ImgurAlbumCreationPtr(new ImgurAlbumCreation(screenshots)); - } +class ImgurAlbumCreation : public Net::NetRequest { + public: + virtual ~ImgurAlbumCreation() = default; - QString deleteHash() const - { - return m_deleteHash; - } - QString id() const - { - return m_id; - } + struct Result { + QString deleteHash; + QString id; + }; - void init() override {}; + class Sink : public Net::Sink { + public: + Sink(std::shared_ptr res) : m_result(res){}; + virtual ~Sink() = default; -protected -slots: - void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) override; - void downloadError(QNetworkReply::NetworkError error) override; - void downloadFinished() override; - void downloadReadyRead() override {} + public: + auto init(QNetworkRequest& request) -> Task::State override; + auto write(QByteArray& data) -> Task::State override; + auto abort() -> Task::State override; + auto finalize(QNetworkReply& reply) -> Task::State override; + auto hasLocalData() -> bool override { return false; } -public -slots: - void executeTask() override; + private: + std::shared_ptr m_result; + QByteArray m_output; + }; -private: + static NetRequest::Ptr make(std::shared_ptr output, QList screenshots); + QNetworkReply* getReply(QNetworkRequest& request) override; + + void init() override; + + private: QList m_screenshots; - - QString m_deleteHash; - QString m_id; }; diff --git a/launcher/screenshots/ImgurUpload.cpp b/launcher/screenshots/ImgurUpload.cpp index a50f9afae..5213d2d71 100644 --- a/launcher/screenshots/ImgurUpload.cpp +++ b/launcher/screenshots/ImgurUpload.cpp @@ -36,120 +36,95 @@ #include "ImgurUpload.h" #include "BuildConfig.h" -#include "Application.h" +#include "net/StaticHeaderProxy.h" -#include +#include +#include #include +#include #include #include -#include -#include +#include #include -#include -ImgurUpload::ImgurUpload(ScreenShot::Ptr shot) : NetAction(), m_shot(shot) +void ImgurUpload::init() { - m_url = BuildConfig.IMGUR_BASE_URL + "upload.json"; - m_state = State::Inactive; + qDebug() << "Setting up imgur upload"; + auto api_headers = new Net::StaticHeaderProxy( + QList{ { "Authorization", QString("Client-ID %1").arg(BuildConfig.IMGUR_CLIENT_ID).toStdString().c_str() }, + { "Accept", "application/json" } }); + addHeaderProxy(api_headers); } -void ImgurUpload::executeTask() +QNetworkReply* ImgurUpload::getReply(QNetworkRequest& request) { - finished = false; - m_state = Task::State::Running; - QNetworkRequest request(m_url); - request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgentUncached().toUtf8()); - request.setRawHeader("Authorization", QString("Client-ID %1").arg(BuildConfig.IMGUR_CLIENT_ID).toStdString().c_str()); - request.setRawHeader("Accept", "application/json"); + auto file = new QFile(m_fileInfo.absoluteFilePath()); - QFile f(m_shot->m_file.absoluteFilePath()); - if (!f.open(QFile::ReadOnly)) - { + if (!file->open(QFile::ReadOnly)) { emitFailed(); - return; + return nullptr; } - QHttpMultiPart *multipart = new QHttpMultiPart(QHttpMultiPart::FormDataType); + QHttpMultiPart* multipart = new QHttpMultiPart(QHttpMultiPart::FormDataType); + file->setParent(multipart); QHttpPart filePart; - filePart.setBody(f.readAll().toBase64()); + filePart.setBodyDevice(file); filePart.setHeader(QNetworkRequest::ContentTypeHeader, "image/png"); filePart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"image\""); multipart->append(filePart); QHttpPart typePart; typePart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"type\""); - typePart.setBody("base64"); + typePart.setBody("file"); multipart->append(typePart); QHttpPart namePart; namePart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"name\""); - namePart.setBody(m_shot->m_file.baseName().toUtf8()); + namePart.setBody(m_fileInfo.baseName().toUtf8()); multipart->append(namePart); - QNetworkReply *rep = m_network->post(request, multipart); + return m_network->post(request, multipart); +}; - m_reply.reset(rep); - connect(rep, &QNetworkReply::uploadProgress, this, &ImgurUpload::downloadProgress); - connect(rep, &QNetworkReply::finished, this, &ImgurUpload::downloadFinished); -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) // QNetworkReply::errorOccurred added in 5.15 - connect(rep, &QNetworkReply::errorOccurred, this, &ImgurUpload::downloadError); -#else - connect(rep, QOverload::of(&QNetworkReply::error), this, &ImgurUpload::downloadError); -#endif - connect(rep, &QNetworkReply::sslErrors, this, &ImgurUpload::sslErrors); +auto ImgurUpload::Sink::init(QNetworkRequest& request) -> Task::State +{ + m_output.clear(); + return Task::State::Running; +}; + +auto ImgurUpload::Sink::write(QByteArray& data) -> Task::State +{ + m_output.append(data); + return Task::State::Running; } -void ImgurUpload::downloadError(QNetworkReply::NetworkError error) +auto ImgurUpload::Sink::abort() -> Task::State { - qCritical() << "ImgurUpload failed with error" << m_reply->errorString() << "Server reply:\n" << m_reply->readAll(); - if(finished) - { - qCritical() << "Double finished ImgurUpload!"; - return; - } - m_state = Task::State::Failed; - finished = true; - m_reply.reset(); - emitFailed(); + m_output.clear(); + return Task::State::Failed; } -void ImgurUpload::downloadFinished() +auto ImgurUpload::Sink::finalize(QNetworkReply&) -> Task::State { - if(finished) - { - qCritical() << "Double finished ImgurUpload!"; - return; - } - QByteArray data = m_reply->readAll(); - m_reply.reset(); QJsonParseError jsonError; - QJsonDocument doc = QJsonDocument::fromJson(data, &jsonError); - if (jsonError.error != QJsonParseError::NoError) - { + QJsonDocument doc = QJsonDocument::fromJson(m_output, &jsonError); + if (jsonError.error != QJsonParseError::NoError) { qDebug() << "imgur server did not reply with JSON" << jsonError.errorString(); - finished = true; - m_reply.reset(); - emitFailed(); - return; + return Task::State::Failed; } auto object = doc.object(); - if (!object.value("success").toBool()) - { + if (!object.value("success").toBool()) { qDebug() << "Screenshot upload not successful:" << doc.toJson(); - finished = true; - m_reply.reset(); - emitFailed(); - return; + return Task::State::Failed; } m_shot->m_imgurId = object.value("data").toObject().value("id").toString(); m_shot->m_url = object.value("data").toObject().value("link").toString(); m_shot->m_imgurDeleteHash = object.value("data").toObject().value("deletehash").toString(); - m_state = Task::State::Succeeded; - finished = true; - emit succeeded(); - return; + return Task::State::Succeeded; } -void ImgurUpload::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) +Net::NetRequest::Ptr ImgurUpload::make(ScreenShot::Ptr m_shot) { - setProgress(bytesReceived, bytesTotal); - emit progress(bytesReceived, bytesTotal); + auto up = makeShared(m_shot->m_file); + up->m_url = std::move(BuildConfig.IMGUR_BASE_URL + "upload.json"); + up->m_sink.reset(new Sink(m_shot)); + return up; } diff --git a/launcher/screenshots/ImgurUpload.h b/launcher/screenshots/ImgurUpload.h index e8a6d8d70..e99ba3a4a 100644 --- a/launcher/screenshots/ImgurUpload.h +++ b/launcher/screenshots/ImgurUpload.h @@ -35,31 +35,36 @@ #pragma once -#include "net/NetAction.h" +#include #include "Screenshot.h" +#include "net/NetRequest.h" -class ImgurUpload : public NetAction { -public: - using Ptr = shared_qobject_ptr; +class ImgurUpload : public Net::NetRequest { + public: + class Sink : public Net::Sink { + public: + Sink(ScreenShot::Ptr shot) : m_shot(shot){}; + virtual ~Sink() = default; - explicit ImgurUpload(ScreenShot::Ptr shot); - static Ptr make(ScreenShot::Ptr shot) { - return Ptr(new ImgurUpload(shot)); - } - void init() override {}; + public: + auto init(QNetworkRequest& request) -> Task::State override; + auto write(QByteArray& data) -> Task::State override; + auto abort() -> Task::State override; + auto finalize(QNetworkReply& reply) -> Task::State override; + auto hasLocalData() -> bool override { return false; } -protected -slots: - void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) override; - void downloadError(QNetworkReply::NetworkError error) override; - void downloadFinished() override; - void downloadReadyRead() override {} + private: + ScreenShot::Ptr m_shot; + QByteArray m_output; + }; + ImgurUpload(QFileInfo info) : m_fileInfo(info) {} + virtual ~ImgurUpload() = default; -public -slots: - void executeTask() override; + static NetRequest::Ptr make(ScreenShot::Ptr m_shot); -private: - ScreenShot::Ptr m_shot; - bool finished = true; + void init() override; + + private: + virtual QNetworkReply* getReply(QNetworkRequest&) override; + const QFileInfo m_fileInfo; }; diff --git a/launcher/ui/pages/instance/ScreenshotsPage.cpp b/launcher/ui/pages/instance/ScreenshotsPage.cpp index 352375941..128d79503 100644 --- a/launcher/ui/pages/instance/ScreenshotsPage.cpp +++ b/launcher/ui/pages/instance/ScreenshotsPage.cpp @@ -403,41 +403,37 @@ void ScreenshotsPage::on_actionUpload_triggered() QList uploaded; auto job = NetJob::Ptr(new NetJob("Screenshot Upload", APPLICATION->network())); - if(selection.size() < 2) - { + + ProgressDialog dialog(this); + dialog.setSkipButton(true, tr("Abort")); + + if (selection.size() < 2) { auto item = selection.at(0); auto info = m_model->fileInfo(item); auto screenshot = std::make_shared(info); job->addNetAction(ImgurUpload::make(screenshot)); m_uploadActive = true; - ProgressDialog dialog(this); - if(dialog.execWithTask(job.get()) != QDialog::Accepted) - { - CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), - tr("Unknown error"), QMessageBox::Warning)->exec(); - } - else - { + if (dialog.execWithTask(job.get()) != QDialog::Accepted) { + CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec(); + } else { auto link = screenshot->m_url; - QClipboard *clipboard = QApplication::clipboard(); + QClipboard* clipboard = QApplication::clipboard(); + qDebug() << "ImgurUpload link" << link; clipboard->setText(link); CustomMessageBox::selectable( - this, - tr("Upload finished"), - tr("The link to the uploaded screenshot has been placed in your clipboard.") - .arg(link), - QMessageBox::Information - )->exec(); + this, tr("Upload finished"), + tr("The link to the uploaded screenshot has been placed in your clipboard.").arg(link), + QMessageBox::Information) + ->exec(); } m_uploadActive = false; return; } - for (auto item : selection) - { + for (auto item : selection) { auto info = m_model->fileInfo(item); auto screenshot = std::make_shared(info); uploaded.push_back(screenshot); @@ -445,32 +441,23 @@ void ScreenshotsPage::on_actionUpload_triggered() } SequentialTask task; auto albumTask = NetJob::Ptr(new NetJob("Imgur Album Creation", APPLICATION->network())); - auto imgurAlbum = ImgurAlbumCreation::make(uploaded); + auto imgurResult = std::make_shared(); + auto imgurAlbum = ImgurAlbumCreation::make(imgurResult, uploaded); albumTask->addNetAction(imgurAlbum); task.addTask(job); task.addTask(albumTask); m_uploadActive = true; - ProgressDialog prog(this); - if (prog.execWithTask(&task) != QDialog::Accepted) - { - CustomMessageBox::selectable( - this, - tr("Failed to upload screenshots!"), - tr("Unknown error"), - QMessageBox::Warning - )->exec(); - } - else - { - auto link = QString("https://imgur.com/a/%1").arg(imgurAlbum->id()); - QClipboard *clipboard = QApplication::clipboard(); + if (dialog.execWithTask(&task) != QDialog::Accepted || imgurResult->id.isEmpty()) { + CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec(); + } else { + auto link = QString("https://imgur.com/a/%1").arg(imgurResult->id); + qDebug() << "ImgurUpload link" << link; + QClipboard* clipboard = QApplication::clipboard(); clipboard->setText(link); - CustomMessageBox::selectable( - this, - tr("Upload finished"), - tr("The link to the uploaded album has been placed in your clipboard.") .arg(link), - QMessageBox::Information - )->exec(); + CustomMessageBox::selectable(this, tr("Upload finished"), + tr("The link to the uploaded album has been placed in your clipboard.").arg(link), + QMessageBox::Information) + ->exec(); } m_uploadActive = false; } @@ -478,8 +465,7 @@ void ScreenshotsPage::on_actionUpload_triggered() void ScreenshotsPage::on_actionCopy_Image_triggered() { auto selection = ui->listView->selectionModel()->selectedRows(); - if(selection.size() < 1) - { + if (selection.size() < 1) { return; } From 997a3709d40ad66e586c5b5342e8aeb8fe485a32 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 12 Jul 2023 18:10:13 +0100 Subject: [PATCH 02/79] Custom environment variables UI and implementation Signed-off-by: TheKodeToad --- launcher/Application.cpp | 4 + launcher/CMakeLists.txt | 5 + launcher/minecraft/MinecraftInstance.cpp | 22 + .../resources/breeze_dark/breeze_dark.qrc | 1 + .../scalable/environment-variables.svg | 13 + .../resources/breeze_light/breeze_light.qrc | 1 + .../scalable/environment-variables.svg | 13 + launcher/resources/flat/flat.qrc | 1 + .../flat/scalable/custom-commands.svg | 87 +- .../flat/scalable/environment-variables.svg | 86 + launcher/resources/flat_white/flat_white.qrc | 1 + .../flat_white/scalable/custom-commands.svg | 87 +- .../scalable/environment-variables.svg | 86 + launcher/resources/multimc/multimc.qrc | 2 +- .../multimc/scalable/custom-commands.svg | 4615 +++++++++++++++-- .../scalable/environment-variables.svg | 346 ++ launcher/resources/pe_blue/pe_blue.qrc | 1 + .../scalable/environment-variables.svg | 345 ++ launcher/resources/pe_colored/pe_colored.qrc | 1 + .../scalable/environment-variables.svg | 347 ++ launcher/resources/pe_dark/pe_dark.qrc | 1 + .../scalable/environment-variables.svg | 345 ++ launcher/resources/pe_light/pe_light.qrc | 1 + .../scalable/environment-variables.svg | 345 ++ .../pages/global/EnvironmentVariablesPage.cpp | 64 + .../pages/global/EnvironmentVariablesPage.h | 42 + .../pages/instance/InstanceSettingsPage.cpp | 17 + .../ui/pages/instance/InstanceSettingsPage.ui | 25 +- launcher/ui/widgets/EnvironmentVariables.cpp | 138 + launcher/ui/widgets/EnvironmentVariables.h | 44 + launcher/ui/widgets/EnvironmentVariables.ui | 122 + 31 files changed, 6722 insertions(+), 486 deletions(-) create mode 100644 launcher/resources/breeze_dark/scalable/environment-variables.svg create mode 100644 launcher/resources/breeze_light/scalable/environment-variables.svg create mode 100644 launcher/resources/flat/scalable/environment-variables.svg create mode 100644 launcher/resources/flat_white/scalable/environment-variables.svg create mode 100644 launcher/resources/multimc/scalable/environment-variables.svg create mode 100644 launcher/resources/pe_blue/scalable/environment-variables.svg create mode 100644 launcher/resources/pe_colored/scalable/environment-variables.svg create mode 100644 launcher/resources/pe_dark/scalable/environment-variables.svg create mode 100644 launcher/resources/pe_light/scalable/environment-variables.svg create mode 100644 launcher/ui/pages/global/EnvironmentVariablesPage.cpp create mode 100644 launcher/ui/pages/global/EnvironmentVariablesPage.h create mode 100644 launcher/ui/widgets/EnvironmentVariables.cpp create mode 100644 launcher/ui/widgets/EnvironmentVariables.h create mode 100644 launcher/ui/widgets/EnvironmentVariables.ui diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 7858d7132..862e4256e 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -64,6 +64,7 @@ #include "ui/pages/global/AccountListPage.h" #include "ui/pages/global/APIPage.h" #include "ui/pages/global/CustomCommandsPage.h" +#include "ui/pages/global/EnvironmentVariablesPage.h" #include "ui/setupwizard/SetupWizard.h" #include "ui/setupwizard/LanguageWizardPage.h" @@ -701,6 +702,8 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_settings->registerSetting("CloseAfterLaunch", false); m_settings->registerSetting("QuitAfterGameStop", false); + m_settings->registerSetting("Env", QVariant(QMap())); + // Custom Microsoft Authentication Client ID m_settings->registerSetting("MSAClientIDOverride", ""); @@ -726,6 +729,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); + m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); m_globalSettingsProvider->addPage(); diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index af3bc28e3..8992b1e6c 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -812,6 +812,8 @@ SET(LAUNCHER_SOURCES ui/pages/global/AccountListPage.h ui/pages/global/CustomCommandsPage.cpp ui/pages/global/CustomCommandsPage.h + ui/pages/global/EnvironmentVariablesPage.cpp + ui/pages/global/EnvironmentVariablesPage.h ui/pages/global/ExternalToolsPage.cpp ui/pages/global/ExternalToolsPage.h ui/pages/global/JavaPage.cpp @@ -953,6 +955,8 @@ SET(LAUNCHER_SOURCES ui/widgets/Common.h ui/widgets/CustomCommands.cpp ui/widgets/CustomCommands.h + ui/widgets/EnvironmentVariables.cpp + ui/widgets/EnvironmentVariables.h ui/widgets/DropLabel.cpp ui/widgets/DropLabel.h ui/widgets/FocusLineEdit.cpp @@ -1044,6 +1048,7 @@ qt_wrap_ui(LAUNCHER_UI ui/pages/modplatform/technic/TechnicPage.ui ui/widgets/InstanceCardWidget.ui ui/widgets/CustomCommands.ui + ui/widgets/EnvironmentVariables.ui ui/widgets/InfoFrame.ui ui/widgets/ModFilterWidget.ui ui/widgets/SubTaskProgressBar.ui diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 4867cc7a3..6afc4e9a5 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -186,6 +186,10 @@ void MinecraftInstance::loadSpecificSettings() m_settings->registerOverride(global_settings->getSetting("CloseAfterLaunch"), miscellaneousOverride); m_settings->registerOverride(global_settings->getSetting("QuitAfterGameStop"), miscellaneousOverride); + m_settings->registerSetting("UseEnv", false); + m_settings->registerSetting("OverrideEnv", false); + m_settings->registerSetting("Env", QVariant(QMap())); + m_settings->set("InstanceType", "OneSix"); } @@ -526,6 +530,24 @@ QProcessEnvironment MinecraftInstance::createLaunchEnvironment() } #endif + // custom env + + auto insertEnv = [&env](QMap envMap) { + if (envMap.isEmpty()) + return; + + for (auto iter = envMap.begin(); iter != envMap.end(); iter++) + env.insert(iter.key(), iter.value().toString()); + }; + + bool useEnv = settings()->get("UseEnv").toBool(); + bool overrideEnv = useEnv && settings()->get("OverrideEnv").toBool(); + + if (!overrideEnv) + insertEnv(APPLICATION->settings()->get("Env").toMap()); + if (useEnv) + insertEnv(settings()->get("Env").toMap()); + return env; } diff --git a/launcher/resources/breeze_dark/breeze_dark.qrc b/launcher/resources/breeze_dark/breeze_dark.qrc index 320ca8171..61d82ec30 100644 --- a/launcher/resources/breeze_dark/breeze_dark.qrc +++ b/launcher/resources/breeze_dark/breeze_dark.qrc @@ -9,6 +9,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/discord.svg scalable/externaltools.svg scalable/help.svg diff --git a/launcher/resources/breeze_dark/scalable/environment-variables.svg b/launcher/resources/breeze_dark/scalable/environment-variables.svg new file mode 100644 index 000000000..308c4a239 --- /dev/null +++ b/launcher/resources/breeze_dark/scalable/environment-variables.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/launcher/resources/breeze_light/breeze_light.qrc b/launcher/resources/breeze_light/breeze_light.qrc index e88cd9a00..2211c7188 100644 --- a/launcher/resources/breeze_light/breeze_light.qrc +++ b/launcher/resources/breeze_light/breeze_light.qrc @@ -9,6 +9,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/discord.svg scalable/externaltools.svg scalable/help.svg diff --git a/launcher/resources/breeze_light/scalable/environment-variables.svg b/launcher/resources/breeze_light/scalable/environment-variables.svg new file mode 100644 index 000000000..f5d4acc3b --- /dev/null +++ b/launcher/resources/breeze_light/scalable/environment-variables.svg @@ -0,0 +1,13 @@ + + + + + + diff --git a/launcher/resources/flat/flat.qrc b/launcher/resources/flat/flat.qrc index 2fd5daefe..8876027da 100644 --- a/launcher/resources/flat/flat.qrc +++ b/launcher/resources/flat/flat.qrc @@ -11,6 +11,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/discord.svg scalable/externaltools.svg scalable/help.svg diff --git a/launcher/resources/flat/scalable/custom-commands.svg b/launcher/resources/flat/scalable/custom-commands.svg index a35634b16..f2e587843 100644 --- a/launcher/resources/flat/scalable/custom-commands.svg +++ b/launcher/resources/flat/scalable/custom-commands.svg @@ -1,86 +1 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - + diff --git a/launcher/resources/flat/scalable/environment-variables.svg b/launcher/resources/flat/scalable/environment-variables.svg new file mode 100644 index 000000000..a35634b16 --- /dev/null +++ b/launcher/resources/flat/scalable/environment-variables.svg @@ -0,0 +1,86 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/flat_white/flat_white.qrc b/launcher/resources/flat_white/flat_white.qrc index a1c940da0..83b178cbf 100644 --- a/launcher/resources/flat_white/flat_white.qrc +++ b/launcher/resources/flat_white/flat_white.qrc @@ -11,6 +11,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/discord.svg scalable/externaltools.svg scalable/help.svg diff --git a/launcher/resources/flat_white/scalable/custom-commands.svg b/launcher/resources/flat_white/scalable/custom-commands.svg index fe1cf9987..0ba459cff 100644 --- a/launcher/resources/flat_white/scalable/custom-commands.svg +++ b/launcher/resources/flat_white/scalable/custom-commands.svg @@ -1,86 +1 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - + diff --git a/launcher/resources/flat_white/scalable/environment-variables.svg b/launcher/resources/flat_white/scalable/environment-variables.svg new file mode 100644 index 000000000..fe1cf9987 --- /dev/null +++ b/launcher/resources/flat_white/scalable/environment-variables.svg @@ -0,0 +1,86 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/multimc.qrc b/launcher/resources/multimc/multimc.qrc index 2c00f28fa..88a7829f5 100644 --- a/launcher/resources/multimc/multimc.qrc +++ b/launcher/resources/multimc/multimc.qrc @@ -73,8 +73,8 @@ 64x64/screenshots.png scalable/screenshots.svg - scalable/custom-commands.svg + scalable/environment-variables.svg 16x16/cat.png diff --git a/launcher/resources/multimc/scalable/custom-commands.svg b/launcher/resources/multimc/scalable/custom-commands.svg index b7f1a149b..0d502bb1d 100644 --- a/launcher/resources/multimc/scalable/custom-commands.svg +++ b/launcher/resources/multimc/scalable/custom-commands.svg @@ -1,338 +1,4339 @@ + + width="128" + height="128" + id="svg2756" + sodipodi:version="0.32" + inkscape:version="0.45.1" + version="1.0" + sodipodi:docname="konsole.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape" + sodipodi:docbase="/home/david/sandbox"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + inkscape:zoom="4" + inkscape:cx="64" + inkscape:cy="73.608336" + inkscape:document-units="px" + inkscape:current-layer="layer1" + height="128px" + width="128px" + showgrid="true" + gridspacingy="4px" + gridspacingx="4px" + gridempspacing="0" + inkscape:window-width="971" + inkscape:window-height="648" + inkscape:window-x="46" + inkscape:window-y="45" /> + id="metadata2761"> image/svg+xml - + inkscape:label="Livello 1" + inkscape:groupmode="layer" + id="layer1"> + + + + + + + + + + + - - + x="12" + y="16" + width="104" + height="80" + id="rect30" /> - - - - - - - - - - - - - - - - - - - - - + id="g32" + transform="matrix(1.0851064,0,0,1.1142857,3.2340422,6.9714286)"> + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + id="g2644"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/environment-variables.svg b/launcher/resources/multimc/scalable/environment-variables.svg new file mode 100644 index 000000000..5e136b202 --- /dev/null +++ b/launcher/resources/multimc/scalable/environment-variables.svg @@ -0,0 +1,346 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_blue/pe_blue.qrc b/launcher/resources/pe_blue/pe_blue.qrc index da45ef9a1..717d3972e 100644 --- a/launcher/resources/pe_blue/pe_blue.qrc +++ b/launcher/resources/pe_blue/pe_blue.qrc @@ -10,6 +10,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/externaltools.svg scalable/help.svg scalable/instance-settings.svg diff --git a/launcher/resources/pe_blue/scalable/environment-variables.svg b/launcher/resources/pe_blue/scalable/environment-variables.svg new file mode 100644 index 000000000..61c63a4c5 --- /dev/null +++ b/launcher/resources/pe_blue/scalable/environment-variables.svg @@ -0,0 +1,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_colored/pe_colored.qrc b/launcher/resources/pe_colored/pe_colored.qrc index ba5bd44f9..023c81e74 100644 --- a/launcher/resources/pe_colored/pe_colored.qrc +++ b/launcher/resources/pe_colored/pe_colored.qrc @@ -10,6 +10,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/externaltools.svg scalable/help.svg scalable/instance-settings.svg diff --git a/launcher/resources/pe_colored/scalable/environment-variables.svg b/launcher/resources/pe_colored/scalable/environment-variables.svg new file mode 100644 index 000000000..c1aab6bca --- /dev/null +++ b/launcher/resources/pe_colored/scalable/environment-variables.svg @@ -0,0 +1,347 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_dark/pe_dark.qrc b/launcher/resources/pe_dark/pe_dark.qrc index 2bfec42cb..c97fb469c 100644 --- a/launcher/resources/pe_dark/pe_dark.qrc +++ b/launcher/resources/pe_dark/pe_dark.qrc @@ -10,6 +10,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/externaltools.svg scalable/help.svg scalable/instance-settings.svg diff --git a/launcher/resources/pe_dark/scalable/environment-variables.svg b/launcher/resources/pe_dark/scalable/environment-variables.svg new file mode 100644 index 000000000..46a3445f4 --- /dev/null +++ b/launcher/resources/pe_dark/scalable/environment-variables.svg @@ -0,0 +1,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_light/pe_light.qrc b/launcher/resources/pe_light/pe_light.qrc index 25d5da73b..b590dd2c6 100644 --- a/launcher/resources/pe_light/pe_light.qrc +++ b/launcher/resources/pe_light/pe_light.qrc @@ -10,6 +10,7 @@ scalable/copy.svg scalable/coremods.svg scalable/custom-commands.svg + scalable/environment-variables.svg scalable/externaltools.svg scalable/help.svg scalable/instance-settings.svg diff --git a/launcher/resources/pe_light/scalable/environment-variables.svg b/launcher/resources/pe_light/scalable/environment-variables.svg new file mode 100644 index 000000000..b8d562ffe --- /dev/null +++ b/launcher/resources/pe_light/scalable/environment-variables.svg @@ -0,0 +1,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/ui/pages/global/EnvironmentVariablesPage.cpp b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp new file mode 100644 index 000000000..2c3b716b8 --- /dev/null +++ b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad + * + * 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 . + */ + +#include +#include + +#include "EnvironmentVariablesPage.h" + +EnvironmentVariablesPage::EnvironmentVariablesPage(QWidget* parent) : QWidget(parent) +{ + auto verticalLayout = new QVBoxLayout(this); + verticalLayout->setContentsMargins(0, 0, 0, 0); + variables = new EnvironmentVariables(this); + variables->setContentsMargins(6, 6, 6, 6); + verticalLayout->addWidget(variables); + + variables->initialize(false, true, false, APPLICATION->settings()->get("Env").toMap()); +} + +QString EnvironmentVariablesPage::displayName() const +{ + return tr("Environment Variables"); +} + +QIcon EnvironmentVariablesPage::icon() const +{ + return APPLICATION->getThemedIcon("environment-variables"); +} + +QString EnvironmentVariablesPage::id() const +{ + return "environment-variables"; +} + +QString EnvironmentVariablesPage::helpPage() const +{ + return "Environment-variables"; +} + +bool EnvironmentVariablesPage::apply() +{ + APPLICATION->settings()->set("Env", variables->value()); + return true; +} + +void EnvironmentVariablesPage::retranslate() +{ + variables->retranslate(); +} diff --git a/launcher/ui/pages/global/EnvironmentVariablesPage.h b/launcher/ui/pages/global/EnvironmentVariablesPage.h new file mode 100644 index 000000000..6e80775ec --- /dev/null +++ b/launcher/ui/pages/global/EnvironmentVariablesPage.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad + * + * 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 . + */ + +#pragma once + +#include + +#include "ui/pages/BasePage.h" +#include "ui/widgets/EnvironmentVariables.h" + +class EnvironmentVariablesPage : public QWidget, public BasePage { + Q_OBJECT + + public: + explicit EnvironmentVariablesPage(QWidget* parent = nullptr); + + QString displayName() const override; + QIcon icon() const override; + QString id() const override; + QString helpPage() const override; + + bool apply() override; + void retranslate() override; + + private: + EnvironmentVariables* variables; +}; diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp index 943ff17f1..5144e973c 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -84,6 +84,9 @@ void InstanceSettingsPage::globalSettingsButtonClicked(bool) case 2: APPLICATION->ShowGlobalSettings(this, "custom-commands"); return; + case 3: + APPLICATION->ShowGlobalSettings(this, "environment-variables"); + return; default: APPLICATION->ShowGlobalSettings(this, "minecraft-settings"); return; @@ -217,6 +220,11 @@ void InstanceSettingsPage::applySettings() m_settings->reset("PostExitCommand"); } + // Environment Variables + m_settings->set("UseEnv", ui->environmentVariables->checked()); + m_settings->set("OverrideEnv", ui->environmentVariables->override()); + m_settings->set("Env", ui->environmentVariables->value()); + // Workarounds bool workarounds = ui->nativeWorkaroundsGroupBox->isChecked(); m_settings->set("OverrideNativeWorkarounds", workarounds); @@ -345,6 +353,14 @@ void InstanceSettingsPage::loadSettings() m_settings->get("PostExitCommand").toString() ); + // Environment variables + ui->environmentVariables->initialize( + true, + m_settings->get("UseEnv").toBool(), + m_settings->get("OverrideEnv").toBool(), + m_settings->get("Env").toMap() + ); + // Workarounds ui->nativeWorkaroundsGroupBox->setChecked(m_settings->get("OverrideNativeWorkarounds").toBool()); ui->useNativeGLFWCheck->setChecked(m_settings->get("UseNativeGLFW").toBool()); @@ -492,6 +508,7 @@ void InstanceSettingsPage::retranslate() { ui->retranslateUi(this); ui->customCommands->retranslate(); // TODO: why is this seperate from the others? + ui->environmentVariables->retranslate(); } void InstanceSettingsPage::updateThresholds() diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.ui b/launcher/ui/pages/instance/InstanceSettingsPage.ui index 8427965de..7adeb8785 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.ui +++ b/launcher/ui/pages/instance/InstanceSettingsPage.ui @@ -35,13 +35,10 @@ - - QTabWidget::Rounded - 0 - + Java @@ -246,7 +243,7 @@ - + Game windows @@ -406,7 +403,7 @@ - + Custom commands @@ -416,6 +413,16 @@ + + + Environment variables + + + + + + + Workarounds @@ -669,6 +676,12 @@
ui/widgets/CustomCommands.h
1 + + EnvironmentVariables + QWidget +
ui/widgets/EnvironmentVariables.h
+ 1 +
openGlobalJavaSettingsButton diff --git a/launcher/ui/widgets/EnvironmentVariables.cpp b/launcher/ui/widgets/EnvironmentVariables.cpp new file mode 100644 index 000000000..a409f64fc --- /dev/null +++ b/launcher/ui/widgets/EnvironmentVariables.cpp @@ -0,0 +1,138 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad + * + * 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 . + */ + +#include + +#include "Application.h" +#include "EnvironmentVariables.h" +#include "ui/dialogs/CustomMessageBox.h" +#include "ui_EnvironmentVariables.h" + +EnvironmentVariables::EnvironmentVariables(QWidget* parent) : QWidget(parent), ui(new Ui::EnvironmentVariables) +{ + ui->setupUi(this); + ui->list->installEventFilter(this); + + ui->list->sortItems(0, Qt::AscendingOrder); + ui->list->setSortingEnabled(true); + ui->list->header()->resizeSections(QHeaderView::Interactive); + ui->list->header()->resizeSection(0, 200); + + connect(ui->add, &QPushButton::clicked, this, [this] { + auto item = new QTreeWidgetItem(ui->list); + item->setText(0, "ENV_VAR"); + item->setText(1, "value"); + item->setFlags(item->flags() | Qt::ItemIsEditable); + ui->list->addTopLevelItem(item); + ui->list->selectionModel()->select(ui->list->model()->index(ui->list->indexOfTopLevelItem(item), 0), + QItemSelectionModel::ClearAndSelect | QItemSelectionModel::SelectionFlag::Rows); + ui->list->editItem(item); + }); + + connect(ui->remove, &QPushButton::clicked, this, [this] { + for (QTreeWidgetItem* item : ui->list->selectedItems()) + ui->list->takeTopLevelItem(ui->list->indexOfTopLevelItem(item)); + }); + + connect(ui->clear, &QPushButton::clicked, this, [this] { ui->list->clear(); }); + + connect(ui->globalOverride, &QCheckBox::clicked, this, [this](bool state) { + if (!state) + return; + + auto global = APPLICATION->settings()->get("Env").toMap(); + if (global.isEmpty()) + return; + + auto response = CustomMessageBox::selectable( + this, tr("Reset"), + tr("You have chosen to ignore global settings.\n\nWould you like to clear the current variables and copy " + "the global variables over?"), + QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) + ->exec(); + + if (response == QMessageBox::Yes) + initialize(true, checked(), override(), global); + }); +} + +EnvironmentVariables::~EnvironmentVariables() +{ + delete ui; +} + +void EnvironmentVariables::initialize(bool instance, bool checked, bool override, const QMap& value) +{ + // update widgets to settings + ui->groupBox->setCheckable(instance); + ui->groupBox->setChecked(checked); + ui->globalOverride->setVisible(instance); + ui->globalOverride->setChecked(override); + + // populate + ui->list->clear(); + for (auto iter = value.begin(); iter != value.end(); iter++) { + auto item = new QTreeWidgetItem(ui->list); + item->setText(0, iter.key()); + item->setText(1, iter.value().toString()); + item->setFlags(item->flags() | Qt::ItemIsEditable); + ui->list->addTopLevelItem(item); + } +} + +bool EnvironmentVariables::eventFilter(QObject* watched, QEvent* event) +{ + if (watched == ui->list && event->type() == QEvent::KeyPress) { + const QKeyEvent* keyEvent = (QKeyEvent*)event; + if (keyEvent->key() == Qt::Key_Delete) { + emit ui->remove->clicked(); + return true; + } + } + + return QObject::eventFilter(watched, event); +} + +void EnvironmentVariables::retranslate() +{ + ui->retranslateUi(this); +} + +bool EnvironmentVariables::checked() const +{ + if (!ui->groupBox->isCheckable()) + return true; + return ui->groupBox->isChecked(); +} + +bool EnvironmentVariables::override() const +{ + if (!ui->globalOverride->isVisible()) + return false; + return ui->globalOverride->isChecked(); +} + +QMap EnvironmentVariables::value() const +{ + QMap result; + QTreeWidgetItem* item = ui->list->topLevelItem(0); + for (int i = 1; item != nullptr; item = ui->list->topLevelItem(i++)) + result[item->text(0)] = item->text(1); + + return result; +} diff --git a/launcher/ui/widgets/EnvironmentVariables.h b/launcher/ui/widgets/EnvironmentVariables.h new file mode 100644 index 000000000..ba4329dd9 --- /dev/null +++ b/launcher/ui/widgets/EnvironmentVariables.h @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad + * + * 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 . + */ + +#pragma once + +#include +#include + +namespace Ui { +class EnvironmentVariables; +} + +class EnvironmentVariables : public QWidget { + Q_OBJECT + + public: + explicit EnvironmentVariables(QWidget* state = nullptr); + ~EnvironmentVariables() override; + void initialize(bool instance, bool checked, bool override, const QMap& value); + bool eventFilter(QObject* watched, QEvent* event) override; + + void retranslate(); + bool checked() const; + bool override() const; + QMap value() const; + + private: + Ui::EnvironmentVariables* ui; +}; diff --git a/launcher/ui/widgets/EnvironmentVariables.ui b/launcher/ui/widgets/EnvironmentVariables.ui new file mode 100644 index 000000000..895b40d01 --- /dev/null +++ b/launcher/ui/widgets/EnvironmentVariables.ui @@ -0,0 +1,122 @@ + + + EnvironmentVariables + + + + 0 + 0 + 565 + 410 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + &Environment Variables + + + true + + + + + + &Ignore global settings + + + + + + + true + + + QAbstractItemView::ExtendedSelection + + + false + + + false + + + true + + + false + + + + Name + + + + + Value + + + + + + + + + + &Add + + + + + + + &Remove + + + + + + + &Clear + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + From 9d0175b81ab702467cd5c707669c12b6bbcb913e Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 16 Jul 2023 17:46:00 +0300 Subject: [PATCH 03/79] Added welcome screen Signed-off-by: Trial97 --- launcher/ui/instanceview/InstanceView.cpp | 79 +++++++++++++++++------ 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index 1911dd59a..a1acf5875 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -35,32 +35,32 @@ #include "InstanceView.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "VisualGroup.h" #include "ui/themes/ThemeManager.h" -#include #include #include - -template bool listsIntersect(const QList &l1, const QList t2) +template +bool listsIntersect(const QList& l1, const QList t2) { - for (auto &item : l1) - { - if (t2.contains(item)) - { + for (auto& item : l1) { + if (t2.contains(item)) { return true; } } @@ -536,11 +536,50 @@ void InstanceView::paintEvent(QPaintEvent* event) #endif option.widget = this; + if (model()->rowCount() == 0) { + painter.save(); + const QString line1 = "Welcome!"; + const QString line2 = "Add an instance to get started."; + auto rect = this->viewport()->rect(); + auto font = option.font; + font.setPointSize(64); + painter.setFont(font); + auto fm = painter.fontMetrics(); + + if (rect.height() <= (fm.height() * 5) || rect.width() <= fm.horizontalAdvance(line2)) { + auto s = rect.height() / (5. * fm.height()); + auto sx = rect.width() * 1. / fm.horizontalAdvance(line2); + if (s >= sx) + s = sx; + auto ps = font.pointSize() * s; + if (ps <= 0) + ps = 1; + font.setPointSize(ps); + painter.setFont(font); + fm = painter.fontMetrics(); + } + // about icon + auto about = QIcon::fromTheme("about"); + QRect aboutRect(0, 0, fm.height() * .75, fm.height() * .75); + aboutRect.moveCenter(rect.center()); + aboutRect.moveTop(fm.height() * .75); + auto px = about.pixmap(about.actualSize(aboutRect.size())); + if (!px.isNull()) + painter.drawPixmap(aboutRect, px); + + // text + rect.setTop(rect.top() + fm.height() * 1.5); + painter.drawText(rect, Qt::AlignHCenter, line1); + rect.setTop(rect.top() + fm.height()); + painter.drawText(rect, Qt::AlignHCenter, line2); + painter.restore(); + return; + } + int wpWidth = viewport()->width(); option.rect.setWidth(wpWidth); - for (int i = 0; i < m_groups.size(); ++i) - { - VisualGroup *category = m_groups.at(i); + for (int i = 0; i < m_groups.size(); ++i) { + VisualGroup* category = m_groups.at(i); int y = category->verticalPosition(); y -= verticalOffset(); QRect backup = option.rect; From 7441974d9d22ad8596a52cf9fd70ae5e2e0e721a Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 16 Jul 2023 21:23:22 +0300 Subject: [PATCH 04/79] Removed icon Signed-off-by: Trial97 --- launcher/ui/instanceview/InstanceView.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index a1acf5875..9b0022229 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -542,7 +542,7 @@ void InstanceView::paintEvent(QPaintEvent* event) const QString line2 = "Add an instance to get started."; auto rect = this->viewport()->rect(); auto font = option.font; - font.setPointSize(64); + font.setPointSize(53); painter.setFont(font); auto fm = painter.fontMetrics(); @@ -558,14 +558,6 @@ void InstanceView::paintEvent(QPaintEvent* event) painter.setFont(font); fm = painter.fontMetrics(); } - // about icon - auto about = QIcon::fromTheme("about"); - QRect aboutRect(0, 0, fm.height() * .75, fm.height() * .75); - aboutRect.moveCenter(rect.center()); - aboutRect.moveTop(fm.height() * .75); - auto px = about.pixmap(about.actualSize(aboutRect.size())); - if (!px.isNull()) - painter.drawPixmap(aboutRect, px); // text rect.setTop(rect.top() + fm.height() * 1.5); From f5891940e0d8b52b2250b3e5b80532c71c39c7e8 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 17 Jul 2023 17:22:35 +0300 Subject: [PATCH 05/79] translate strings Signed-off-by: Trial97 --- launcher/ui/instanceview/InstanceView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index 9b0022229..025382cb7 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -538,8 +538,8 @@ void InstanceView::paintEvent(QPaintEvent* event) if (model()->rowCount() == 0) { painter.save(); - const QString line1 = "Welcome!"; - const QString line2 = "Add an instance to get started."; + const QString line1 = tr("Welcome!"); + const QString line2 = tr("Add an instance to get started."); auto rect = this->viewport()->rect(); auto font = option.font; font.setPointSize(53); From 72de2d5254babb209b478ed5e9d7c4e1019d7459 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sat, 5 Aug 2023 21:08:16 +0300 Subject: [PATCH 06/79] Added missing header Signed-off-by: Trial97 --- launcher/meta/BaseEntity.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/launcher/meta/BaseEntity.cpp b/launcher/meta/BaseEntity.cpp index 38e7f600d..18686acf6 100644 --- a/launcher/meta/BaseEntity.cpp +++ b/launcher/meta/BaseEntity.cpp @@ -15,6 +15,7 @@ #include "BaseEntity.h" +#include "Json.h" #include "net/ApiDownload.h" #include "net/HttpMetaCache.h" #include "net/NetJob.h" From f7e8ec1855f26052420694f873ee7e3c167f7545 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sat, 5 Aug 2023 21:17:38 +0300 Subject: [PATCH 07/79] format files Signed-off-by: Trial97 --- launcher/modplatform/flame/FlameAPI.cpp | 6 +++--- .../modplatform/modrinth/ModrinthInstanceCreationTask.cpp | 2 +- launcher/modplatform/technic/SolderPackInstallTask.cpp | 2 +- launcher/ui/pages/modplatform/flame/FlamePage.cpp | 3 ++- launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp | 2 +- launcher/ui/widgets/VariableSizedImageObject.cpp | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/launcher/modplatform/flame/FlameAPI.cpp b/launcher/modplatform/flame/FlameAPI.cpp index 7231b4664..73ed10112 100644 --- a/launcher/modplatform/flame/FlameAPI.cpp +++ b/launcher/modplatform/flame/FlameAPI.cpp @@ -8,9 +8,9 @@ #include "Application.h" #include "BuildConfig.h" #include "Json.h" +#include "net/ApiDownload.h" #include "net/ApiUpload.h" #include "net/NetJob.h" -#include "net/ApiDownload.h" #include "net/Upload.h" Task::Ptr FlameAPI::matchFingerprints(const QList& fingerprints, std::shared_ptr response) @@ -75,8 +75,8 @@ auto FlameAPI::getModDescription(int modId) -> QString auto netJob = makeShared(QString("Flame::ModDescription"), APPLICATION->network()); auto response = std::make_shared(); - netJob->addNetAction( - Net::ApiDownload::makeByteArray(QString("https://api.curseforge.com/v1/mods/%1/description").arg(QString::number(modId)), response)); + netJob->addNetAction(Net::ApiDownload::makeByteArray( + QString("https://api.curseforge.com/v1/mods/%1/description").arg(QString::number(modId)), response)); QObject::connect(netJob.get(), &NetJob::succeeded, [&netJob, response, &description] { QJsonParseError parse_error{}; diff --git a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp index e0873ce7e..cdbbd42d0 100644 --- a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp +++ b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp @@ -11,8 +11,8 @@ #include "net/ChecksumValidator.h" -#include "net/NetJob.h" #include "net/ApiDownload.h" +#include "net/NetJob.h" #include "settings/INISettingsObject.h" #include "ui/dialogs/CustomMessageBox.h" diff --git a/launcher/modplatform/technic/SolderPackInstallTask.cpp b/launcher/modplatform/technic/SolderPackInstallTask.cpp index b24604983..c162d6253 100644 --- a/launcher/modplatform/technic/SolderPackInstallTask.cpp +++ b/launcher/modplatform/technic/SolderPackInstallTask.cpp @@ -42,8 +42,8 @@ #include "SolderPackManifest.h" #include "TechnicPackProcessor.h" -#include "net/ChecksumValidator.h" #include "net/ApiDownload.h" +#include "net/ChecksumValidator.h" Technic::SolderPackInstallTask::SolderPackInstallTask(shared_qobject_ptr network, const QUrl& solderUrl, diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.cpp b/launcher/ui/pages/modplatform/flame/FlamePage.cpp index a87ff8668..9f0e7085c 100644 --- a/launcher/ui/pages/modplatform/flame/FlamePage.cpp +++ b/launcher/ui/pages/modplatform/flame/FlamePage.cpp @@ -134,7 +134,8 @@ void FlamePage::onSelectionChanged(QModelIndex curr, QModelIndex prev) auto netJob = new NetJob(QString("Flame::PackVersions(%1)").arg(current.name), APPLICATION->network()); auto response = std::make_shared(); int addonId = current.addonId; - netJob->addNetAction(Net::ApiDownload::makeByteArray(QString("https://api.curseforge.com/v1/mods/%1/files").arg(addonId), response)); + netJob->addNetAction( + Net::ApiDownload::makeByteArray(QString("https://api.curseforge.com/v1/mods/%1/files").arg(addonId), response)); QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId, curr] { if (addonId != current.addonId) { diff --git a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp index 176728ee5..f600e5a78 100644 --- a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp +++ b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp @@ -35,9 +35,9 @@ #include "ListModel.h" #include "Application.h" +#include "net/ApiDownload.h" #include "net/HttpMetaCache.h" #include "net/NetJob.h" -#include "net/ApiDownload.h" #include #include "StringUtils.h" diff --git a/launcher/ui/widgets/VariableSizedImageObject.cpp b/launcher/ui/widgets/VariableSizedImageObject.cpp index 51f2966b1..f655fc38d 100644 --- a/launcher/ui/widgets/VariableSizedImageObject.cpp +++ b/launcher/ui/widgets/VariableSizedImageObject.cpp @@ -25,8 +25,8 @@ #include "Application.h" -#include "net/NetJob.h" #include "net/ApiDownload.h" +#include "net/NetJob.h" enum FormatProperties { ImageData = QTextFormat::UserProperty + 1 }; From e2d77f21bab3354a75e68df4c4a124984dfd3fa1 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 11 Aug 2023 00:02:27 +0100 Subject: [PATCH 08/79] =?UTF-8?q?More=20system=20properties=20because=20ye?= =?UTF-8?q?s!!=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: TheKodeToad --- launcher/BaseInstance.cpp | 2 +- launcher/minecraft/MinecraftInstance.cpp | 6 ++++++ .../org/prismlauncher/EntryPoint.java | 20 ++++++++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/launcher/BaseInstance.cpp b/launcher/BaseInstance.cpp index 70c6da6b3..c48710003 100644 --- a/launcher/BaseInstance.cpp +++ b/launcher/BaseInstance.cpp @@ -385,7 +385,7 @@ QString BaseInstance::name() const QString BaseInstance::windowTitle() const { - return BuildConfig.LAUNCHER_DISPLAYNAME + ": " + name().replace(QRegularExpression("\\s+"), " "); + return BuildConfig.LAUNCHER_DISPLAYNAME + ": " + name(); } // FIXME: why is this here? move it to MinecraftInstance!!! diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 305bff67b..f9b0d05ff 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -634,6 +634,12 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS launchScript += "windowParams " + windowParams + "\n"; } + // instance info + { + launchScript += "instanceName " + name() + "\n"; + launchScript += "instanceIconKey " + iconKey() + "\n"; + } + // legacy auth if (session) { launchScript += "userName " + session->player_name + "\n"; diff --git a/libraries/launcher/org/prismlauncher/EntryPoint.java b/libraries/launcher/org/prismlauncher/EntryPoint.java index 4b59c1da6..4fc57c8e5 100644 --- a/libraries/launcher/org/prismlauncher/EntryPoint.java +++ b/libraries/launcher/org/prismlauncher/EntryPoint.java @@ -105,11 +105,25 @@ public final class EntryPoint { return ExitCode.ABORT; } + // populate properties to provide mods with more info + String name = params.getString("instanceName", ""); + String iconKey = params.getString("instanceIconKey", "default"); + + System.setProperty("org.prismlauncher.instance.name", name); + System.setProperty("org.prismlauncher.instance.icon.id", iconKey); + System.setProperty("org.prismlauncher.instance.icon.path", "icon.png"); + + // set multimc properties for compatibility + System.setProperty("multimc.instance.title", name); + System.setProperty("multimc.instance.icon", iconKey); + + // launch the game + String launcherType = params.getString("launcher"); + try { Launcher launcher; - String type = params.getString("launcher"); - switch (type) { + switch (launcherType) { case "standard": launcher = new StandardLauncher(params); break; @@ -119,7 +133,7 @@ public final class EntryPoint { break; default: - throw new IllegalArgumentException("Invalid launcher type: " + type); + throw new IllegalArgumentException("Invalid launcher type: " + launcherType); } launcher.launch(); From f6d8c9659cefd133ec0234fb5a72207088f542dd Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 11 Aug 2023 00:37:27 +0100 Subject: [PATCH 09/79] Rework Signed-off-by: TheKodeToad --- launcher/minecraft/MinecraftInstance.cpp | 5 ++- .../org/prismlauncher/EntryPoint.java | 39 +++++++++++++------ .../launcher/impl/AbstractLauncher.java | 2 +- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index f9b0d05ff..f31fc4001 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -626,7 +626,7 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS { QString windowParams; if (settings()->get("LaunchMaximized").toBool()) - windowParams = "max"; + windowParams = "maximized"; else windowParams = QString("%1x%2").arg(settings()->get("MinecraftWinWidth").toInt()).arg(settings()->get("MinecraftWinHeight").toInt()); @@ -637,7 +637,8 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS // instance info { launchScript += "instanceName " + name() + "\n"; - launchScript += "instanceIconKey " + iconKey() + "\n"; + launchScript += "instanceIconKey " + name() + "\n"; + launchScript += "instanceIconPath icon.png\n"; // we already save a copy here } // legacy auth diff --git a/libraries/launcher/org/prismlauncher/EntryPoint.java b/libraries/launcher/org/prismlauncher/EntryPoint.java index 4fc57c8e5..9a8a7ee1d 100644 --- a/libraries/launcher/org/prismlauncher/EntryPoint.java +++ b/libraries/launcher/org/prismlauncher/EntryPoint.java @@ -105,19 +105,8 @@ public final class EntryPoint { return ExitCode.ABORT; } - // populate properties to provide mods with more info - String name = params.getString("instanceName", ""); - String iconKey = params.getString("instanceIconKey", "default"); + setProperties(params); - System.setProperty("org.prismlauncher.instance.name", name); - System.setProperty("org.prismlauncher.instance.icon.id", iconKey); - System.setProperty("org.prismlauncher.instance.icon.path", "icon.png"); - - // set multimc properties for compatibility - System.setProperty("multimc.instance.title", name); - System.setProperty("multimc.instance.icon", iconKey); - - // launch the game String launcherType = params.getString("launcher"); try { @@ -150,6 +139,32 @@ public final class EntryPoint { } } + private static void setProperties(Parameters params) { + String name = params.getString("instanceName", null); + String iconId = params.getString("instanceIconKey", null); + String iconPath = params.getString("instanceIconPath", null); + String windowTitle = params.getString("windowTitle", null); + String windowDimensions = params.getString("windowParams", null); + + // set useful properties for mods + if (name != null) + System.setProperty("org.prismlauncher.instance.name", name); + if (iconId != null) + System.setProperty("org.prismlauncher.instance.icon.id", iconId); + if (iconPath != null) + System.setProperty("org.prismlauncher.instance.icon.path", iconPath); + if (windowTitle != null) + System.setProperty("org.prismlauncher.window.title", windowTitle); + if (windowDimensions != null) + System.setProperty("org.prismlauncher.window.dimensions", windowDimensions); + + // set multimc properties for compatibility + if (name != null) + System.setProperty("multimc.instance.title", name); + if (iconId != null) + System.setProperty("multimc.instance.icon", iconId); + } + private static PreLaunchAction parseLine(String input, Parameters params) throws ParseException { switch (input) { case "": diff --git a/libraries/launcher/org/prismlauncher/launcher/impl/AbstractLauncher.java b/libraries/launcher/org/prismlauncher/launcher/impl/AbstractLauncher.java index 761837041..de28a0401 100644 --- a/libraries/launcher/org/prismlauncher/launcher/impl/AbstractLauncher.java +++ b/libraries/launcher/org/prismlauncher/launcher/impl/AbstractLauncher.java @@ -83,7 +83,7 @@ public abstract class AbstractLauncher implements Launcher { String windowParams = params.getString("windowParams", null); - if ("max".equals(windowParams) || windowParams == null) { + if ("maximized".equals(windowParams) || windowParams == null) { maximize = windowParams != null; width = DEFAULT_WINDOW_WIDTH; From 6d070e8607cb7bd48c06dfac7e613b4805bed7a6 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 12 Aug 2023 21:50:02 +0100 Subject: [PATCH 10/79] "Format" Signed-off-by: TheKodeToad --- launcher/minecraft/MinecraftInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index f31fc4001..abdc4ea39 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -638,7 +638,7 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS { launchScript += "instanceName " + name() + "\n"; launchScript += "instanceIconKey " + name() + "\n"; - launchScript += "instanceIconPath icon.png\n"; // we already save a copy here + launchScript += "instanceIconPath icon.png\n"; // we already save a copy here } // legacy auth From fecc1e087aefd276a18d7941d123f1f261a6d0d2 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 18 Aug 2023 13:35:50 +0300 Subject: [PATCH 11/79] Add Trial97 to contribuitors list Signed-off-by: Trial97 --- launcher/ui/dialogs/AboutDialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/launcher/ui/dialogs/AboutDialog.cpp b/launcher/ui/dialogs/AboutDialog.cpp index 3c6f6ef16..f5eaff7a1 100644 --- a/launcher/ui/dialogs/AboutDialog.cpp +++ b/launcher/ui/dialogs/AboutDialog.cpp @@ -85,6 +85,7 @@ QString getCreditsHtml() stream << QString("

TayouVR %1

\n").arg(getGitHub("TayouVR")); stream << QString("

TheKodeToad %1

\n").arg(getGitHub("TheKodeToad")); stream << QString("

getchoo %1

\n").arg(getGitHub("getchoo")); + stream << QString("

Alexandru Tripon (Trial97) %1

\n").arg(getGitHub("Trial97")); stream << "
\n"; // TODO: possibly retrieve from git history at build time? From 79652799bd88299f1e1bdb1b16449fae56c59913 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 27 Aug 2023 21:30:46 +0300 Subject: [PATCH 12/79] Made text smaller Signed-off-by: Trial97 --- launcher/ui/instanceview/InstanceView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index 11402e58f..7530fdfba 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -482,10 +482,10 @@ void InstanceView::paintEvent([[maybe_unused]] QPaintEvent* event) if (model()->rowCount() == 0) { painter.save(); const QString line1 = tr("Welcome!"); - const QString line2 = tr("Add an instance to get started."); + const QString line2 = tr("Click \"Add Instance\" to get started."); auto rect = this->viewport()->rect(); auto font = option.font; - font.setPointSize(53); + font.setPointSize(37); painter.setFont(font); auto fm = painter.fontMetrics(); From 211865a1e1098245228aea75ee70d7e7b60ebd05 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 28 Aug 2023 13:31:19 +0300 Subject: [PATCH 13/79] handle gracefully the upload abort Signed-off-by: Trial97 --- .../ui/pages/instance/ScreenshotsPage.cpp | 48 +++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/launcher/ui/pages/instance/ScreenshotsPage.cpp b/launcher/ui/pages/instance/ScreenshotsPage.cpp index da56112c1..25f978cea 100644 --- a/launcher/ui/pages/instance/ScreenshotsPage.cpp +++ b/launcher/ui/pages/instance/ScreenshotsPage.cpp @@ -393,11 +393,18 @@ void ScreenshotsPage::on_actionUpload_triggered() auto screenshot = std::make_shared(info); job->addNetAction(ImgurUpload::make(screenshot)); + connect(job.get(), &Task::failed, [this](QString reason) { + CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), reason, QMessageBox::Critical)->show(); + }); + connect(job.get(), &Task::aborted, [this] { + CustomMessageBox::selectable(this, tr("Screenshots upload aborted"), tr("The task has been aborted by the user."), + QMessageBox::Information) + ->show(); + }); + m_uploadActive = true; - if (dialog.execWithTask(job.get()) != QDialog::Accepted) { - CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec(); - } else { + if (dialog.execWithTask(job.get()) == QDialog::Accepted) { auto link = screenshot->m_url; QClipboard* clipboard = QApplication::clipboard(); qDebug() << "ImgurUpload link" << link; @@ -426,18 +433,31 @@ void ScreenshotsPage::on_actionUpload_triggered() albumTask->addNetAction(imgurAlbum); task.addTask(job); task.addTask(albumTask); - m_uploadActive = true; - if (dialog.execWithTask(&task) != QDialog::Accepted || imgurResult->id.isEmpty()) { - CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec(); - } else { - auto link = QString("https://imgur.com/a/%1").arg(imgurResult->id); - qDebug() << "ImgurUpload link" << link; - QClipboard* clipboard = QApplication::clipboard(); - clipboard->setText(link); - CustomMessageBox::selectable(this, tr("Upload finished"), - tr("The link to the uploaded album has been placed in your clipboard.").arg(link), + + connect(&task, &Task::failed, [this](QString reason) { + CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), reason, QMessageBox::Critical)->show(); + }); + connect(&task, &Task::aborted, [this] { + CustomMessageBox::selectable(this, tr("Screenshots upload aborted"), tr("The task has been aborted by the user."), QMessageBox::Information) - ->exec(); + ->show(); + }); + + m_uploadActive = true; + if (dialog.execWithTask(&task) == QDialog::Accepted) { + if (imgurResult->id.isEmpty()) { + CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec(); + } else { + auto link = QString("https://imgur.com/a/%1").arg(imgurResult->id); + qDebug() << "ImgurUpload link" << link; + QClipboard* clipboard = QApplication::clipboard(); + clipboard->setText(link); + CustomMessageBox::selectable( + this, tr("Upload finished"), + tr("The link to the uploaded album has been placed in your clipboard.").arg(link), + QMessageBox::Information) + ->exec(); + } } m_uploadActive = false; } From 4f1ee854249f62c36dd9e8e1d9fbbc0b20bc09ec Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 6 Oct 2023 00:21:37 +0300 Subject: [PATCH 14/79] check for minecraft java runtime Signed-off-by: Trial97 --- launcher/java/JavaUtils.cpp | 43 +++++++++++++++++++++++++++++++++++++ launcher/java/JavaUtils.h | 1 + 2 files changed, 44 insertions(+) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index cca1ed6d4..9f682e086 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -335,6 +335,7 @@ QList JavaUtils::FindJavaPaths() } } + javas.append(getMinecraftJavaBundle()); candidates = addJavasFromEnv(candidates); candidates.removeDuplicates(); return candidates; @@ -360,6 +361,7 @@ QList JavaUtils::FindJavaPaths() javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Home/bin/java"); javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Commands/java"); } + javas.append(getMinecraftJavaBundle()); javas = addJavasFromEnv(javas); javas.removeDuplicates(); return javas; @@ -411,6 +413,7 @@ QList JavaUtils::FindJavaPaths() // javas downloaded by sdkman scanJavaDirs(FS::PathCombine(home, ".sdkman/candidates/java")); + javas.append(getMinecraftJavaBundle()); javas = addJavasFromEnv(javas); javas.removeDuplicates(); return javas; @@ -423,6 +426,7 @@ QList JavaUtils::FindJavaPaths() QList javas; javas.append(this->GetDefaultJava()->path); + javas.append(getMinecraftJavaBundle()); return addJavasFromEnv(javas); } #endif @@ -431,3 +435,42 @@ QString JavaUtils::getJavaCheckPath() { return APPLICATION->getJarPath("JavaCheck.jar"); } + +QStringList getMinecraftJavaBundle() +{ + QString partialPath; + QString executable = "java"; +#if defined(Q_OS_OSX) + partialPath = FS::PathCombine(QDir::homePath(), "Library/Application Support"); +#elif defined(Q_OS_WIN32) + partialPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", ""); + executable += "w.exe"; +#else + partialPath = QDir::homePath(); +#endif + auto minecraftPath = FS::PathCombine(partialPath, ".minecraft", "runtime"); + QStringList javas; + QStringList processpaths{ minecraftPath }; + + while (!processpaths.isEmpty()) { + auto dirPath = processpaths.takeFirst(); + QDir dir(dirPath); + if (!dir.exists()) + continue; + auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + auto binFound = false; + for (auto& entry : entries) { + if (entry.baseName() == "bin") { + javas.append(FS::PathCombine(entry.canonicalFilePath(), executable)); + binFound = true; + break; + } + } + if (!binFound) { + for (auto& entry : entries) { + processpaths << entry.canonicalFilePath(); + } + } + } + return javas; +} diff --git a/launcher/java/JavaUtils.h b/launcher/java/JavaUtils.h index 616179706..2fb03af7a 100644 --- a/launcher/java/JavaUtils.h +++ b/launcher/java/JavaUtils.h @@ -26,6 +26,7 @@ QString stripVariableEntries(QString name, QString target, QString remove); QProcessEnvironment CleanEnviroment(); +QStringList getMinecraftJavaBundle(); class JavaUtils : public QObject { Q_OBJECT From 82461b1113b01a4305046b5da69dbf60e885f756 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 6 Oct 2023 08:51:45 +0300 Subject: [PATCH 15/79] rename for windows Signed-off-by: Trial97 --- launcher/java/JavaUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index 9f682e086..10bbb1f1b 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -335,7 +335,7 @@ QList JavaUtils::FindJavaPaths() } } - javas.append(getMinecraftJavaBundle()); + candidates.append(getMinecraftJavaBundle()); candidates = addJavasFromEnv(candidates); candidates.removeDuplicates(); return candidates; From 8d0a53273f6fbd75c563b184f5bc326adfaf02d2 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 6 Oct 2023 18:42:54 +0300 Subject: [PATCH 16/79] Add no_color env variable Signed-off-by: Trial97 --- launcher/minecraft/MinecraftInstance.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index f9833b972..b536951a8 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -536,6 +536,7 @@ QMap MinecraftInstance::getVariables() out.insert("INST_MC_DIR", QDir::toNativeSeparators(QDir(gameRoot()).absolutePath())); out.insert("INST_JAVA", settings()->get("JavaPath").toString()); out.insert("INST_JAVA_ARGS", javaArguments().join(' ')); + out.insert("NO_COLOR", "1"); return out; } From dc74ea73825e7997538bc2aa381b284260a40551 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 6 Oct 2023 19:27:26 +0300 Subject: [PATCH 17/79] fixed wrong account selection Signed-off-by: Trial97 --- launcher/LaunchController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index 21a146062..9fb385777 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -106,7 +106,7 @@ void LaunchController::decideAccount() // Select the account to use. If the instance has a specific account set, that will be used. Otherwise, the default account will be used auto instanceAccountId = m_instance->settings()->get("InstanceAccountId").toString(); auto instanceAccountIndex = accounts->findAccountByProfileId(instanceAccountId); - if (instanceAccountIndex == -1) { + if (instanceAccountIndex == -1 || instanceAccountId.isEmpty()) { m_accountToUse = accounts->defaultAccount(); } else { m_accountToUse = accounts->at(instanceAccountIndex); From e66c3b94199fe3fe0d7fd1a29c26858f01cb3fc0 Mon Sep 17 00:00:00 2001 From: Hazel Date: Wed, 11 Oct 2023 23:19:14 +0200 Subject: [PATCH 18/79] Add game category to generated Linux shortcuts Signed-off-by: Hazel --- launcher/FileSystem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index defb2cb9e..00a6ee539 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -872,6 +872,8 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri << "\n"; stream << "Type=Application" << "\n"; + stream << "Categories=Game" + << "\n"; stream << "Exec=\"" << target.toLocal8Bit() << "\"" << argstring.toLocal8Bit() << "\n"; stream << "Name=" << name.toLocal8Bit() << "\n"; if (!icon.isEmpty()) { From d348f20dd994c7c60510e33d9ec0496d961f45d1 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Tue, 17 Oct 2023 10:00:17 +0200 Subject: [PATCH 19/79] fix: allow loading themes with missing resources folder Signed-off-by: Sefa Eyeoglu --- launcher/ui/themes/CustomTheme.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/launcher/ui/themes/CustomTheme.cpp b/launcher/ui/themes/CustomTheme.cpp index 29ecf6254..4859983c6 100644 --- a/launcher/ui/themes/CustomTheme.cpp +++ b/launcher/ui/themes/CustomTheme.cpp @@ -165,11 +165,15 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QFileInfo& fileInfo, bool isManifest QString path = FS::PathCombine("themes", m_id); QString pathResources = FS::PathCombine("themes", m_id, "resources"); - if (!FS::ensureFolderPathExists(path) || !FS::ensureFolderPathExists(pathResources)) { - themeWarningLog() << "couldn't create folder for theme!"; + if (!FS::ensureFolderPathExists(path)) { + themeWarningLog() << "Theme directory for" << m_id << "could not be created. This theme might be invalid"; return; } + if (!FS::ensureFolderPathExists(pathResources)) { + themeWarningLog() << "Resources directory for" << m_id << "could not be created"; + } + auto themeFilePath = FS::PathCombine(path, themeFile); bool jsonDataIncomplete = false; @@ -230,7 +234,11 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QFileInfo& fileInfo, bool isManifest QStringList CustomTheme::searchPaths() { - return { FS::PathCombine("themes", m_id, "resources") }; + QString pathResources = FS::PathCombine("themes", m_id, "resources"); + if (QFileInfo::exists(pathResources)) + return { pathResources }; + + return {}; } QString CustomTheme::id() From 069bc887f1f74b9ea29130d33042bafc82d97f57 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 17 Oct 2023 19:05:05 -0400 Subject: [PATCH 20/79] fix: don't always build updater on platforms besides mac Signed-off-by: seth --- CMakeLists.txt | 5 +++++ launcher/CMakeLists.txt | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be443fe31..faeb1c44e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,6 +347,11 @@ add_subdirectory(program_info) ####################################### Install layout ####################################### set(Launcher_ENABLE_UPDATER NO) +set(Launcher_BUILD_UPDATER NO) + +if (NOT APPLE AND (NOT Launcher_UPDATER_GITHUB_REPO STREQUAL "" AND NOT Launcher_BUILD_ARTIFACT STREQUAL "")) + set(Launcher_BUILD_UPDATER YES) +endif() if(NOT (UNIX AND APPLE)) # Install "portable.txt" if selected component is "portable" diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index d15dc85de..19b837a2f 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -1306,7 +1306,7 @@ install(TARGETS ${Launcher_Name} FRAMEWORK DESTINATION ${FRAMEWORK_DEST_DIR} COMPONENT Runtime ) -if(NOT APPLE OR (DEFINED Launcher_BUILD_UPDATER AND Launcher_BUILD_UPDATER)) +if(Launcher_BUILD_UPDATER) # Updater add_library(prism_updater_logic STATIC ${PRISMUPDATER_SOURCES} ${TASKS_SOURCES} ${PRISMUPDATER_UI}) target_include_directories(prism_updater_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) From 1f2483c39ee980f317aa8a4bcc5ccebe3a02045f Mon Sep 17 00:00:00 2001 From: Indrale Dnyaneshwar <118615488+Dnyanu76@users.noreply.github.com> Date: Fri, 20 Oct 2023 00:31:47 +0530 Subject: [PATCH 21/79] Remove typo Signed-off-by: Indrale Dnyaneshwar <118615488+Dnyanu76@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 093bc94da..61bf4c20b 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ For **Arch**, **Debian**, **Fedora**, **OpenSUSE (Tumbleweed)** and **Gentoo**, [![prismlauncher-git](https://img.shields.io/badge/aur-prismlauncher--git-1793D1?label=AUR&logo=archlinux&logoColor=white)](https://aur.archlinux.org/packages/prismlauncher-git) [![prismlauncher-git](https://img.shields.io/badge/aur-prismlauncher--qt5--git-1793D1?label=AUR&logo=archlinux&logoColor=white)](https://aur.archlinux.org/packages/prismlauncher-qt5-git) [![prismlauncher-git](https://img.shields.io/badge/mpr-prismlauncher--git-A80030?label=MPR&logo=debian&logoColor=white)](https://mpr.makedeb.org/packages/prismlauncher-git)
[![prismlauncher-nightly](https://img.shields.io/badge/copr-prismlauncher--nightly-51A2DA?label=COPR&logo=fedora&logoColor=white)](https://copr.fedorainfracloud.org/coprs/g3tchoo/prismlauncher/) [![prismlauncher-nightly](https://img.shields.io/badge/OBS-prismlauncher--nightly-3AB6A9?logo=opensuse&logoColor=white)](https://build.opensuse.org/project/show/home:getchoo) [![prismlauncher-9999](https://img.shields.io/badge/gentoo-prismlauncher--9999-4D4270?label=Gentoo&logo=gentoo&logoColor=white)](https://packages.gentoo.org/packages/games-action/prismlauncher) -These packages are also availiable to all the distributions based on the ones mentioned above. +These packages are also available to all the distributions based on the ones mentioned above. ## Community & Support From e9fd02baca57db1af85dd4f8f36a4c0fed2de8ff Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Fri, 20 Oct 2023 13:12:16 +0100 Subject: [PATCH 22/79] Fix code style Signed-off-by: TheKodeToad --- launcher/minecraft/MinecraftInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index dd4a56596..cc33c05af 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -187,7 +187,7 @@ void MinecraftInstance::loadSpecificSettings() // Legacy-related options auto legacySettings = m_settings->registerSetting("OverrideLegacySettings", false); m_settings->registerOverride(global_settings->getSetting("OnlineFixes"), legacySettings); - + m_settings->registerSetting("UseEnv", false); m_settings->registerSetting("OverrideEnv", false); m_settings->registerSetting("Env", QVariant(QMap())); From 80723eeca174afbbb5af31bf422fe7b2a8e8cad3 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 20 Oct 2023 16:41:32 +0300 Subject: [PATCH 23/79] Fixed FTBApp import icon Signed-off-by: Trial97 --- launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp index 43ff1c0fe..d46f16b4d 100644 --- a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp +++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp @@ -90,7 +90,7 @@ void ImportFTBPage::suggestCurrent() } dialog->setSuggestedPack(selected.name, new PackInstallTask(selected)); - QString editedLogoName = QString("ftb_%1_%2,jpg").arg(selected.name, selected.id); + QString editedLogoName = QString("ftb_%1_%2.jpg").arg(selected.name, QString::number(selected.id)); dialog->setSuggestedIconFromFile(FS::PathCombine(selected.path, "folder.jpg"), editedLogoName); } From 7b62d146838967903addc80247cf6e7db9862967 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 20 Oct 2023 17:15:12 +0300 Subject: [PATCH 24/79] fixed squished mod icons Signed-off-by: Trial97 --- launcher/minecraft/mod/ModFolderModel.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index a5f1489dd..b1e35f405 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -127,7 +127,18 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const if (column == NAME_COLUMN && (at(row)->isSymLinkUnder(instDirPath()) || at(row)->isMoreThanOneHardLink())) return APPLICATION->getThemedIcon("status-yellow"); if (column == ImageColumn) { - return at(row)->icon({ 32, 32 }, Qt::AspectRatioMode::KeepAspectRatioByExpanding); + QSize size(32, 32); + auto icon = at(row)->icon(size, Qt::AspectRatioMode::KeepAspectRatioByExpanding); + if (icon.isNull()) { + QPixmap transparent_image(size); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + transparent_image.fill(QColorConstants::Transparent); +#else + transparent_image.fill(QColor(0, 0, 0, 0)); +#endif + return transparent_image; + } + return icon; } return {}; } From 5d926582c7dcd4a288b9539a4a15338c1bfce21e Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 20 Oct 2023 19:08:56 +0300 Subject: [PATCH 25/79] added Image column size hint Signed-off-by: Trial97 --- launcher/minecraft/mod/ModFolderModel.cpp | 18 ++++++------------ .../minecraft/mod/ResourcePackFolderModel.cpp | 5 +++++ .../minecraft/mod/TexturePackFolderModel.cpp | 5 +++++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index b1e35f405..11f7cd0f1 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -127,21 +127,15 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const if (column == NAME_COLUMN && (at(row)->isSymLinkUnder(instDirPath()) || at(row)->isMoreThanOneHardLink())) return APPLICATION->getThemedIcon("status-yellow"); if (column == ImageColumn) { - QSize size(32, 32); - auto icon = at(row)->icon(size, Qt::AspectRatioMode::KeepAspectRatioByExpanding); - if (icon.isNull()) { - QPixmap transparent_image(size); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - transparent_image.fill(QColorConstants::Transparent); -#else - transparent_image.fill(QColor(0, 0, 0, 0)); -#endif - return transparent_image; - } - return icon; + return at(row)->icon({ 32, 32 }, Qt::AspectRatioMode::KeepAspectRatioByExpanding); } return {}; } + case Qt::SizeHintRole: + if (column == ImageColumn) { + return QSize(32, 32); + } + return {}; case Qt::CheckStateRole: switch (column) { case ActiveColumn: diff --git a/launcher/minecraft/mod/ResourcePackFolderModel.cpp b/launcher/minecraft/mod/ResourcePackFolderModel.cpp index f27431576..efe1cc5dd 100644 --- a/launcher/minecraft/mod/ResourcePackFolderModel.cpp +++ b/launcher/minecraft/mod/ResourcePackFolderModel.cpp @@ -117,6 +117,11 @@ QVariant ResourcePackFolderModel::data(const QModelIndex& index, int role) const } return m_resources[row]->internal_id(); } + case Qt::SizeHintRole: + if (column == ImageColumn) { + return QSize(32, 32); + } + return {}; case Qt::CheckStateRole: switch (column) { case ActiveColumn: diff --git a/launcher/minecraft/mod/TexturePackFolderModel.cpp b/launcher/minecraft/mod/TexturePackFolderModel.cpp index 5c5f2b7c1..e39be1fb9 100644 --- a/launcher/minecraft/mod/TexturePackFolderModel.cpp +++ b/launcher/minecraft/mod/TexturePackFolderModel.cpp @@ -104,6 +104,11 @@ QVariant TexturePackFolderModel::data(const QModelIndex& index, int role) const } return {}; } + case Qt::SizeHintRole: + if (column == ImageColumn) { + return QSize(32, 32); + } + return {}; case Qt::CheckStateRole: if (column == ActiveColumn) { return m_resources[row]->enabled() ? Qt::Checked : Qt::Unchecked; From e7e80e704f06c4fd73231228fa04d583d427f635 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 22 Oct 2023 00:18:23 +0000 Subject: [PATCH 26/79] chore(nix): update lockfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nixpkgs': 'github:nixos/nixpkgs/01441e14af5e29c9d27ace398e6dd0b293e25a54' (2023-10-11) → 'github:nixos/nixpkgs/44881e03af1c730cbb1d72a4d41274a2c957813a' (2023-10-21) • Updated input 'pre-commit-hooks': 'github:cachix/pre-commit-hooks.nix/42e1b6095ef80a51f79595d9951eb38e91c4e6ca' (2023-10-09) → 'github:cachix/pre-commit-hooks.nix/8cc349bfd082da8782b989cad2158c9ad5bd70fd' (2023-10-19) --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index ad18ff615..d71403358 100644 --- a/flake.lock +++ b/flake.lock @@ -106,11 +106,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1697009197, - "narHash": "sha256-viVRhBTFT8fPJTb1N3brQIpFZnttmwo3JVKNuWRVc3s=", + "lastModified": 1697886341, + "narHash": "sha256-AdE67xPty9M9wn36nPVp6aDntIdigrs7UbyaGv1VAaM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "01441e14af5e29c9d27ace398e6dd0b293e25a54", + "rev": "44881e03af1c730cbb1d72a4d41274a2c957813a", "type": "github" }, "original": { @@ -153,11 +153,11 @@ ] }, "locked": { - "lastModified": 1696846637, - "narHash": "sha256-0hv4kbXxci2+pxhuXlVgftj/Jq79VSmtAyvfabCCtYk=", + "lastModified": 1697746376, + "narHash": "sha256-gu77VkgdfaHgNCVufeb6WP9oqFLjwK4jHcoPZmBVF3E=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "42e1b6095ef80a51f79595d9951eb38e91c4e6ca", + "rev": "8cc349bfd082da8782b989cad2158c9ad5bd70fd", "type": "github" }, "original": { From db19362a970d2ffb4b25d1fbc2a5b1a1139205b9 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 22 Oct 2023 21:19:44 +0200 Subject: [PATCH 27/79] feat: add launcher brand and version props Signed-off-by: Sefa Eyeoglu --- launcher/minecraft/MinecraftInstance.cpp | 6 ++++++ libraries/launcher/org/prismlauncher/EntryPoint.java | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index f324ce87a..a4571e626 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -718,6 +718,12 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS launchScript += "windowParams " + windowParams + "\n"; } + // launcher info + { + launchScript += "launcherBrand " + BuildConfig.LAUNCHER_NAME + "\n"; + launchScript += "launcherVersion " + BuildConfig.printableVersionString() + "\n"; + } + // instance info { launchScript += "instanceName " + name() + "\n"; diff --git a/libraries/launcher/org/prismlauncher/EntryPoint.java b/libraries/launcher/org/prismlauncher/EntryPoint.java index eec2df9a9..699adfe30 100644 --- a/libraries/launcher/org/prismlauncher/EntryPoint.java +++ b/libraries/launcher/org/prismlauncher/EntryPoint.java @@ -142,12 +142,19 @@ public final class EntryPoint { } private static void setProperties(Parameters params) { + String launcherBrand = params.getString("launcherBrand", null); + String launcherVersion = params.getString("launcherVersion", null); String name = params.getString("instanceName", null); String iconId = params.getString("instanceIconKey", null); String iconPath = params.getString("instanceIconPath", null); String windowTitle = params.getString("windowTitle", null); String windowDimensions = params.getString("windowParams", null); + if (launcherBrand != null) + System.setProperty("minecraft.launcher.brand", launcherBrand); + if (launcherVersion != null) + System.setProperty("minecraft.launcher.version", launcherVersion); + // set useful properties for mods if (name != null) System.setProperty("org.prismlauncher.instance.name", name); From 7d5206818b70cede91aad1bf0dbcec92e5acde5a Mon Sep 17 00:00:00 2001 From: Tayou Date: Sun, 22 Oct 2023 21:00:52 +0200 Subject: [PATCH 28/79] fix switch/case fallthrough Signed-off-by: Tayou --- launcher/minecraft/mod/tasks/LocalModParseTask.cpp | 2 ++ launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp | 2 ++ launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp index 7ec00c0c6..e9e12d86a 100644 --- a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp @@ -688,6 +688,7 @@ bool loadIconFile(const Mod& mod) return png_invalid(); // icon invalid } } + return false; } case ResourceType::ZIPFILE: { QuaZip zip(mod.fileinfo().filePath()); @@ -714,6 +715,7 @@ bool loadIconFile(const Mod& mod) } else { return png_invalid(); // could not set icon as current file. } + return false; } case ResourceType::LITEMOD: { return false; // can lightmods even have icons? diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp index 7b9f4f594..7e02fd51c 100644 --- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp @@ -232,6 +232,7 @@ bool processPackPNG(const ResourcePack& pack) } else { return png_invalid(); // pack.png does not exists or is not a valid file. } + return false; // not processed correctly; https://github.com/PrismLauncher/PrismLauncher/issues/1740 } case ResourceType::ZIPFILE: { Q_ASSERT(pack.type() == ResourceType::ZIPFILE); @@ -259,6 +260,7 @@ bool processPackPNG(const ResourcePack& pack) } else { return png_invalid(); // could not set pack.mcmeta as current file. } + return false; // not processed correctly; https://github.com/PrismLauncher/PrismLauncher/issues/1740 } default: qWarning() << "Invalid type for resource pack parse task!"; diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp index 887a1062e..13f157dff 100644 --- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp @@ -186,6 +186,7 @@ bool processPackPNG(const TexturePack& pack) } else { return png_invalid(); // pack.png does not exists or is not a valid file. } + return false; } case ResourceType::ZIPFILE: { Q_ASSERT(pack.type() == ResourceType::ZIPFILE); @@ -215,6 +216,7 @@ bool processPackPNG(const TexturePack& pack) zip.close(); return png_invalid(); // could not set pack.mcmeta as current file. } + return false; } default: qWarning() << "Invalid type for resource pack parse task!"; From 0fe3241df61e014a0b427282258d156546880019 Mon Sep 17 00:00:00 2001 From: Tayou Date: Sat, 21 Oct 2023 20:05:14 +0200 Subject: [PATCH 29/79] remove now unneeded Q_ASSERTs Signed-off-by: Tayou --- launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp | 2 -- launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp index 7e02fd51c..26bc07637 100644 --- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp @@ -235,8 +235,6 @@ bool processPackPNG(const ResourcePack& pack) return false; // not processed correctly; https://github.com/PrismLauncher/PrismLauncher/issues/1740 } case ResourceType::ZIPFILE: { - Q_ASSERT(pack.type() == ResourceType::ZIPFILE); - QuaZip zip(pack.fileinfo().filePath()); if (!zip.open(QuaZip::mdUnzip)) return false; // can't open zip file diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp index 13f157dff..d7e61ca90 100644 --- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp @@ -189,8 +189,6 @@ bool processPackPNG(const TexturePack& pack) return false; } case ResourceType::ZIPFILE: { - Q_ASSERT(pack.type() == ResourceType::ZIPFILE); - QuaZip zip(pack.fileinfo().filePath()); if (!zip.open(QuaZip::mdUnzip)) return false; // can't open zip file From f7c9972db07fc10b58383f55feb5254a6c950315 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 23 Oct 2023 19:46:30 +0300 Subject: [PATCH 30/79] separated dependecy check from mod update Signed-off-by: Trial97 --- launcher/ui/dialogs/ChooseProviderDialog.h | 1 - launcher/ui/dialogs/ModUpdateDialog.cpp | 6 +++-- launcher/ui/dialogs/ModUpdateDialog.h | 4 +++- .../pages/instance/ExternalResourcesPage.ui | 11 +++++++++ launcher/ui/pages/instance/ModFolderPage.cpp | 23 ++++++++++++------- launcher/ui/pages/instance/ModFolderPage.h | 2 +- 6 files changed, 34 insertions(+), 13 deletions(-) diff --git a/launcher/ui/dialogs/ChooseProviderDialog.h b/launcher/ui/dialogs/ChooseProviderDialog.h index be9735b5c..51e7c98c6 100644 --- a/launcher/ui/dialogs/ChooseProviderDialog.h +++ b/launcher/ui/dialogs/ChooseProviderDialog.h @@ -13,7 +13,6 @@ enum class ResourceProvider; class Mod; class NetJob; -class ModUpdateDialog; class ChooseProviderDialog : public QDialog { Q_OBJECT diff --git a/launcher/ui/dialogs/ModUpdateDialog.cpp b/launcher/ui/dialogs/ModUpdateDialog.cpp index 1a70ea59a..9e91a4aec 100644 --- a/launcher/ui/dialogs/ModUpdateDialog.cpp +++ b/launcher/ui/dialogs/ModUpdateDialog.cpp @@ -39,7 +39,8 @@ static std::optional mcLoaders(BaseInstance* inst) ModUpdateDialog::ModUpdateDialog(QWidget* parent, BaseInstance* instance, const std::shared_ptr mods, - QList& search_for) + QList& search_for, + bool includeDeps) : ReviewMessageBox(parent, tr("Confirm mods to update"), "") , m_parent(parent) , m_mod_model(mods) @@ -47,6 +48,7 @@ ModUpdateDialog::ModUpdateDialog(QWidget* parent, , m_second_try_metadata( new ConcurrentTask(nullptr, "Second Metadata Search", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt())) , m_instance(instance) + , m_include_deps(includeDeps) { ReviewMessageBox::setGeometry(0, 0, 800, 600); @@ -186,7 +188,7 @@ void ModUpdateDialog::checkCandidates() } } - { // dependencies + if (m_include_deps) { // dependencies auto depTask = makeShared(this, m_instance, m_mod_model.get(), selectedVers); connect(depTask.get(), &Task::failed, this, diff --git a/launcher/ui/dialogs/ModUpdateDialog.h b/launcher/ui/dialogs/ModUpdateDialog.h index b79aa4943..98f6780bf 100644 --- a/launcher/ui/dialogs/ModUpdateDialog.h +++ b/launcher/ui/dialogs/ModUpdateDialog.h @@ -19,7 +19,8 @@ class ModUpdateDialog final : public ReviewMessageBox { explicit ModUpdateDialog(QWidget* parent, BaseInstance* instance, const std::shared_ptr mod_model, - QList& search_for); + QList& search_for, + bool includeDeps); void checkCandidates(); @@ -61,4 +62,5 @@ class ModUpdateDialog final : public ReviewMessageBox { bool m_no_updates = false; bool m_aborted = false; + bool m_include_deps = false; }; diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.ui b/launcher/ui/pages/instance/ExternalResourcesPage.ui index ba703f77d..b9a8e4963 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.ui +++ b/launcher/ui/pages/instance/ExternalResourcesPage.ui @@ -156,6 +156,17 @@ Try to check or update all selected resources (all resources if none are selected) + + + + false + + + &Verify Dependencies + + + Try to update and check for missing dependencies all selected resources (all resources if none are selected) + diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 625d37933..8e3b9e93b 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -88,6 +88,11 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr ui->actionsToolbar->insertActionAfter(ui->actionAddItem, ui->actionUpdateItem); connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods); + ui->actionUpdateDepsItem->setToolTip( + tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)")); + ui->actionsToolbar->insertActionAfter(ui->actionUpdateItem, ui->actionUpdateDepsItem); + connect(ui->actionUpdateDepsItem, &QAction::triggered, this, [this] { updateMods(true); }); + ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page")); ui->actionsToolbar->addAction(ui->actionVisitItemPage); connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages); @@ -100,6 +105,7 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); + ui->actionUpdateDepsItem->setEnabled(check_allow_update()); auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); auto mods_list = m_model->selectedMods(selection); @@ -120,14 +126,15 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr ui->actionRemoveItemMetadata->setEnabled(selected != 0); }); - connect(mods.get(), &ModFolderModel::rowsInserted, this, - [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); }); + auto updateButtons = [this, check_allow_update] { + ui->actionUpdateItem->setEnabled(check_allow_update()); + ui->actionUpdateDepsItem->setEnabled(check_allow_update()); + }; + connect(mods.get(), &ModFolderModel::rowsInserted, this, updateButtons); - connect(mods.get(), &ModFolderModel::rowsRemoved, this, - [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); }); + connect(mods.get(), &ModFolderModel::rowsRemoved, this, updateButtons); - connect(mods.get(), &ModFolderModel::updateFinished, this, - [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); }); + connect(mods.get(), &ModFolderModel::updateFinished, this, updateButtons); } } @@ -204,7 +211,7 @@ void ModFolderPage::installMods() } } -void ModFolderPage::updateMods() +void ModFolderPage::updateMods(bool includeDeps) { if (m_instance->typeName() != "Minecraft") return; // this is a null instance or a legacy instance @@ -221,7 +228,7 @@ void ModFolderPage::updateMods() if (use_all) mods_list = m_model->allMods(); - ModUpdateDialog update_dialog(this, m_instance, m_model, mods_list); + ModUpdateDialog update_dialog(this, m_instance, m_model, mods_list, includeDeps); update_dialog.checkCandidates(); if (update_dialog.aborted()) { diff --git a/launcher/ui/pages/instance/ModFolderPage.h b/launcher/ui/pages/instance/ModFolderPage.h index 0c654d0d1..4672350c6 100644 --- a/launcher/ui/pages/instance/ModFolderPage.h +++ b/launcher/ui/pages/instance/ModFolderPage.h @@ -64,7 +64,7 @@ class ModFolderPage : public ExternalResourcesPage { void deleteModMetadata(); void installMods(); - void updateMods(); + void updateMods(bool includeDeps = false); void visitModPages(); protected: From 87f2f88d4cdba8070e8cd259cee37f40ff2a8e2a Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 23 Oct 2023 23:38:03 +0300 Subject: [PATCH 31/79] fix: java memory not set on initial setup Signed-off-by: Trial97 --- launcher/ui/setupwizard/JavaWizardPage.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/launcher/ui/setupwizard/JavaWizardPage.cpp b/launcher/ui/setupwizard/JavaWizardPage.cpp index e2c444373..abe4860da 100644 --- a/launcher/ui/setupwizard/JavaWizardPage.cpp +++ b/launcher/ui/setupwizard/JavaWizardPage.cpp @@ -64,8 +64,7 @@ bool JavaWizardPage::validatePage() } case JavaSettingsWidget::ValidationStatus::AllOK: { settings->set("JavaPath", m_java_widget->javaPath()); - return true; - } + } /* fallthrough */ case JavaSettingsWidget::ValidationStatus::JavaBad: { // Memory auto s = APPLICATION->settings(); From 5be80df1ee0e17f4db22daff4ea327cb969bfaef Mon Sep 17 00:00:00 2001 From: LocalSpook <56512186+LocalSpook@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:34:11 -0700 Subject: [PATCH 32/79] Replace `typedef` with `using` Signed-off-by: LocalSpook <56512186+LocalSpook@users.noreply.github.com> --- .clang-tidy | 4 ++++ launcher/BaseInstance.h | 2 +- launcher/BaseVersionList.h | 2 +- launcher/FileSystem.cpp | 21 +++++++++++++------ launcher/MMCZip.h | 2 +- launcher/VersionProxyModel.h | 2 +- launcher/java/JavaChecker.h | 4 ++-- launcher/java/JavaCheckerJob.h | 2 +- launcher/java/JavaInstall.h | 2 +- launcher/minecraft/Agent.h | 2 +- launcher/minecraft/Component.h | 2 +- launcher/minecraft/Library.h | 2 +- launcher/minecraft/MinecraftInstance.h | 2 +- launcher/minecraft/MojangDownloadInfo.h | 6 +++--- launcher/minecraft/ProfileUtils.h | 2 +- launcher/minecraft/auth/AuthSession.h | 2 +- launcher/minecraft/auth/MinecraftAccount.h | 2 +- .../minecraft/launch/MinecraftServerTarget.h | 2 +- launcher/minecraft/services/SkinDelete.h | 2 +- launcher/minecraft/services/SkinUpload.h | 2 +- launcher/modplatform/import_ftb/PackHelpers.h | 2 +- launcher/modplatform/legacy_ftb/PackHelpers.h | 2 +- launcher/net/NetRequest.h | 2 +- launcher/news/NewsEntry.h | 2 +- launcher/pathmatcher/IPathMatcher.h | 2 +- launcher/settings/SettingsObject.h | 4 ++-- launcher/tasks/Task.h | 2 +- launcher/ui/dialogs/ExportInstanceDialog.h | 2 +- .../instanceview/AccessibleInstanceView_p.h | 2 +- launcher/ui/pages/BasePage.h | 2 +- launcher/ui/pages/BasePageProvider.h | 2 +- .../ui/pages/instance/ScreenshotsPage.cpp | 4 ++-- .../modplatform/atlauncher/AtlListModel.h | 4 ++-- .../ui/pages/modplatform/flame/FlameModel.h | 4 ++-- .../pages/modplatform/legacy_ftb/ListModel.h | 4 ++-- .../pages/modplatform/technic/TechnicModel.h | 2 +- libraries/.clang-tidy | 2 ++ 37 files changed, 63 insertions(+), 48 deletions(-) create mode 100644 .clang-tidy create mode 100644 libraries/.clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..11ddc9cfc --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,4 @@ +Checks: + - modernize-use-using + +SystemHeaders: false diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h index 47fff5957..f4ed9113c 100644 --- a/launcher/BaseInstance.h +++ b/launcher/BaseInstance.h @@ -64,7 +64,7 @@ class LaunchTask; class BaseInstance; // pointer for lazy people -typedef std::shared_ptr InstancePtr; +using InstancePtr = std::shared_ptr; /*! * \brief Base class for instances. diff --git a/launcher/BaseVersionList.h b/launcher/BaseVersionList.h index fe1550c21..231887c4e 100644 --- a/launcher/BaseVersionList.h +++ b/launcher/BaseVersionList.h @@ -51,7 +51,7 @@ class BaseVersionList : public QAbstractListModel { ArchitectureRole, SortRole }; - typedef QList RoleList; + using RoleList = QList; explicit BaseVersionList(QObject* parent = 0); diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 652ba2995..c7d5f85fa 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -123,26 +123,35 @@ namespace fs = ghc::filesystem; #if defined(__MINGW32__) -typedef struct _DUPLICATE_EXTENTS_DATA { +struct _DUPLICATE_EXTENTS_DATA { HANDLE FileHandle; LARGE_INTEGER SourceFileOffset; LARGE_INTEGER TargetFileOffset; LARGE_INTEGER ByteCount; -} DUPLICATE_EXTENTS_DATA, *PDUPLICATE_EXTENTS_DATA; +}; -typedef struct _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER { +using DUPLICATE_EXTENTS_DATA = _DUPLICATE_EXTENTS_DATA; +using PDUPLICATE_EXTENTS_DATA = _DUPLICATE_EXTENTS_DATA*; + +struct _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER { WORD ChecksumAlgorithm; // Checksum algorithm. e.g. CHECKSUM_TYPE_UNCHANGED, CHECKSUM_TYPE_NONE, CHECKSUM_TYPE_CRC32 WORD Reserved; // Must be 0 DWORD Flags; // FSCTL_INTEGRITY_FLAG_xxx DWORD ChecksumChunkSizeInBytes; DWORD ClusterSizeInBytes; -} FSCTL_GET_INTEGRITY_INFORMATION_BUFFER, *PFSCTL_GET_INTEGRITY_INFORMATION_BUFFER; +}; -typedef struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER { +using FSCTL_GET_INTEGRITY_INFORMATION_BUFFER = _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER; +using PFSCTL_GET_INTEGRITY_INFORMATION_BUFFER = _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER*; + +struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER { WORD ChecksumAlgorithm; // Checksum algorithm. e.g. CHECKSUM_TYPE_UNCHANGED, CHECKSUM_TYPE_NONE, CHECKSUM_TYPE_CRC32 WORD Reserved; // Must be 0 DWORD Flags; // FSCTL_INTEGRITY_FLAG_xxx -} FSCTL_SET_INTEGRITY_INFORMATION_BUFFER, *PFSCTL_SET_INTEGRITY_INFORMATION_BUFFER; +}; + +using FSCTL_SET_INTEGRITY_INFORMATION_BUFFER = _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER; +using PFSCTL_SET_INTEGRITY_INFORMATION_BUFFER = _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER*; #endif diff --git a/launcher/MMCZip.h b/launcher/MMCZip.h index 1c6ebe34a..45b1df0b3 100644 --- a/launcher/MMCZip.h +++ b/launcher/MMCZip.h @@ -172,7 +172,7 @@ class ExportToZipTask : public Task { void setExcludeFiles(QStringList excludeFiles) { m_exclude_files = excludeFiles; } void addExtraFile(QString fileName, QByteArray data) { m_extra_files.insert(fileName, data); } - typedef std::optional ZipResult; + using ZipResult = std::optional; protected: virtual void executeTask() override; diff --git a/launcher/VersionProxyModel.h b/launcher/VersionProxyModel.h index c7d5fd94e..57c711d58 100644 --- a/launcher/VersionProxyModel.h +++ b/launcher/VersionProxyModel.h @@ -10,7 +10,7 @@ class VersionProxyModel : public QAbstractProxyModel { Q_OBJECT public: enum Column { Name, ParentVersion, Branch, Type, Architecture, Path, Time }; - typedef QHash> FilterMap; + using FilterMap = QHash>; public: VersionProxyModel(QObject* parent = 0); diff --git a/launcher/java/JavaChecker.h b/launcher/java/JavaChecker.h index 743f49417..7111f8522 100644 --- a/launcher/java/JavaChecker.h +++ b/launcher/java/JavaChecker.h @@ -22,8 +22,8 @@ struct JavaCheckResult { enum class Validity { Errored, ReturnedInvalidData, Valid } validity = Validity::Errored; }; -typedef shared_qobject_ptr QProcessPtr; -typedef shared_qobject_ptr JavaCheckerPtr; +using QProcessPtr = shared_qobject_ptr; +using JavaCheckerPtr = shared_qobject_ptr; class JavaChecker : public QObject { Q_OBJECT public: diff --git a/launcher/java/JavaCheckerJob.h b/launcher/java/JavaCheckerJob.h index 009687917..ddf827968 100644 --- a/launcher/java/JavaCheckerJob.h +++ b/launcher/java/JavaCheckerJob.h @@ -20,7 +20,7 @@ #include "tasks/Task.h" class JavaCheckerJob; -typedef shared_qobject_ptr JavaCheckerJobPtr; +using JavaCheckerJobPtr = shared_qobject_ptr; // FIXME: this just seems horribly redundant class JavaCheckerJob : public Task { diff --git a/launcher/java/JavaInstall.h b/launcher/java/JavaInstall.h index 49e9ed06e..8c2743a00 100644 --- a/launcher/java/JavaInstall.h +++ b/launcher/java/JavaInstall.h @@ -42,4 +42,4 @@ struct JavaInstall : public BaseVersion { bool recommended = false; }; -typedef std::shared_ptr JavaInstallPtr; +using JavaInstallPtr = std::shared_ptr; diff --git a/launcher/minecraft/Agent.h b/launcher/minecraft/Agent.h index 8958521e5..bc385a74e 100644 --- a/launcher/minecraft/Agent.h +++ b/launcher/minecraft/Agent.h @@ -6,7 +6,7 @@ class Agent; -typedef std::shared_ptr AgentPtr; +using AgentPtr = std::shared_ptr; class Agent { public: diff --git a/launcher/minecraft/Component.h b/launcher/minecraft/Component.h index 3474a22e0..fdb61c45e 100644 --- a/launcher/minecraft/Component.h +++ b/launcher/minecraft/Component.h @@ -105,4 +105,4 @@ class Component : public QObject, public ProblemProvider { bool m_loaded = false; }; -typedef shared_qobject_ptr ComponentPtr; +using ComponentPtr = shared_qobject_ptr; diff --git a/launcher/minecraft/Library.h b/launcher/minecraft/Library.h index f8816a97b..adb89c4c6 100644 --- a/launcher/minecraft/Library.h +++ b/launcher/minecraft/Library.h @@ -52,7 +52,7 @@ class Library; class MinecraftInstance; -typedef std::shared_ptr LibraryPtr; +using LibraryPtr = std::shared_ptr; class Library { friend class OneSixVersionFormat; diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h index a816a3e60..b1f305201 100644 --- a/launcher/minecraft/MinecraftInstance.h +++ b/launcher/minecraft/MinecraftInstance.h @@ -174,4 +174,4 @@ class MinecraftInstance : public BaseInstance { mutable std::shared_ptr m_game_options; }; -typedef std::shared_ptr MinecraftInstancePtr; +using MinecraftInstancePtr = std::shared_ptr; diff --git a/launcher/minecraft/MojangDownloadInfo.h b/launcher/minecraft/MojangDownloadInfo.h index 855dbe005..eb64f95b7 100644 --- a/launcher/minecraft/MojangDownloadInfo.h +++ b/launcher/minecraft/MojangDownloadInfo.h @@ -5,7 +5,7 @@ struct MojangDownloadInfo { // types - typedef std::shared_ptr Ptr; + using Ptr = std::shared_ptr; // data /// Local filesystem path. WARNING: not used, only here so we can pass through mojang files unmolested! @@ -23,7 +23,7 @@ struct MojangLibraryDownloadInfo { MojangLibraryDownloadInfo() {} // types - typedef std::shared_ptr Ptr; + using Ptr = std::shared_ptr; // methods MojangDownloadInfo* getDownloadInfo(QString classifier) @@ -42,7 +42,7 @@ struct MojangLibraryDownloadInfo { struct MojangAssetIndexInfo : public MojangDownloadInfo { // types - typedef std::shared_ptr Ptr; + using Ptr = std::shared_ptr; // methods MojangAssetIndexInfo() {} diff --git a/launcher/minecraft/ProfileUtils.h b/launcher/minecraft/ProfileUtils.h index 98a7ff739..edabe0bf0 100644 --- a/launcher/minecraft/ProfileUtils.h +++ b/launcher/minecraft/ProfileUtils.h @@ -38,7 +38,7 @@ #include "VersionFile.h" namespace ProfileUtils { -typedef QStringList PatchOrder; +using PatchOrder = QStringList; /// Read and parse a OneSix format order file bool readOverrideOrders(QString path, PatchOrder& order); diff --git a/launcher/minecraft/auth/AuthSession.h b/launcher/minecraft/auth/AuthSession.h index 074b2d6e3..cec238033 100644 --- a/launcher/minecraft/auth/AuthSession.h +++ b/launcher/minecraft/auth/AuthSession.h @@ -43,4 +43,4 @@ struct AuthSession { bool demo = false; }; -typedef std::shared_ptr AuthSessionPtr; +using AuthSessionPtr = std::shared_ptr; diff --git a/launcher/minecraft/auth/MinecraftAccount.h b/launcher/minecraft/auth/MinecraftAccount.h index 910f4a28a..c4e9756a9 100644 --- a/launcher/minecraft/auth/MinecraftAccount.h +++ b/launcher/minecraft/auth/MinecraftAccount.h @@ -54,7 +54,7 @@ class Task; class AccountTask; class MinecraftAccount; -typedef shared_qobject_ptr MinecraftAccountPtr; +using MinecraftAccountPtr = shared_qobject_ptr; Q_DECLARE_METATYPE(MinecraftAccountPtr) /** diff --git a/launcher/minecraft/launch/MinecraftServerTarget.h b/launcher/minecraft/launch/MinecraftServerTarget.h index af8d6550b..2edd8a30d 100644 --- a/launcher/minecraft/launch/MinecraftServerTarget.h +++ b/launcher/minecraft/launch/MinecraftServerTarget.h @@ -26,4 +26,4 @@ struct MinecraftServerTarget { static MinecraftServerTarget parse(const QString& fullAddress); }; -typedef std::shared_ptr MinecraftServerTargetPtr; +using MinecraftServerTargetPtr = std::shared_ptr; diff --git a/launcher/minecraft/services/SkinDelete.h b/launcher/minecraft/services/SkinDelete.h index d5b2e63db..44e30453f 100644 --- a/launcher/minecraft/services/SkinDelete.h +++ b/launcher/minecraft/services/SkinDelete.h @@ -4,7 +4,7 @@ #include #include "tasks/Task.h" -typedef shared_qobject_ptr SkinDeletePtr; +using SkinDeletePtr = shared_qobject_ptr; class SkinDelete : public Task { Q_OBJECT diff --git a/launcher/minecraft/services/SkinUpload.h b/launcher/minecraft/services/SkinUpload.h index 5716aa996..016367ff8 100644 --- a/launcher/minecraft/services/SkinUpload.h +++ b/launcher/minecraft/services/SkinUpload.h @@ -5,7 +5,7 @@ #include #include "tasks/Task.h" -typedef shared_qobject_ptr SkinUploadPtr; +using SkinUploadPtr = shared_qobject_ptr; class SkinUpload : public Task { Q_OBJECT diff --git a/launcher/modplatform/import_ftb/PackHelpers.h b/launcher/modplatform/import_ftb/PackHelpers.h index 5400252b6..221eb5bf6 100644 --- a/launcher/modplatform/import_ftb/PackHelpers.h +++ b/launcher/modplatform/import_ftb/PackHelpers.h @@ -45,7 +45,7 @@ struct Modpack { QIcon icon; }; -typedef QList ModpackList; +using ModpackList = QList; Modpack parseDirectory(QString path); diff --git a/launcher/modplatform/legacy_ftb/PackHelpers.h b/launcher/modplatform/legacy_ftb/PackHelpers.h index 4fb535530..f2d18f802 100644 --- a/launcher/modplatform/legacy_ftb/PackHelpers.h +++ b/launcher/modplatform/legacy_ftb/PackHelpers.h @@ -31,7 +31,7 @@ struct Modpack { QString packCode; }; -typedef QList ModpackList; +using ModpackList = QList; } // namespace LegacyFTB diff --git a/launcher/net/NetRequest.h b/launcher/net/NetRequest.h index ee47ab2a6..0b307b4f6 100644 --- a/launcher/net/NetRequest.h +++ b/launcher/net/NetRequest.h @@ -87,7 +87,7 @@ class NetRequest : public NetAction { std::unique_ptr m_sink; Options m_options; - typedef const QLoggingCategory& (*logCatFunc)(); + using logCatFunc = const QLoggingCategory& (*)(); logCatFunc logCat = taskUploadLogC; std::chrono::steady_clock m_clock; diff --git a/launcher/news/NewsEntry.h b/launcher/news/NewsEntry.h index 2d409a9fb..ab717ec89 100644 --- a/launcher/news/NewsEntry.h +++ b/launcher/news/NewsEntry.h @@ -51,4 +51,4 @@ class NewsEntry : public QObject { QString link; }; -typedef std::shared_ptr NewsEntryPtr; +using NewsEntryPtr = std::shared_ptr; diff --git a/launcher/pathmatcher/IPathMatcher.h b/launcher/pathmatcher/IPathMatcher.h index cd6121979..f3b01e8cf 100644 --- a/launcher/pathmatcher/IPathMatcher.h +++ b/launcher/pathmatcher/IPathMatcher.h @@ -4,7 +4,7 @@ class IPathMatcher { public: - typedef std::shared_ptr Ptr; + using Ptr = std::shared_ptr; public: virtual ~IPathMatcher() {} diff --git a/launcher/settings/SettingsObject.h b/launcher/settings/SettingsObject.h index 75631f247..f133f2f7f 100644 --- a/launcher/settings/SettingsObject.h +++ b/launcher/settings/SettingsObject.h @@ -26,8 +26,8 @@ class Setting; class SettingsObject; -typedef std::shared_ptr SettingsObjectPtr; -typedef std::weak_ptr SettingsObjectWeakPtr; +using SettingsObjectPtr = std::shared_ptr; +using SettingsObjectWeakPtr = std::weak_ptr; /*! * \brief The SettingsObject handles communicating settings between the application and a diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h index 94b4089f3..883408c97 100644 --- a/launcher/tasks/Task.h +++ b/launcher/tasks/Task.h @@ -77,7 +77,7 @@ struct TaskStepProgress { Q_DECLARE_METATYPE(TaskStepProgress) -typedef QList> TaskStepProgressList; +using TaskStepProgressList = QList>; class Task : public QObject, public QRunnable { Q_OBJECT diff --git a/launcher/ui/dialogs/ExportInstanceDialog.h b/launcher/ui/dialogs/ExportInstanceDialog.h index 02f38f63d..183681f57 100644 --- a/launcher/ui/dialogs/ExportInstanceDialog.h +++ b/launcher/ui/dialogs/ExportInstanceDialog.h @@ -43,7 +43,7 @@ #include "FileIgnoreProxy.h" class BaseInstance; -typedef std::shared_ptr InstancePtr; +using InstancePtr = std::shared_ptr; namespace Ui { class ExportInstanceDialog; diff --git a/launcher/ui/instanceview/AccessibleInstanceView_p.h b/launcher/ui/instanceview/AccessibleInstanceView_p.h index e99f85069..1a3a62d9f 100644 --- a/launcher/ui/instanceview/AccessibleInstanceView_p.h +++ b/launcher/ui/instanceview/AccessibleInstanceView_p.h @@ -59,7 +59,7 @@ class AccessibleInstanceView : public QAccessibleTableInterface, public QAccessi protected: // maybe vector - typedef QHash ChildCache; + using ChildCache = QHash; mutable ChildCache childToId; virtual ~AccessibleInstanceView(); diff --git a/launcher/ui/pages/BasePage.h b/launcher/ui/pages/BasePage.h index d35206a08..cb3a7633d 100644 --- a/launcher/ui/pages/BasePage.h +++ b/launcher/ui/pages/BasePage.h @@ -77,4 +77,4 @@ class BasePage { bool isOpened = false; }; -typedef std::shared_ptr BasePagePtr; +using BasePagePtr = std::shared_ptr; diff --git a/launcher/ui/pages/BasePageProvider.h b/launcher/ui/pages/BasePageProvider.h index 4c3ecd6c1..422891e6b 100644 --- a/launcher/ui/pages/BasePageProvider.h +++ b/launcher/ui/pages/BasePageProvider.h @@ -26,7 +26,7 @@ class BasePageProvider { }; class GenericPageProvider : public BasePageProvider { - typedef std::function PageCreator; + using PageCreator = std::function; public: explicit GenericPageProvider(const QString& dialogTitle) : m_dialogTitle(dialogTitle) {} diff --git a/launcher/ui/pages/instance/ScreenshotsPage.cpp b/launcher/ui/pages/instance/ScreenshotsPage.cpp index 25f978cea..83fb0d5ff 100644 --- a/launcher/ui/pages/instance/ScreenshotsPage.cpp +++ b/launcher/ui/pages/instance/ScreenshotsPage.cpp @@ -68,8 +68,8 @@ #include #include "RWStorage.h" -typedef RWStorage SharedIconCache; -typedef std::shared_ptr SharedIconCachePtr; +using SharedIconCache = RWStorage; +using SharedIconCachePtr = std::shared_ptr; class ThumbnailingResult : public QObject { Q_OBJECT diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlListModel.h b/launcher/ui/pages/modplatform/atlauncher/AtlListModel.h index ed1fdc9f9..bcadd7c91 100644 --- a/launcher/ui/pages/modplatform/atlauncher/AtlListModel.h +++ b/launcher/ui/pages/modplatform/atlauncher/AtlListModel.h @@ -24,8 +24,8 @@ namespace Atl { -typedef QMap LogoMap; -typedef std::function LogoCallback; +using LogoMap = QMap; +using LogoCallback = std::function; class ListModel : public QAbstractListModel { Q_OBJECT diff --git a/launcher/ui/pages/modplatform/flame/FlameModel.h b/launcher/ui/pages/modplatform/flame/FlameModel.h index fd8496dfb..5a07ef6bb 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModel.h +++ b/launcher/ui/pages/modplatform/flame/FlameModel.h @@ -19,8 +19,8 @@ namespace Flame { -typedef QMap LogoMap; -typedef std::function LogoCallback; +using LogoMap = QMap; +using LogoCallback = std::function; class ListModel : public QAbstractListModel { Q_OBJECT diff --git a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h index c802a4b56..f35012078 100644 --- a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h +++ b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h @@ -13,8 +13,8 @@ namespace LegacyFTB { -typedef QMap FTBLogoMap; -typedef std::function LogoCallback; +using FTBLogoMap = QMap; +using LogoCallback = std::function; class FilterModel : public QSortFilterProxyModel { Q_OBJECT diff --git a/launcher/ui/pages/modplatform/technic/TechnicModel.h b/launcher/ui/pages/modplatform/technic/TechnicModel.h index aeb4f3084..09e9294bb 100644 --- a/launcher/ui/pages/modplatform/technic/TechnicModel.h +++ b/launcher/ui/pages/modplatform/technic/TechnicModel.h @@ -42,7 +42,7 @@ namespace Technic { -typedef std::function LogoCallback; +using LogoCallback = std::function; class ListModel : public QAbstractListModel { Q_OBJECT diff --git a/libraries/.clang-tidy b/libraries/.clang-tidy new file mode 100644 index 000000000..358b093b9 --- /dev/null +++ b/libraries/.clang-tidy @@ -0,0 +1,2 @@ +# We don't care about linting third-party code. +Checks: -* From 12d567a9b83142b102598a944c650849d4a0f94e Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 26 Oct 2023 22:51:38 +0300 Subject: [PATCH 33/79] made env vars behave like the rest of the settings Signed-off-by: Trial97 --- launcher/minecraft/MinecraftInstance.cpp | 10 +++--- .../pages/global/EnvironmentVariablesPage.cpp | 2 +- .../pages/instance/InstanceSettingsPage.cpp | 12 ++++--- launcher/ui/widgets/EnvironmentVariables.cpp | 36 +++---------------- launcher/ui/widgets/EnvironmentVariables.h | 3 +- launcher/ui/widgets/EnvironmentVariables.ui | 7 ---- 6 files changed, 17 insertions(+), 53 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index cc33c05af..b371a3751 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -188,9 +188,8 @@ void MinecraftInstance::loadSpecificSettings() auto legacySettings = m_settings->registerSetting("OverrideLegacySettings", false); m_settings->registerOverride(global_settings->getSetting("OnlineFixes"), legacySettings); - m_settings->registerSetting("UseEnv", false); - m_settings->registerSetting("OverrideEnv", false); - m_settings->registerSetting("Env", QVariant(QMap())); + auto envSetting = m_settings->registerSetting("OverrideEnv", false); + m_settings->registerOverride(global_settings->getSetting("Env"), envSetting); m_settings->set("InstanceType", "OneSix"); } @@ -612,12 +611,11 @@ QProcessEnvironment MinecraftInstance::createLaunchEnvironment() env.insert(iter.key(), iter.value().toString()); }; - bool useEnv = settings()->get("UseEnv").toBool(); - bool overrideEnv = useEnv && settings()->get("OverrideEnv").toBool(); + bool overrideEnv = settings()->get("OverrideEnv").toBool(); if (!overrideEnv) insertEnv(APPLICATION->settings()->get("Env").toMap()); - if (useEnv) + else insertEnv(settings()->get("Env").toMap()); return env; diff --git a/launcher/ui/pages/global/EnvironmentVariablesPage.cpp b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp index 2c3b716b8..2b76df362 100644 --- a/launcher/ui/pages/global/EnvironmentVariablesPage.cpp +++ b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp @@ -29,7 +29,7 @@ EnvironmentVariablesPage::EnvironmentVariablesPage(QWidget* parent) : QWidget(pa variables->setContentsMargins(6, 6, 6, 6); verticalLayout->addWidget(variables); - variables->initialize(false, true, false, APPLICATION->settings()->get("Env").toMap()); + variables->initialize(false, false, APPLICATION->settings()->get("Env").toMap()); } QString EnvironmentVariablesPage::displayName() const diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp index 9f01cab42..74785f97e 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -203,9 +203,12 @@ void InstanceSettingsPage::applySettings() } // Environment Variables - m_settings->set("UseEnv", ui->environmentVariables->checked()); - m_settings->set("OverrideEnv", ui->environmentVariables->override()); - m_settings->set("Env", ui->environmentVariables->value()); + auto env = ui->environmentVariables->override(); + m_settings->set("OverrideEnv", env); + if (env) + m_settings->set("Env", ui->environmentVariables->value()); + else + m_settings->reset("Env"); // Workarounds bool workarounds = ui->nativeWorkaroundsGroupBox->isChecked(); @@ -327,8 +330,7 @@ void InstanceSettingsPage::loadSettings() m_settings->get("WrapperCommand").toString(), m_settings->get("PostExitCommand").toString()); // Environment variables - ui->environmentVariables->initialize(true, m_settings->get("UseEnv").toBool(), m_settings->get("OverrideEnv").toBool(), - m_settings->get("Env").toMap()); + ui->environmentVariables->initialize(true, m_settings->get("OverrideEnv").toBool(), m_settings->get("Env").toMap()); // Workarounds ui->nativeWorkaroundsGroupBox->setChecked(m_settings->get("OverrideNativeWorkarounds").toBool()); diff --git a/launcher/ui/widgets/EnvironmentVariables.cpp b/launcher/ui/widgets/EnvironmentVariables.cpp index a409f64fc..633fc6122 100644 --- a/launcher/ui/widgets/EnvironmentVariables.cpp +++ b/launcher/ui/widgets/EnvironmentVariables.cpp @@ -50,25 +50,6 @@ EnvironmentVariables::EnvironmentVariables(QWidget* parent) : QWidget(parent), u }); connect(ui->clear, &QPushButton::clicked, this, [this] { ui->list->clear(); }); - - connect(ui->globalOverride, &QCheckBox::clicked, this, [this](bool state) { - if (!state) - return; - - auto global = APPLICATION->settings()->get("Env").toMap(); - if (global.isEmpty()) - return; - - auto response = CustomMessageBox::selectable( - this, tr("Reset"), - tr("You have chosen to ignore global settings.\n\nWould you like to clear the current variables and copy " - "the global variables over?"), - QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) - ->exec(); - - if (response == QMessageBox::Yes) - initialize(true, checked(), override(), global); - }); } EnvironmentVariables::~EnvironmentVariables() @@ -76,13 +57,11 @@ EnvironmentVariables::~EnvironmentVariables() delete ui; } -void EnvironmentVariables::initialize(bool instance, bool checked, bool override, const QMap& value) +void EnvironmentVariables::initialize(bool instance, bool override, const QMap& value) { // update widgets to settings ui->groupBox->setCheckable(instance); - ui->groupBox->setChecked(checked); - ui->globalOverride->setVisible(instance); - ui->globalOverride->setChecked(override); + ui->groupBox->setChecked(override); // populate ui->list->clear(); @@ -113,18 +92,11 @@ void EnvironmentVariables::retranslate() ui->retranslateUi(this); } -bool EnvironmentVariables::checked() const -{ - if (!ui->groupBox->isCheckable()) - return true; - return ui->groupBox->isChecked(); -} - bool EnvironmentVariables::override() const { - if (!ui->globalOverride->isVisible()) + if (!ui->groupBox->isCheckable()) return false; - return ui->globalOverride->isChecked(); + return ui->groupBox->isChecked(); } QMap EnvironmentVariables::value() const diff --git a/launcher/ui/widgets/EnvironmentVariables.h b/launcher/ui/widgets/EnvironmentVariables.h index ba4329dd9..092d586bd 100644 --- a/launcher/ui/widgets/EnvironmentVariables.h +++ b/launcher/ui/widgets/EnvironmentVariables.h @@ -31,11 +31,10 @@ class EnvironmentVariables : public QWidget { public: explicit EnvironmentVariables(QWidget* state = nullptr); ~EnvironmentVariables() override; - void initialize(bool instance, bool checked, bool override, const QMap& value); + void initialize(bool instance, bool override, const QMap& value); bool eventFilter(QObject* watched, QEvent* event) override; void retranslate(); - bool checked() const; bool override() const; QMap value() const; diff --git a/launcher/ui/widgets/EnvironmentVariables.ui b/launcher/ui/widgets/EnvironmentVariables.ui index 895b40d01..ded5b2ded 100644 --- a/launcher/ui/widgets/EnvironmentVariables.ui +++ b/launcher/ui/widgets/EnvironmentVariables.ui @@ -35,13 +35,6 @@ true - - - - &Ignore global settings - - - From bd11b93a0cb917e67dceac2f8eb03562f0f7bdb6 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 26 Oct 2023 21:01:24 +0100 Subject: [PATCH 34/79] Use hidden tab bar like other pages Signed-off-by: TheKodeToad --- launcher/ui/pages/global/EnvironmentVariablesPage.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/launcher/ui/pages/global/EnvironmentVariablesPage.cpp b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp index 2b76df362..2d44ed624 100644 --- a/launcher/ui/pages/global/EnvironmentVariablesPage.cpp +++ b/launcher/ui/pages/global/EnvironmentVariablesPage.cpp @@ -17,6 +17,7 @@ */ #include +#include #include #include "EnvironmentVariablesPage.h" @@ -24,10 +25,16 @@ EnvironmentVariablesPage::EnvironmentVariablesPage(QWidget* parent) : QWidget(parent) { auto verticalLayout = new QVBoxLayout(this); + verticalLayout->setObjectName(QStringLiteral("verticalLayout")); verticalLayout->setContentsMargins(0, 0, 0, 0); + + auto tabWidget = new QTabWidget(this); + tabWidget->setObjectName(QStringLiteral("tabWidget")); variables = new EnvironmentVariables(this); variables->setContentsMargins(6, 6, 6, 6); - verticalLayout->addWidget(variables); + tabWidget->addTab(variables, "Foo"); + tabWidget->tabBar()->hide(); + verticalLayout->addWidget(tabWidget); variables->initialize(false, false, APPLICATION->settings()->get("Env").toMap()); } From 364cb4ff6afccb2d9696a5a2363df0623beee0da Mon Sep 17 00:00:00 2001 From: IThundxr Date: Sat, 28 Oct 2023 07:39:32 -0400 Subject: [PATCH 35/79] chore: remove windows 7/8 support With 8.0 windows legacy support was dropped, this just removes it from the manifest Signed-off-by: IThundxr --- program_info/prismlauncher.manifest.in | 6 ------ 1 file changed, 6 deletions(-) diff --git a/program_info/prismlauncher.manifest.in b/program_info/prismlauncher.manifest.in index 6f4467c7d..fb28afc17 100644 --- a/program_info/prismlauncher.manifest.in +++ b/program_info/prismlauncher.manifest.in @@ -16,12 +16,6 @@ Custom Minecraft launcher for managing multiple installs. - - - - - - From 9dcb7e975921374274740e67632ca44dc0fe09da Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 28 Oct 2023 16:03:11 +0000 Subject: [PATCH 36/79] chore(deps): update korthout/backport-action action to v2 --- .github/workflows/backport.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index c705ff7b0..f9cf4fb7d 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -24,7 +24,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - name: Create backport PRs - uses: korthout/backport-action@v1.4.0 + uses: korthout/backport-action@v2.0.0 with: # Config README: https://github.com/korthout/backport-action#backport-action pull_description: |- From 54305397e45ec9f2c14b84eb782b541633b9dc3d Mon Sep 17 00:00:00 2001 From: LocalSpook <56512186+LocalSpook@users.noreply.github.com> Date: Sat, 28 Oct 2023 12:50:40 -0700 Subject: [PATCH 37/79] Localize sorting options for resource and shader packs Signed-off-by: LocalSpook <56512186+LocalSpook@users.noreply.github.com> --- launcher/modplatform/flame/FlameAPI.cpp | 20 +++++++++---------- launcher/modplatform/modrinth/ModrinthAPI.cpp | 14 ++++++------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/launcher/modplatform/flame/FlameAPI.cpp b/launcher/modplatform/flame/FlameAPI.cpp index e99ce3a56..bb4f18983 100644 --- a/launcher/modplatform/flame/FlameAPI.cpp +++ b/launcher/modplatform/flame/FlameAPI.cpp @@ -208,17 +208,15 @@ Task::Ptr FlameAPI::getFile(const QString& addonId, const QString& fileId, std:: return netJob; } -// https://docs.curseforge.com/?python#tocS_ModsSearchSortField -static QList s_sorts = { { 1, "Featured", QObject::tr("Sort by Featured") }, - { 2, "Popularity", QObject::tr("Sort by Popularity") }, - { 3, "LastUpdated", QObject::tr("Sort by Last Updated") }, - { 4, "Name", QObject::tr("Sort by Name") }, - { 5, "Author", QObject::tr("Sort by Author") }, - { 6, "TotalDownloads", QObject::tr("Sort by Downloads") }, - { 7, "Category", QObject::tr("Sort by Category") }, - { 8, "GameVersion", QObject::tr("Sort by Game Version") } }; - QList FlameAPI::getSortingMethods() const { - return s_sorts; + // https://docs.curseforge.com/?python#tocS_ModsSearchSortField + return { { 1, "Featured", QObject::tr("Sort by Featured") }, + { 2, "Popularity", QObject::tr("Sort by Popularity") }, + { 3, "LastUpdated", QObject::tr("Sort by Last Updated") }, + { 4, "Name", QObject::tr("Sort by Name") }, + { 5, "Author", QObject::tr("Sort by Author") }, + { 6, "TotalDownloads", QObject::tr("Sort by Downloads") }, + { 7, "Category", QObject::tr("Sort by Category") }, + { 8, "GameVersion", QObject::tr("Sort by Game Version") } }; } diff --git a/launcher/modplatform/modrinth/ModrinthAPI.cpp b/launcher/modplatform/modrinth/ModrinthAPI.cpp index f453f5cb9..8be963ecf 100644 --- a/launcher/modplatform/modrinth/ModrinthAPI.cpp +++ b/launcher/modplatform/modrinth/ModrinthAPI.cpp @@ -111,14 +111,12 @@ Task::Ptr ModrinthAPI::getProjects(QStringList addonIds, std::shared_ptr s_sorts = { { 1, "relevance", QObject::tr("Sort by Relevance") }, - { 2, "downloads", QObject::tr("Sort by Downloads") }, - { 3, "follows", QObject::tr("Sort by Follows") }, - { 4, "newest", QObject::tr("Sort by Last Updated") }, - { 5, "updated", QObject::tr("Sort by Newest") } }; - QList ModrinthAPI::getSortingMethods() const { - return s_sorts; + // https://docs.modrinth.com/api-spec/#tag/projects/operation/searchProjects + return { { 1, "relevance", QObject::tr("Sort by Relevance") }, + { 2, "downloads", QObject::tr("Sort by Downloads") }, + { 3, "follows", QObject::tr("Sort by Follows") }, + { 4, "newest", QObject::tr("Sort by Last Updated") }, + { 5, "updated", QObject::tr("Sort by Newest") } }; } From 55ac17c45b40f678f831b189a6d25a1f5344f73e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 29 Oct 2023 00:18:11 +0000 Subject: [PATCH 38/79] chore(nix): update lockfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nixpkgs': 'github:nixos/nixpkgs/44881e03af1c730cbb1d72a4d41274a2c957813a' (2023-10-21) → 'github:nixos/nixpkgs/808c0d8c53c7ae50f82aca8e7df263225cf235bf' (2023-10-26) • Updated input 'pre-commit-hooks': 'github:cachix/pre-commit-hooks.nix/8cc349bfd082da8782b989cad2158c9ad5bd70fd' (2023-10-19) → 'github:cachix/pre-commit-hooks.nix/bd38df3d508dfcdff52cd243d297f218ed2257bf' (2023-10-25) --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index d71403358..7cf901f77 100644 --- a/flake.lock +++ b/flake.lock @@ -106,11 +106,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1697886341, - "narHash": "sha256-AdE67xPty9M9wn36nPVp6aDntIdigrs7UbyaGv1VAaM=", + "lastModified": 1698336494, + "narHash": "sha256-sO72WDBKyijYD1GcKPlGsycKbMBiTJMBCnmOxLAs880=", "owner": "nixos", "repo": "nixpkgs", - "rev": "44881e03af1c730cbb1d72a4d41274a2c957813a", + "rev": "808c0d8c53c7ae50f82aca8e7df263225cf235bf", "type": "github" }, "original": { @@ -153,11 +153,11 @@ ] }, "locked": { - "lastModified": 1697746376, - "narHash": "sha256-gu77VkgdfaHgNCVufeb6WP9oqFLjwK4jHcoPZmBVF3E=", + "lastModified": 1698227354, + "narHash": "sha256-Fi5H9jbaQLmLw9qBi/mkR33CoFjNbobo5xWdX4tKz1Q=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "8cc349bfd082da8782b989cad2158c9ad5bd70fd", + "rev": "bd38df3d508dfcdff52cd243d297f218ed2257bf", "type": "github" }, "original": { From 5a54d80c6ee2ec05bcca0044d3936d5fa0e8d13d Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 30 Oct 2023 09:26:38 +0000 Subject: [PATCH 39/79] Fix group issues Signed-off-by: TheKodeToad --- launcher/InstanceList.cpp | 11 ++++++----- launcher/InstanceList.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp index 756ff93dd..111f8d8a4 100644 --- a/launcher/InstanceList.cpp +++ b/launcher/InstanceList.cpp @@ -290,8 +290,7 @@ void InstanceList::deleteGroup(const GroupId& name) qDebug() << "Remove" << instID << "from group" << name; removed = true; auto idx = getInstIndex(instance.get()); - if (idx > 0) - emit dataChanged(index(idx), index(idx), { GroupRole }); + emit dataChanged(index(idx), index(idx), { GroupRole }); } } if (removed) @@ -315,8 +314,7 @@ void InstanceList::renameGroup(const QString& src, const QString& dst) qDebug() << "Set" << instID << "group to" << dst; modified = true; auto idx = getInstIndex(instance.get()); - if (idx > 0) - emit dataChanged(index(idx), index(idx), { GroupRole }); + emit dataChanged(index(idx), index(idx), { GroupRole }); } } if (modified) @@ -947,9 +945,12 @@ QString InstanceList::getStagedInstancePath() bool InstanceList::commitStagedInstance(const QString& path, InstanceName const& instanceName, - const QString& groupName, + QString groupName, InstanceTask const& commiting) { + if (groupName.isEmpty() && !groupName.isNull()) + groupName = QString(); + QDir dir; QString instID; InstancePtr inst; diff --git a/launcher/InstanceList.h b/launcher/InstanceList.h index 6b0bcd810..5ddddee95 100644 --- a/launcher/InstanceList.h +++ b/launcher/InstanceList.h @@ -130,7 +130,7 @@ class InstanceList : public QAbstractListModel { * should_override is used when another similar instance already exists, and we want to override it * - for instance, when updating it. */ - bool commitStagedInstance(const QString& keyPath, const InstanceName& instanceName, const QString& groupName, const InstanceTask&); + bool commitStagedInstance(const QString& keyPath, const InstanceName& instanceName, QString groupName, const InstanceTask&); /** * Destroy a previously created staging area given by @keyPath - used when creation fails. From 2526275c5e124996b7a6b0465bad8b2bc9a1dffe Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 30 Oct 2023 09:51:37 +0000 Subject: [PATCH 40/79] Better check Signed-off-by: TheKodeToad --- launcher/InstanceList.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp index 111f8d8a4..2b8f34293 100644 --- a/launcher/InstanceList.cpp +++ b/launcher/InstanceList.cpp @@ -290,7 +290,8 @@ void InstanceList::deleteGroup(const GroupId& name) qDebug() << "Remove" << instID << "from group" << name; removed = true; auto idx = getInstIndex(instance.get()); - emit dataChanged(index(idx), index(idx), { GroupRole }); + if (idx >= 0) + emit dataChanged(index(idx), index(idx), { GroupRole }); } } if (removed) @@ -314,7 +315,8 @@ void InstanceList::renameGroup(const QString& src, const QString& dst) qDebug() << "Set" << instID << "group to" << dst; modified = true; auto idx = getInstIndex(instance.get()); - emit dataChanged(index(idx), index(idx), { GroupRole }); + if (idx >= 0) + emit dataChanged(index(idx), index(idx), { GroupRole }); } } if (modified) From 2349f29be01e1f6777f60a0397eab69650454c0d Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 2 Nov 2023 01:19:18 +0200 Subject: [PATCH 41/79] jsut a overflow protection Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index 1a3e52160..a14882097 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -113,7 +113,13 @@ class PixmapCache final : public QObject { if (m_consecutive_fast_evicitons >= m_consecutive_fast_evicitons_threshold) { // double the cache size auto newSize = _cacheLimit() * 2; - qDebug() << m_consecutive_fast_evicitons << "pixmap cache misses by eviction happened too fast, doubling cache size to" + if (newSize <= 0) { // double it until you overflow :D + qDebug() << m_consecutive_fast_evicitons + << tr("pixmap cache misses by eviction happened too fast, doing nothing as the cache size reached it's limit"); + m_consecutive_fast_evicitons = 0; + return true; + } + qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doubling cache size to") << newSize; _setCacheLimit(newSize); m_consecutive_fast_evicitons = 0; From 220a1de99a564602b9d043732b83b5d7c5545c25 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 2 Nov 2023 22:41:56 +0200 Subject: [PATCH 42/79] made sure that we do not relay for undefined behavior Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index a14882097..5f8212d74 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -5,6 +5,7 @@ #include #include #include +#include #define GET_TYPE() \ Qt::ConnectionType type; \ @@ -112,16 +113,16 @@ class PixmapCache final : public QObject { m_last_cache_miss_by_eviciton = now; if (m_consecutive_fast_evicitons >= m_consecutive_fast_evicitons_threshold) { // double the cache size - auto newSize = _cacheLimit() * 2; - if (newSize <= 0) { // double it until you overflow :D + auto newSize = _cacheLimit() * 2.L; + if (newSize >= std::numeric_limits::max()) { // double it until you overflow :D + newSize = std::numeric_limits::max(); qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doing nothing as the cache size reached it's limit"); - m_consecutive_fast_evicitons = 0; - return true; + } else { + qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doubling cache size to") + << static_cast(newSize); } - qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doubling cache size to") - << newSize; - _setCacheLimit(newSize); + _setCacheLimit(static_cast(newSize)); m_consecutive_fast_evicitons = 0; return true; } From 127a31ba3a468f8ad9fcedc29befea78ad381657 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 3 Nov 2023 10:31:40 +0200 Subject: [PATCH 43/79] Added warning for remove account Signed-off-by: Trial97 --- launcher/ui/pages/global/AccountListPage.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index 50f3ff2b6..6fd6112d4 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -42,22 +42,17 @@ #include -#include "net/NetJob.h" - #include "ui/dialogs/CustomMessageBox.h" #include "ui/dialogs/MSALoginDialog.h" #include "ui/dialogs/OfflineLoginDialog.h" #include "ui/dialogs/ProgressDialog.h" #include "ui/dialogs/SkinUploadDialog.h" -#include "minecraft/auth/AccountTask.h" #include "minecraft/services/SkinDelete.h" #include "tasks/Task.h" #include "Application.h" -#include "BuildConfig.h" - AccountListPage::AccountListPage(QWidget* parent) : QMainWindow(parent), ui(new Ui::AccountListPage) { ui->setupUi(this); @@ -172,6 +167,12 @@ void AccountListPage::on_actionAddOffline_triggered() void AccountListPage::on_actionRemove_triggered() { + auto response = CustomMessageBox::selectable(this, tr("Remove account?"), tr("Do you realy want to delete this account?"), + QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) + ->exec(); + if (response != QMessageBox::Yes) { + return; + } QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); if (selection.size() > 0) { QModelIndex selected = selection.first(); From b18082376ddc90eab4176ff88a10683d3b38ecff Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 3 Nov 2023 11:04:13 +0200 Subject: [PATCH 44/79] Fixed visual bug with Modlist export Signed-off-by: Trial97 --- launcher/ui/dialogs/ExportToModListDialog.cpp | 7 +++--- launcher/ui/dialogs/ExportToModListDialog.ui | 23 +++++++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/launcher/ui/dialogs/ExportToModListDialog.cpp b/launcher/ui/dialogs/ExportToModListDialog.cpp index c811bfe6a..a343f555a 100644 --- a/launcher/ui/dialogs/ExportToModListDialog.cpp +++ b/launcher/ui/dialogs/ExportToModListDialog.cpp @@ -214,10 +214,11 @@ void ExportToModListDialog::addExtra(ExportToModList::OptionalData option) void ExportToModListDialog::enableCustom(bool enabled) { ui->authorsCheckBox->setHidden(enabled); - ui->versionCheckBox->setHidden(enabled); - ui->urlCheckBox->setHidden(enabled); - ui->authorsButton->setHidden(!enabled); + + ui->versionCheckBox->setHidden(enabled); ui->versionButton->setHidden(!enabled); + + ui->urlCheckBox->setHidden(enabled); ui->urlButton->setHidden(!enabled); } diff --git a/launcher/ui/dialogs/ExportToModListDialog.ui b/launcher/ui/dialogs/ExportToModListDialog.ui index 25eb43429..4f8ab52b5 100644 --- a/launcher/ui/dialogs/ExportToModListDialog.ui +++ b/launcher/ui/dialogs/ExportToModListDialog.ui @@ -7,7 +7,7 @@ 0 0 650 - 446 + 522 @@ -61,18 +61,37 @@ + + + 0 + 0 + + Template - + + + + 0 + 0 + + + + + + 0 + 0 + + Optional Info From 1bd69ecbb286df9d14a76d2dcb8a635d7895f154 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Fri, 3 Nov 2023 11:42:40 +0200 Subject: [PATCH 45/79] Update launcher/ui/pages/global/AccountListPage.cpp Co-authored-by: TheKodeToad Signed-off-by: Alexandru Ionut Tripon --- launcher/ui/pages/global/AccountListPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index 6fd6112d4..3a21cdd9b 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -167,7 +167,7 @@ void AccountListPage::on_actionAddOffline_triggered() void AccountListPage::on_actionRemove_triggered() { - auto response = CustomMessageBox::selectable(this, tr("Remove account?"), tr("Do you realy want to delete this account?"), + auto response = CustomMessageBox::selectable(this, tr("Remove account?"), tr("Do you really want to delete this account?"), QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ->exec(); if (response != QMessageBox::Yes) { From 0f95bf1e424e3ebd7f1450461d554f54c71c5f33 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sat, 4 Nov 2023 12:08:49 +0200 Subject: [PATCH 46/79] Updated readme Signed-off-by: Trial97 --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 61bf4c20b..e3457c7ed 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,18 @@ - All downloads and instructions for Prism Launcher can be found on our [Website](https://prismlauncher.org/download). -- Last build status can be found in the [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions). +- Last build status can be found in the [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) (this also includes the pull requests status). ### Development Builds -There are development builds available [here](https://github.com/PrismLauncher/PrismLauncher/actions). These have debug information in the binaries, so their file sizes are relatively larger. +Please understand that these builds are not intended for most users. There may be bugs, and other instabilities. You have been warned. + +There are development builds available on: + +- [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) includes builds from pull requests opened by contribuitors. +- [nightly.link](https://nightly.link/PrismLauncher/PrismLauncher/workflows/trigger_builds/develop) this will allways point only to the latest develop. + +These have debug information in the binaries, so their file sizes are relatively larger. Prebuilt Development builds are provided for **Linux**, **Windows** and **macOS**. From 40ebae394afe7ba426a67615e7a658f07ea76297 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 5 Nov 2023 00:18:56 +0000 Subject: [PATCH 47/79] chore(nix): update lockfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'flake-parts': 'github:hercules-ci/flake-parts/c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4' (2023-10-03) → 'github:hercules-ci/flake-parts/8c9fa2545007b49a5db5f650ae91f227672c3877' (2023-11-01) • Updated input 'flake-parts/nixpkgs-lib': 'github:NixOS/nixpkgs/f5892ddac112a1e9b3612c39af1b72987ee5783a?dir=lib' (2023-09-29) → 'github:NixOS/nixpkgs/0cbe9f69c234a7700596e943bfae7ef27a31b735?dir=lib' (2023-10-29) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/808c0d8c53c7ae50f82aca8e7df263225cf235bf' (2023-10-26) → 'github:nixos/nixpkgs/9d5d25bbfe8c0297ebe85324addcb5020ed1a454' (2023-11-04) • Updated input 'pre-commit-hooks': 'github:cachix/pre-commit-hooks.nix/bd38df3d508dfcdff52cd243d297f218ed2257bf' (2023-10-25) → 'github:cachix/pre-commit-hooks.nix/dec10399e5b56aa95fcd530e0338be72ad6462a0' (2023-11-01) --- flake.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index 7cf901f77..a520c27e5 100644 --- a/flake.lock +++ b/flake.lock @@ -21,11 +21,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1696343447, - "narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=", + "lastModified": 1698882062, + "narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4", + "rev": "8c9fa2545007b49a5db5f650ae91f227672c3877", "type": "github" }, "original": { @@ -106,11 +106,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1698336494, - "narHash": "sha256-sO72WDBKyijYD1GcKPlGsycKbMBiTJMBCnmOxLAs880=", + "lastModified": 1699094435, + "narHash": "sha256-YLZ5/KKZ1PyLrm2MO8UxRe4H3M0/oaYqNhSlq6FDeeA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "808c0d8c53c7ae50f82aca8e7df263225cf235bf", + "rev": "9d5d25bbfe8c0297ebe85324addcb5020ed1a454", "type": "github" }, "original": { @@ -123,11 +123,11 @@ "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1696019113, - "narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=", + "lastModified": 1698611440, + "narHash": "sha256-jPjHjrerhYDy3q9+s5EAsuhyhuknNfowY6yt6pjn9pc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a", + "rev": "0cbe9f69c234a7700596e943bfae7ef27a31b735", "type": "github" }, "original": { @@ -153,11 +153,11 @@ ] }, "locked": { - "lastModified": 1698227354, - "narHash": "sha256-Fi5H9jbaQLmLw9qBi/mkR33CoFjNbobo5xWdX4tKz1Q=", + "lastModified": 1698852633, + "narHash": "sha256-Hsc/cCHud8ZXLvmm8pxrXpuaPEeNaaUttaCvtdX/Wug=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "bd38df3d508dfcdff52cd243d297f218ed2257bf", + "rev": "dec10399e5b56aa95fcd530e0338be72ad6462a0", "type": "github" }, "original": { From cf4144cb5022db62c97d35b9917ade9947110d16 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 4 Nov 2023 15:22:43 -0400 Subject: [PATCH 48/79] Fixed link to Fulmine's website Signed-off-by: Alex --- launcher/ui/dialogs/AboutDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/dialogs/AboutDialog.cpp b/launcher/ui/dialogs/AboutDialog.cpp index f5eaff7a1..cee01e821 100644 --- a/launcher/ui/dialogs/AboutDialog.cpp +++ b/launcher/ui/dialogs/AboutDialog.cpp @@ -101,7 +101,7 @@ QString getCreditsHtml() stream << "

" << QObject::tr("With thanks to", "About Credits") << "

\n"; stream << QString("

Boba %1

\n").arg(getWebsite("https://bobaonline.neocities.org/")); stream << QString("

Davi Rafael %1

\n").arg(getWebsite("https://auti.one/")); - stream << QString("

Fulmine %1

\n").arg(getWebsite("https://www.fulmine.xyz/")); + stream << QString("

Fulmine %1

\n").arg(getWebsite("https://fulmine.xyz/")); stream << QString("

ely %1

\n").arg(getGitHub("elyrodso")); stream << QString("

gon sawa %1

\n").arg(getGitHub("gonsawa")); stream << QString("

Pankakes

\n"); From 64bbcb2834a7974d2c329180add799a728a856f9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 5 Nov 2023 15:57:06 +0000 Subject: [PATCH 49/79] chore(deps): update korthout/backport-action action to v2.1.0 --- .github/workflows/backport.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index f9cf4fb7d..6f2025551 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -24,7 +24,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - name: Create backport PRs - uses: korthout/backport-action@v2.0.0 + uses: korthout/backport-action@v2.1.0 with: # Config README: https://github.com/korthout/backport-action#backport-action pull_description: |- From d2a85cb580f47ab181d65d13d18de2a96e297471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgars=20C=C4=ABrulis?= Date: Sun, 5 Nov 2023 17:41:53 +0000 Subject: [PATCH 50/79] visual: Fix spacing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Edgars Cīrulis --- launcher/LaunchController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index 9fb385777..f59cdeda8 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -89,7 +89,7 @@ void LaunchController::decideAccount() // Tell the user they need to log in at least one account in order to play. auto reply = CustomMessageBox::selectable(m_parentWidget, tr("No Accounts"), tr("In order to play Minecraft, you must have at least one Microsoft " - "account which owns Minecraft logged in." + "account which owns Minecraft logged in. " "Would you like to open the account manager to add an account now?"), QMessageBox::Information, QMessageBox::Yes | QMessageBox::No) ->exec(); From 710a48fcafdfd70c13077ea26a57dfb1aa375079 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 5 Nov 2023 21:41:10 +0200 Subject: [PATCH 51/79] changed type form double long to long long Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index 5f8212d74..a1447fd5a 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -113,7 +113,7 @@ class PixmapCache final : public QObject { m_last_cache_miss_by_eviciton = now; if (m_consecutive_fast_evicitons >= m_consecutive_fast_evicitons_threshold) { // double the cache size - auto newSize = _cacheLimit() * 2.L; + auto newSize = _cacheLimit() * 2ll; if (newSize >= std::numeric_limits::max()) { // double it until you overflow :D newSize = std::numeric_limits::max(); qDebug() << m_consecutive_fast_evicitons From 9a8667e99cdfd9608f8aa543b432bacc672a45e4 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 5 Nov 2023 22:22:49 +0200 Subject: [PATCH 52/79] Added Global Dependenicies toggle Signed-off-by: Trial97 --- launcher/Application.cpp | 1 + launcher/ui/dialogs/ModUpdateDialog.cpp | 2 +- launcher/ui/dialogs/ResourceDownloadDialog.cpp | 14 ++++++++------ launcher/ui/pages/global/LauncherPage.cpp | 2 ++ launcher/ui/pages/global/LauncherPage.ui | 10 ++++++++++ launcher/ui/pages/instance/ModFolderPage.cpp | 4 ++++ 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 661c6c5be..be252f1c5 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -644,6 +644,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) // Minecraft mods m_settings->registerSetting("ModMetadataDisabled", false); + m_settings->registerSetting("ModDependenciesDisabled", false); // Minecraft offline player name m_settings->registerSetting("LastOfflinePlayerName", ""); diff --git a/launcher/ui/dialogs/ModUpdateDialog.cpp b/launcher/ui/dialogs/ModUpdateDialog.cpp index 1a70ea59a..298bdad97 100644 --- a/launcher/ui/dialogs/ModUpdateDialog.cpp +++ b/launcher/ui/dialogs/ModUpdateDialog.cpp @@ -186,7 +186,7 @@ void ModUpdateDialog::checkCandidates() } } - { // dependencies + if (!APPLICATION->settings()->get("ModDependenciesDisabled").toBool()) { // dependencies auto depTask = makeShared(this, m_instance, m_mod_model.get(), selectedVers); connect(depTask.get(), &Task::failed, this, diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp index dc7cfff06..1431ea92c 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp +++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp @@ -270,13 +270,15 @@ QList ModDownloadDialog::getPages() GetModDependenciesTask::Ptr ModDownloadDialog::getModDependenciesTask() { - if (auto model = dynamic_cast(getBaseModel().get()); model) { - QList> selectedVers; - for (auto& selected : getTasks()) { - selectedVers.append(std::make_shared(selected->getPack(), selected->getVersion())); - } + if (!APPLICATION->settings()->get("ModDependenciesDisabled").toBool()) { // dependencies + if (auto model = dynamic_cast(getBaseModel().get()); model) { + QList> selectedVers; + for (auto& selected : getTasks()) { + selectedVers.append(std::make_shared(selected->getPack(), selected->getVersion())); + } - return makeShared(this, m_instance, model, selectedVers); + return makeShared(this, m_instance, model, selectedVers); + } } return nullptr; } diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index 6d8c65ec5..d15883db5 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -223,6 +223,7 @@ void LauncherPage::applySettings() // Mods s->set("ModMetadataDisabled", ui->metadataDisableBtn->isChecked()); + s->set("ModDependenciesDisabled", ui->dependenciesDisableBtn->isChecked()); } void LauncherPage::loadSettings() { @@ -278,6 +279,7 @@ void LauncherPage::loadSettings() // Mods ui->metadataDisableBtn->setChecked(s->get("ModMetadataDisabled").toBool()); ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked()); + ui->dependenciesDisableBtn->setChecked(s->get("ModDependenciesDisabled").toBool()); } void LauncherPage::refreshFontPreview() diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 250a8bc88..637b2cd81 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -186,6 +186,16 @@
+ + + + Disable mod dependencies checking. + + + Disable mod dependencies checking + + +
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 625d37933..8d99256b9 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -214,6 +214,10 @@ void ModFolderPage::updateMods() QMessageBox::critical(this, tr("Error"), tr("Please install a mod loader first!")); return; } + if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) { + QMessageBox::critical(this, tr("Error"), tr("The mod update is disabled when the metadata is disabled!")); + return; + } auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); auto mods_list = m_model->selectedMods(selection); From bd9d5e09907071d2a2576add9c99314e6c52ed20 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sun, 5 Nov 2023 20:31:48 +0000 Subject: [PATCH 53/79] Reword Signed-off-by: TheKodeToad --- launcher/ui/pages/global/LauncherPage.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 637b2cd81..32d89ee51 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -189,10 +189,10 @@ - Disable mod dependencies checking. + Disable automatically checking and installation of mod dependencies. - Disable mod dependencies checking + Do not install mod dependencies From 902e861fc68b658d999476f273f4a15fe4207672 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Sun, 5 Nov 2023 23:41:26 +0200 Subject: [PATCH 54/79] Apply suggestions from code review Co-authored-by: seth Signed-off-by: Alexandru Ionut Tripon --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e3457c7ed..b32132d49 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,16 @@ - All downloads and instructions for Prism Launcher can be found on our [Website](https://prismlauncher.org/download). -- Last build status can be found in the [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) (this also includes the pull requests status). +- Last build status can be found in the [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) tab (this also includes the pull requests status). ### Development Builds Please understand that these builds are not intended for most users. There may be bugs, and other instabilities. You have been warned. -There are development builds available on: +There are development builds available through: -- [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) includes builds from pull requests opened by contribuitors. -- [nightly.link](https://nightly.link/PrismLauncher/PrismLauncher/workflows/trigger_builds/develop) this will allways point only to the latest develop. +- [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) (includes builds from pull requests opened by contribuitors) +- [nightly.link](https://nightly.link/PrismLauncher/PrismLauncher/workflows/trigger_builds/develop) (this will always point only to the latest version of develop) These have debug information in the binaries, so their file sizes are relatively larger. From 3e7f9083cab97489aab958d3bbc649b24d58abb6 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Sun, 5 Nov 2023 23:41:54 +0200 Subject: [PATCH 55/79] Update launcher/ui/pages/instance/ModFolderPage.cpp Co-authored-by: seth Signed-off-by: Alexandru Ionut Tripon --- launcher/ui/pages/instance/ModFolderPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 8d99256b9..f45f8b4b3 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -215,7 +215,7 @@ void ModFolderPage::updateMods() return; } if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) { - QMessageBox::critical(this, tr("Error"), tr("The mod update is disabled when the metadata is disabled!")); + QMessageBox::critical(this, tr("Error"), tr("Mod updates are unavailable when metadata is disabled!")); return; } auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); From 867e6223ce5601ea32e8fc471d5dc3e13e32e276 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 5 Nov 2023 23:48:26 +0200 Subject: [PATCH 56/79] Fixed mangoHub loading Signed-off-by: Trial97 --- launcher/minecraft/MinecraftInstance.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 170561f11..7cb4100ea 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -575,15 +575,20 @@ QProcessEnvironment MinecraftInstance::createLaunchEnvironment() #ifdef Q_OS_LINUX if (settings()->get("EnableMangoHud").toBool() && APPLICATION->capabilities() & Application::SupportsMangoHud) { - auto preloadList = env.value("LD_PRELOAD").split(QLatin1String(":")); - auto libPaths = env.value("LD_LIBRARY_PATH").split(QLatin1String(":")); + QStringList preloadList; + if (auto value = env.value("LD_PRELOAD"); !value.isEmpty()) + preloadList = value.split(QLatin1String(":")); + QStringList libPaths; + if (auto value = env.value("LD_LIBRARY_PATH"); !value.isEmpty()) + libPaths = value.split(QLatin1String(":")); auto mangoHudLibString = MangoHud::getLibraryString(); if (!mangoHudLibString.isEmpty()) { QFileInfo mangoHudLib(mangoHudLibString); // dlsym variant is only needed for OpenGL and not included in the vulkan layer - preloadList << "libMangoHud_dlsym.so" << mangoHudLib.fileName(); + preloadList << "libMangoHud_dlsym.so" + << "libMangoHud_opengl.so" << mangoHudLib.fileName(); libPaths << mangoHudLib.absolutePath(); } From cc291219f9c937ec69402f7b88b79d1f33927ba3 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 6 Nov 2023 10:51:34 +0200 Subject: [PATCH 57/79] apply suggested changes Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index a1447fd5a..da9500788 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -101,10 +101,14 @@ class PixmapCache final : public QObject { */ bool _markCacheMissByEviciton() { + static constexpr int maxInt = std::numeric_limits::max(); + static constexpr uint oneMB = 1000; + static constexpr int oneSecond = 1000; + auto now = QTime::currentTime(); if (!m_last_cache_miss_by_eviciton.isNull()) { auto diff = m_last_cache_miss_by_eviciton.msecsTo(now); - if (diff < 1000) { // less than a second ago + if (diff < oneSecond) { // less than a second ago ++m_consecutive_fast_evicitons; } else { m_consecutive_fast_evicitons = 0; @@ -112,10 +116,10 @@ class PixmapCache final : public QObject { } m_last_cache_miss_by_eviciton = now; if (m_consecutive_fast_evicitons >= m_consecutive_fast_evicitons_threshold) { - // double the cache size - auto newSize = _cacheLimit() * 2ll; - if (newSize >= std::numeric_limits::max()) { // double it until you overflow :D - newSize = std::numeric_limits::max(); + // increase the cache size + uint newSize = _cacheLimit() + oneMB; + if (newSize >= maxInt) { // increase it until you overflow :D + newSize = maxInt; qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doing nothing as the cache size reached it's limit"); } else { From 670e91cb6072d42f74e501cfaeadbb49a8f171b4 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 6 Nov 2023 11:08:18 +0200 Subject: [PATCH 58/79] Increased the step to around 10MB Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index da9500788..eab6a70ec 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -102,7 +102,7 @@ class PixmapCache final : public QObject { bool _markCacheMissByEviciton() { static constexpr int maxInt = std::numeric_limits::max(); - static constexpr uint oneMB = 1000; + static constexpr uint step = 10240; static constexpr int oneSecond = 1000; auto now = QTime::currentTime(); @@ -117,7 +117,7 @@ class PixmapCache final : public QObject { m_last_cache_miss_by_eviciton = now; if (m_consecutive_fast_evicitons >= m_consecutive_fast_evicitons_threshold) { // increase the cache size - uint newSize = _cacheLimit() + oneMB; + uint newSize = _cacheLimit() + step; if (newSize >= maxInt) { // increase it until you overflow :D newSize = maxInt; qDebug() << m_consecutive_fast_evicitons From ca226d2ab5c3fb88d2e4a69ae94d2393960e9713 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 6 Nov 2023 11:24:19 +0200 Subject: [PATCH 59/79] Fixed comparation warning Signed-off-by: Trial97 --- launcher/MTPixmapCache.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/launcher/MTPixmapCache.h b/launcher/MTPixmapCache.h index eab6a70ec..b6bd13045 100644 --- a/launcher/MTPixmapCache.h +++ b/launcher/MTPixmapCache.h @@ -101,7 +101,7 @@ class PixmapCache final : public QObject { */ bool _markCacheMissByEviciton() { - static constexpr int maxInt = std::numeric_limits::max(); + static constexpr uint maxInt = static_cast(std::numeric_limits::max()); static constexpr uint step = 10240; static constexpr int oneSecond = 1000; @@ -123,8 +123,8 @@ class PixmapCache final : public QObject { qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doing nothing as the cache size reached it's limit"); } else { - qDebug() << m_consecutive_fast_evicitons << tr("pixmap cache misses by eviction happened too fast, doubling cache size to") - << static_cast(newSize); + qDebug() << m_consecutive_fast_evicitons + << tr("pixmap cache misses by eviction happened too fast, increasing cache size to") << static_cast(newSize); } _setCacheLimit(static_cast(newSize)); m_consecutive_fast_evicitons = 0; From 6506e93e4a74eb859fb41ff3fd90adbc11f5727f Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 7 Nov 2023 09:44:27 +0200 Subject: [PATCH 60/79] Removed some buttons Signed-off-by: Trial97 --- .../pages/instance/ExternalResourcesPage.ui | 33 ++----- launcher/ui/pages/instance/ModFolderPage.cpp | 91 ++++++++++++------- 2 files changed, 65 insertions(+), 59 deletions(-) diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.ui b/launcher/ui/pages/instance/ExternalResourcesPage.ui index b9a8e4963..ff08e12d2 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.ui +++ b/launcher/ui/pages/instance/ExternalResourcesPage.ui @@ -70,6 +70,9 @@
+ + true + Actions @@ -146,28 +149,6 @@ Download a new resource - - - false - - - Check for &Updates - - - Try to check or update all selected resources (all resources if none are selected) - - - - - false - - - &Verify Dependencies - - - Try to update and check for missing dependencies all selected resources (all resources if none are selected) - - false @@ -179,15 +160,15 @@ Go to mods home page - + - false + true - Remove metadata + Check for &Updates - Remove mod's metadata + Try to check or update all selected resources (all resources if none are selected) diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index daf9b635f..efe8092bb 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -84,52 +84,77 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr connect(ui->actionDownloadItem, &QAction::triggered, this, &ModFolderPage::installMods); - ui->actionUpdateItem->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); - ui->actionsToolbar->insertActionAfter(ui->actionAddItem, ui->actionUpdateItem); - connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods); + auto updateMenu = ui->actionUpdateItem->menu(); + if (updateMenu) { + updateMenu->clear(); + } else { + updateMenu = new QMenu(this); + } - ui->actionUpdateDepsItem->setToolTip( - tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)")); - ui->actionsToolbar->insertActionAfter(ui->actionUpdateItem, ui->actionUpdateDepsItem); - connect(ui->actionUpdateDepsItem, &QAction::triggered, this, [this] { updateMods(true); }); + { + auto update = updateMenu->addAction(tr("Check for Updates")); + update->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); + connect(update, &QAction::triggered, this, &ModFolderPage::updateMods); + } + { + auto updateWithDeps = updateMenu->addAction(tr("Verify Dependencies")); + updateWithDeps->setToolTip( + tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)")); + connect(updateWithDeps, &QAction::triggered, this, [this] { updateMods(true); }); + } + ui->actionUpdateItem->setMenu(updateMenu); + + ui->actionUpdateItem->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); + connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods); + ui->actionsToolbar->insertActionBefore(ui->actionAddItem, ui->actionUpdateItem); ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page")); ui->actionsToolbar->addAction(ui->actionVisitItemPage); connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages); - ui->actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); - ui->actionsToolbar->insertActionAfter(ui->actionRemoveItem, ui->actionRemoveItemMetadata); - connect(ui->actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata); + auto removeMenu = ui->actionRemoveItem->menu(); + if (removeMenu) { + removeMenu->clear(); + } else { + removeMenu = new QMenu(this); + } + { + auto remove = removeMenu->addAction("Remove"); + remove->setToolTip(tr("Remove selected item")); + connect(remove, &QAction::triggered, this, &ModFolderPage::removeItem); + } + auto actionRemoveItemMetadata = removeMenu->addAction(tr("Remove metadata")); + actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); + connect(actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata); + + ui->actionRemoveItem->setMenu(removeMenu); auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); }; - connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, check_allow_update] { - ui->actionUpdateItem->setEnabled(check_allow_update()); - ui->actionUpdateDepsItem->setEnabled(check_allow_update()); + connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, + [this, check_allow_update, actionRemoveItemMetadata] { + ui->actionUpdateItem->setEnabled(check_allow_update()); - auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); - auto mods_list = m_model->selectedMods(selection); - auto selected = std::count_if(mods_list.cbegin(), mods_list.cend(), - [](Mod* v) { return v->metadata() != nullptr || v->homeurl().size() != 0; }); - if (selected <= 1) { - ui->actionVisitItemPage->setText(tr("Visit mod's page")); - ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page")); + auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); + auto mods_list = m_model->selectedMods(selection); + auto selected = std::count_if(mods_list.cbegin(), mods_list.cend(), + [](Mod* v) { return v->metadata() != nullptr || v->homeurl().size() != 0; }); + if (selected <= 1) { + ui->actionVisitItemPage->setText(tr("Visit mod's page")); + ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page")); - ui->actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); - } else { - ui->actionVisitItemPage->setText(tr("Visit mods' pages")); - ui->actionVisitItemPage->setToolTip(tr("Go to the pages of the selected mods")); + actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); + } else { + ui->actionVisitItemPage->setText(tr("Visit mods' pages")); + ui->actionVisitItemPage->setToolTip(tr("Go to the pages of the selected mods")); - ui->actionRemoveItemMetadata->setToolTip(tr("Remove mods' metadata")); - } - ui->actionVisitItemPage->setEnabled(selected != 0); - ui->actionRemoveItemMetadata->setEnabled(selected != 0); - }); + actionRemoveItemMetadata->setToolTip(tr("Remove mods' metadata")); + } + ui->actionVisitItemPage->setEnabled(selected != 0); + actionRemoveItemMetadata->setEnabled(selected != 0); + }); - auto updateButtons = [this, check_allow_update] { - ui->actionUpdateItem->setEnabled(check_allow_update()); - ui->actionUpdateDepsItem->setEnabled(check_allow_update()); - }; + auto updateButtons = [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); }; connect(mods.get(), &ModFolderModel::rowsInserted, this, updateButtons); connect(mods.get(), &ModFolderModel::rowsRemoved, this, updateButtons); From 5d5adbd7da9bbead583ecec0904c5527508acd63 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 7 Nov 2023 09:48:07 +0200 Subject: [PATCH 61/79] add update menu conditionaly Signed-off-by: Trial97 --- launcher/ui/pages/instance/ModFolderPage.cpp | 36 +++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index efe8092bb..a2fe19a87 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -84,25 +84,27 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr connect(ui->actionDownloadItem, &QAction::triggered, this, &ModFolderPage::installMods); - auto updateMenu = ui->actionUpdateItem->menu(); - if (updateMenu) { - updateMenu->clear(); - } else { - updateMenu = new QMenu(this); - } + if (!APPLICATION->settings()->get("ModDependenciesDisabled").toBool()) { // dependencies + auto updateMenu = ui->actionUpdateItem->menu(); + if (updateMenu) { + updateMenu->clear(); + } else { + updateMenu = new QMenu(this); + } - { - auto update = updateMenu->addAction(tr("Check for Updates")); - update->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); - connect(update, &QAction::triggered, this, &ModFolderPage::updateMods); + { + auto update = updateMenu->addAction(tr("Check for Updates")); + update->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); + connect(update, &QAction::triggered, this, &ModFolderPage::updateMods); + } + { + auto updateWithDeps = updateMenu->addAction(tr("Verify Dependencies")); + updateWithDeps->setToolTip( + tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)")); + connect(updateWithDeps, &QAction::triggered, this, [this] { updateMods(true); }); + } + ui->actionUpdateItem->setMenu(updateMenu); } - { - auto updateWithDeps = updateMenu->addAction(tr("Verify Dependencies")); - updateWithDeps->setToolTip( - tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)")); - connect(updateWithDeps, &QAction::triggered, this, [this] { updateMods(true); }); - } - ui->actionUpdateItem->setMenu(updateMenu); ui->actionUpdateItem->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods); From c78d35d699bf204008da5eb73ed8c4efe510258d Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 7 Nov 2023 10:20:53 +0200 Subject: [PATCH 62/79] added additional minecraft java path for windows Signed-off-by: Trial97 --- launcher/java/JavaUtils.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index 10bbb1f1b..615608ca3 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -34,6 +34,7 @@ */ #include +#include #include #include @@ -440,18 +441,26 @@ QStringList getMinecraftJavaBundle() { QString partialPath; QString executable = "java"; + QStringList processpaths; #if defined(Q_OS_OSX) partialPath = FS::PathCombine(QDir::homePath(), "Library/Application Support"); #elif defined(Q_OS_WIN32) partialPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", ""); executable += "w.exe"; + + // add the following to the search + // C:\Users\USERNAME\AppData\Local\Packages\Microsoft.4297127D64EC6_8wekyb3d8bbwe\LocalCache\Local\runtime + auto minecraftInstaltionPath = + FS::PathCombine(QFileInfo(partialPath).absolutePath(), "Local", "Packages", "Microsoft.4297127D64EC6_8wekyb3d8bbwe"); + minecraftInstaltionPath = FS::PathCombine(minecraftInstaltionPath, "LocalCache", "Local", "runtime"); + processpaths << minecraftInstaltionPath; #else partialPath = QDir::homePath(); #endif - auto minecraftPath = FS::PathCombine(partialPath, ".minecraft", "runtime"); - QStringList javas; - QStringList processpaths{ minecraftPath }; + auto minecraftDataPath = FS::PathCombine(partialPath, ".minecraft", "runtime"); + processpaths << minecraftDataPath; + QStringList javas; while (!processpaths.isEmpty()) { auto dirPath = processpaths.takeFirst(); QDir dir(dirPath); From 8897f16d1dd2d0736d9d50a99f8395c1eb1f2ac0 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 7 Nov 2023 10:52:52 +0200 Subject: [PATCH 63/79] simplify microsoft login Signed-off-by: Trial97 --- launcher/ui/dialogs/MSALoginDialog.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp index 74fff9fd3..5dba84858 100644 --- a/launcher/ui/dialogs/MSALoginDialog.cpp +++ b/launcher/ui/dialogs/MSALoginDialog.cpp @@ -105,8 +105,17 @@ void MSALoginDialog::showVerificationUriAndCode(const QUrl& uri, const QString& QString urlString = uri.toString(); QString linkString = QString("%2").arg(urlString, urlString); - ui->label->setText( - tr("

Please open up %1 in a browser and put in the code %2 to proceed with login.

").arg(linkString, code)); + if (urlString == "https://www.microsoft.com/link" && !code.isEmpty()) { + urlString += QString("?otc=%1").arg(code); + DesktopServices::openUrl(urlString); + ui->label->setText( + tr("

Please login in the opened browser. If no browser was opened please follow the following instructions:

" + "

Please open up %1 in a browser and put in the code %2 to proceed with login.

") + .arg(linkString, code)); + } else { + ui->label->setText( + tr("

Please open up %1 in a browser and put in the code %2 to proceed with login.

").arg(linkString, code)); + } ui->actionButton->setVisible(true); connect(ui->actionButton, &QPushButton::clicked, [=]() { DesktopServices::openUrl(uri); From 9ada8d906d522ec92cee58dc016e3d51f33d963d Mon Sep 17 00:00:00 2001 From: Hazel Hofmann Date: Tue, 7 Nov 2023 14:54:04 +0100 Subject: [PATCH 64/79] Use same categories as main desktop entry --- launcher/FileSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 00a6ee539..bbd8d82e2 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -872,7 +872,7 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri << "\n"; stream << "Type=Application" << "\n"; - stream << "Categories=Game" + stream << "Categories=Game;ActionGame;AdventureGame;Simulation;" << "\n"; stream << "Exec=\"" << target.toLocal8Bit() << "\"" << argstring.toLocal8Bit() << "\n"; stream << "Name=" << name.toLocal8Bit() << "\n"; From 1dea83580eb673e07d7864d56405008551a9bc26 Mon Sep 17 00:00:00 2001 From: Hazel Hofmann Date: Tue, 7 Nov 2023 15:05:56 +0100 Subject: [PATCH 65/79] DCO Remediation Commit for Hazel Hofmann I, Hazel Hofmann , hereby add my Signed-off-by to this commit: 9ada8d906d522ec92cee58dc016e3d51f33d963d Signed-off-by: Hazel Hofmann --- launcher/FileSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index bbd8d82e2..469932374 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -872,7 +872,7 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri << "\n"; stream << "Type=Application" << "\n"; - stream << "Categories=Game;ActionGame;AdventureGame;Simulation;" + stream << "Categories=Game;ActionGame;AdventureGame;Simulation" << "\n"; stream << "Exec=\"" << target.toLocal8Bit() << "\"" << argstring.toLocal8Bit() << "\n"; stream << "Name=" << name.toLocal8Bit() << "\n"; From 54187a505f500231a55cbceba26d6dc605fe6b30 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Tue, 7 Nov 2023 20:39:12 +0200 Subject: [PATCH 66/79] Update launcher/ui/dialogs/MSALoginDialog.cpp Co-authored-by: Tayou Signed-off-by: Alexandru Ionut Tripon --- launcher/ui/dialogs/MSALoginDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp index 5dba84858..e36a574f3 100644 --- a/launcher/ui/dialogs/MSALoginDialog.cpp +++ b/launcher/ui/dialogs/MSALoginDialog.cpp @@ -109,8 +109,8 @@ void MSALoginDialog::showVerificationUriAndCode(const QUrl& uri, const QString& urlString += QString("?otc=%1").arg(code); DesktopServices::openUrl(urlString); ui->label->setText( - tr("

Please login in the opened browser. If no browser was opened please follow the following instructions:

" - "

Please open up %1 in a browser and put in the code %2 to proceed with login.

") + tr("

Please login in the opened browser. If no browser was opened please open up %1 in " + "a browser and put in the code %2 to proceed with login.

") .arg(linkString, code)); } else { ui->label->setText( From 4dc9e658750e5b0cab23ff7492db20fce6bc49d3 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 7 Nov 2023 20:41:45 +0200 Subject: [PATCH 67/79] Formated the suggestion Signed-off-by: Trial97 --- launcher/ui/dialogs/MSALoginDialog.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp index e36a574f3..adc1b9e74 100644 --- a/launcher/ui/dialogs/MSALoginDialog.cpp +++ b/launcher/ui/dialogs/MSALoginDialog.cpp @@ -108,10 +108,9 @@ void MSALoginDialog::showVerificationUriAndCode(const QUrl& uri, const QString& if (urlString == "https://www.microsoft.com/link" && !code.isEmpty()) { urlString += QString("?otc=%1").arg(code); DesktopServices::openUrl(urlString); - ui->label->setText( - tr("

Please login in the opened browser. If no browser was opened please open up %1 in " - "a browser and put in the code %2 to proceed with login.

") - .arg(linkString, code)); + ui->label->setText(tr("

Please login in the opened browser. If no browser was opened please open up %1 in " + "a browser and put in the code %2 to proceed with login.

") + .arg(linkString, code)); } else { ui->label->setText( tr("

Please open up %1 in a browser and put in the code %2 to proceed with login.

").arg(linkString, code)); From d4b479a186dfb3b1ede3d86258f4a9f50722fa5d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 7 Nov 2023 23:55:40 +0000 Subject: [PATCH 68/79] chore(deps): update korthout/backport-action action to v2.1.1 --- .github/workflows/backport.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 6f2025551..e5443439d 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -24,7 +24,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - name: Create backport PRs - uses: korthout/backport-action@v2.1.0 + uses: korthout/backport-action@v2.1.1 with: # Config README: https://github.com/korthout/backport-action#backport-action pull_description: |- From 9d653f172a512e163e61dac2455e12fe1678dc7c Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Wed, 8 Nov 2023 08:56:48 +0200 Subject: [PATCH 69/79] Update launcher/ui/dialogs/MSALoginDialog.cpp Co-authored-by: seth Signed-off-by: Alexandru Ionut Tripon --- launcher/ui/dialogs/MSALoginDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp index adc1b9e74..7df423412 100644 --- a/launcher/ui/dialogs/MSALoginDialog.cpp +++ b/launcher/ui/dialogs/MSALoginDialog.cpp @@ -108,7 +108,7 @@ void MSALoginDialog::showVerificationUriAndCode(const QUrl& uri, const QString& if (urlString == "https://www.microsoft.com/link" && !code.isEmpty()) { urlString += QString("?otc=%1").arg(code); DesktopServices::openUrl(urlString); - ui->label->setText(tr("

Please login in the opened browser. If no browser was opened please open up %1 in " + ui->label->setText(tr("

Please login in the opened browser. If no browser was opened, please open up %1 in " "a browser and put in the code %2 to proceed with login.

") .arg(linkString, code)); } else { From 731363061521375fc363f203b43a65bc3a37434e Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Wed, 8 Nov 2023 09:01:31 +0200 Subject: [PATCH 70/79] Update launcher/java/JavaUtils.cpp Co-authored-by: seth Signed-off-by: Alexandru Ionut Tripon --- launcher/java/JavaUtils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index 615608ca3..074bf54df 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -448,12 +448,12 @@ QStringList getMinecraftJavaBundle() partialPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", ""); executable += "w.exe"; - // add the following to the search + // add the microsoft store version of the launcher to the search. the current path is: // C:\Users\USERNAME\AppData\Local\Packages\Microsoft.4297127D64EC6_8wekyb3d8bbwe\LocalCache\Local\runtime - auto minecraftInstaltionPath = + auto minecraftMSStorePath = FS::PathCombine(QFileInfo(partialPath).absolutePath(), "Local", "Packages", "Microsoft.4297127D64EC6_8wekyb3d8bbwe"); - minecraftInstaltionPath = FS::PathCombine(minecraftInstaltionPath, "LocalCache", "Local", "runtime"); - processpaths << minecraftInstaltionPath; + minecraftMSStorePath = FS::PathCombine(minecraftMSStorePath, "LocalCache", "Local", "runtime"); + processpaths << minecraftMSStorePath; #else partialPath = QDir::homePath(); #endif From a7bfe385ea24a68f791139246c788ef44611a862 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Wed, 8 Nov 2023 12:10:39 +0200 Subject: [PATCH 71/79] Renamed Remove Metadata button Signed-off-by: Trial97 --- launcher/ui/pages/instance/ModFolderPage.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index a2fe19a87..2ce35c43d 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -125,7 +125,7 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr remove->setToolTip(tr("Remove selected item")); connect(remove, &QAction::triggered, this, &ModFolderPage::removeItem); } - auto actionRemoveItemMetadata = removeMenu->addAction(tr("Remove metadata")); + auto actionRemoveItemMetadata = removeMenu->addAction(tr("Reset update metadata")); actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); connect(actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata); @@ -145,12 +145,9 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr ui->actionVisitItemPage->setText(tr("Visit mod's page")); ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page")); - actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); } else { ui->actionVisitItemPage->setText(tr("Visit mods' pages")); ui->actionVisitItemPage->setToolTip(tr("Go to the pages of the selected mods")); - - actionRemoveItemMetadata->setToolTip(tr("Remove mods' metadata")); } ui->actionVisitItemPage->setEnabled(selected != 0); actionRemoveItemMetadata->setEnabled(selected != 0); From ae62e48c7cf78aa585decc4cdb5b921006b1593c Mon Sep 17 00:00:00 2001 From: Trial97 Date: Wed, 8 Nov 2023 12:25:56 +0200 Subject: [PATCH 72/79] Moved some buttons around Signed-off-by: Trial97 --- launcher/ui/pages/instance/ModFolderPage.cpp | 62 ++++++++------------ 1 file changed, 25 insertions(+), 37 deletions(-) diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 2ce35c43d..08fd8ea5a 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -84,28 +84,33 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr connect(ui->actionDownloadItem, &QAction::triggered, this, &ModFolderPage::installMods); - if (!APPLICATION->settings()->get("ModDependenciesDisabled").toBool()) { // dependencies - auto updateMenu = ui->actionUpdateItem->menu(); - if (updateMenu) { - updateMenu->clear(); - } else { - updateMenu = new QMenu(this); - } - - { - auto update = updateMenu->addAction(tr("Check for Updates")); - update->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); - connect(update, &QAction::triggered, this, &ModFolderPage::updateMods); - } - { - auto updateWithDeps = updateMenu->addAction(tr("Verify Dependencies")); - updateWithDeps->setToolTip( - tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)")); - connect(updateWithDeps, &QAction::triggered, this, [this] { updateMods(true); }); - } - ui->actionUpdateItem->setMenu(updateMenu); + // update menu + auto updateMenu = ui->actionUpdateItem->menu(); + if (updateMenu) { + updateMenu->clear(); + } else { + updateMenu = new QMenu(this); } + { + auto update = updateMenu->addAction(tr("Check for Updates")); + update->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); + connect(update, &QAction::triggered, this, &ModFolderPage::updateMods); + } + if (!APPLICATION->settings()->get("ModDependenciesDisabled").toBool()) { // dependencies + + auto updateWithDeps = updateMenu->addAction(tr("Verify Dependencies")); + updateWithDeps->setToolTip( + tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)")); + connect(updateWithDeps, &QAction::triggered, this, [this] { updateMods(true); }); + } + auto actionRemoveItemMetadata = updateMenu->addAction(tr("Reset update metadata")); + actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); + connect(actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata); + actionRemoveItemMetadata->setEnabled(false); + + ui->actionUpdateItem->setMenu(updateMenu); + ui->actionUpdateItem->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods); ui->actionsToolbar->insertActionBefore(ui->actionAddItem, ui->actionUpdateItem); @@ -114,23 +119,6 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr ui->actionsToolbar->addAction(ui->actionVisitItemPage); connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages); - auto removeMenu = ui->actionRemoveItem->menu(); - if (removeMenu) { - removeMenu->clear(); - } else { - removeMenu = new QMenu(this); - } - { - auto remove = removeMenu->addAction("Remove"); - remove->setToolTip(tr("Remove selected item")); - connect(remove, &QAction::triggered, this, &ModFolderPage::removeItem); - } - auto actionRemoveItemMetadata = removeMenu->addAction(tr("Reset update metadata")); - actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); - connect(actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata); - - ui->actionRemoveItem->setMenu(removeMenu); - auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); }; connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, From 6093399f5c861417d8af9503517d391ff58e7390 Mon Sep 17 00:00:00 2001 From: Desoroxxx Date: Wed, 8 Nov 2023 17:32:30 +0100 Subject: [PATCH 73/79] Update LauncherPage.ui Signed-off-by: Desoroxxx --- launcher/ui/pages/global/LauncherPage.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 32d89ee51..83897f7a7 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -189,10 +189,10 @@ - Disable automatically checking and installation of mod dependencies. + Disable the automatic detection, installation, and updating of mod dependencies. - Do not install mod dependencies + Disable automatic mod dependency management From 0f68a2dd616b24173369515046cdd008cf0f6834 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Thu, 9 Nov 2023 16:38:26 +0000 Subject: [PATCH 74/79] Only open/close groups on left button Signed-off-by: TheKodeToad --- launcher/ui/instanceview/InstanceView.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index 7530fdfba..e665097f4 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -278,12 +278,14 @@ void InstanceView::mousePressEvent(QMouseEvent* event) m_pressedAlreadySelected = selectionModel()->isSelected(m_pressedIndex); m_pressedPosition = geometryPos; - VisualGroup::HitResults hitResult; - m_pressedCategory = categoryAt(geometryPos, hitResult); - if (m_pressedCategory && hitResult & VisualGroup::CheckboxHit) { - setState(m_pressedCategory->collapsed ? ExpandingState : CollapsingState); - event->accept(); - return; + if (event->button() == Qt::LeftButton) { + VisualGroup::HitResults hitResult; + m_pressedCategory = categoryAt(geometryPos, hitResult); + if (m_pressedCategory && hitResult & VisualGroup::CheckboxHit) { + setState(m_pressedCategory->collapsed ? ExpandingState : CollapsingState); + event->accept(); + return; + } } if (index.isValid() && (index.flags() & Qt::ItemIsEnabled)) { @@ -366,10 +368,7 @@ void InstanceView::mouseReleaseEvent(QMouseEvent* event) VisualGroup::HitResults hitResult; - bool click = - (index == m_pressedIndex && index.isValid()) || (m_pressedCategory && m_pressedCategory == categoryAt(geometryPos, hitResult)); - - if (click && m_pressedCategory) { + if (event->button() == Qt::LeftButton && m_pressedCategory != nullptr && m_pressedCategory == categoryAt(geometryPos, hitResult)) { if (state() == ExpandingState) { m_pressedCategory->collapsed = false; emit groupStateChanged(m_pressedCategory->text, false); @@ -397,7 +396,7 @@ void InstanceView::mouseReleaseEvent(QMouseEvent* event) setState(NoState); - if (click) { + if (index == m_pressedIndex && index.isValid()) { if (event->button() == Qt::LeftButton) { emit clicked(index); } From 926942a973cd3f9df5467abcd438203f0279bcd4 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 10 Nov 2023 20:00:35 +0200 Subject: [PATCH 75/79] Fixed modrinth sort swap Signed-off-by: Trial97 --- launcher/modplatform/modrinth/ModrinthAPI.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/modplatform/modrinth/ModrinthAPI.cpp b/launcher/modplatform/modrinth/ModrinthAPI.cpp index 8be963ecf..9777c2cfd 100644 --- a/launcher/modplatform/modrinth/ModrinthAPI.cpp +++ b/launcher/modplatform/modrinth/ModrinthAPI.cpp @@ -117,6 +117,6 @@ QList ModrinthAPI::getSortingMethods() const return { { 1, "relevance", QObject::tr("Sort by Relevance") }, { 2, "downloads", QObject::tr("Sort by Downloads") }, { 3, "follows", QObject::tr("Sort by Follows") }, - { 4, "newest", QObject::tr("Sort by Last Updated") }, - { 5, "updated", QObject::tr("Sort by Newest") } }; + { 4, "newest", QObject::tr("Sort by Newest") }, + { 5, "updated", QObject::tr("Sort by Last Updated") } }; } From cb648c180cb6d38aa1a8662851738cde7595e6e2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 12 Nov 2023 00:18:56 +0000 Subject: [PATCH 76/79] chore(nix): update lockfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'libnbtplusplus': 'github:PrismLauncher/libnbtplusplus/a5e8fd52b8bf4ab5d5bcc042b2a247867589985f' (2023-07-22) → 'github:PrismLauncher/libnbtplusplus/23b955121b8217c1c348a9ed2483167a6f3ff4ad' (2023-11-06) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/9d5d25bbfe8c0297ebe85324addcb5020ed1a454' (2023-11-04) → 'github:nixos/nixpkgs/ec750fd01963ab6b20ee1f0cb488754e8036d89d' (2023-11-07) • Updated input 'pre-commit-hooks': 'github:cachix/pre-commit-hooks.nix/dec10399e5b56aa95fcd530e0338be72ad6462a0' (2023-11-01) → 'github:cachix/pre-commit-hooks.nix/ea758da1a6dcde6dc36db348ed690d09b9864128' (2023-11-06) --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index a520c27e5..70c8cba4f 100644 --- a/flake.lock +++ b/flake.lock @@ -76,11 +76,11 @@ "libnbtplusplus": { "flake": false, "locked": { - "lastModified": 1690036783, - "narHash": "sha256-A5kTgICnx+Qdq3Fir/bKTfdTt/T1NQP2SC+nhN1ENug=", + "lastModified": 1699286814, + "narHash": "sha256-yy0q+bky80LtK1GWzz7qpM+aAGrOqLuewbid8WT1ilk=", "owner": "PrismLauncher", "repo": "libnbtplusplus", - "rev": "a5e8fd52b8bf4ab5d5bcc042b2a247867589985f", + "rev": "23b955121b8217c1c348a9ed2483167a6f3ff4ad", "type": "github" }, "original": { @@ -106,11 +106,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1699094435, - "narHash": "sha256-YLZ5/KKZ1PyLrm2MO8UxRe4H3M0/oaYqNhSlq6FDeeA=", + "lastModified": 1699343069, + "narHash": "sha256-s7BBhyLA6MI6FuJgs4F/SgpntHBzz40/qV0xLPW6A1Q=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9d5d25bbfe8c0297ebe85324addcb5020ed1a454", + "rev": "ec750fd01963ab6b20ee1f0cb488754e8036d89d", "type": "github" }, "original": { @@ -153,11 +153,11 @@ ] }, "locked": { - "lastModified": 1698852633, - "narHash": "sha256-Hsc/cCHud8ZXLvmm8pxrXpuaPEeNaaUttaCvtdX/Wug=", + "lastModified": 1699271226, + "narHash": "sha256-8Jt1KW3xTjolD6c6OjJm9USx/jmL+VVmbooADCkdDfU=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "dec10399e5b56aa95fcd530e0338be72ad6462a0", + "rev": "ea758da1a6dcde6dc36db348ed690d09b9864128", "type": "github" }, "original": { From 32a8d9b9c6df7c0c4373d22f9e30edb634c90774 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Mon, 13 Nov 2023 09:23:56 +0200 Subject: [PATCH 77/79] Update launcher/ui/pages/instance/ModFolderPage.cpp Co-authored-by: TheKodeToad Signed-off-by: Alexandru Ionut Tripon --- launcher/ui/pages/instance/ModFolderPage.cpp | 23 ++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 08fd8ea5a..ce67324a3 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -92,18 +92,19 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr updateMenu = new QMenu(this); } - { - auto update = updateMenu->addAction(tr("Check for Updates")); - update->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); - connect(update, &QAction::triggered, this, &ModFolderPage::updateMods); - } - if (!APPLICATION->settings()->get("ModDependenciesDisabled").toBool()) { // dependencies + auto update = updateMenu->addAction(tr("Check for Updates")); + update->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)")); + connect(update, &QAction::triggered, this, &ModFolderPage::updateMods); - auto updateWithDeps = updateMenu->addAction(tr("Verify Dependencies")); - updateWithDeps->setToolTip( - tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)")); - connect(updateWithDeps, &QAction::triggered, this, [this] { updateMods(true); }); - } + auto updateWithDeps = updateMenu->addAction(tr("Verify Dependencies")); + updateWithDeps->setToolTip( + tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)")); + connect(updateWithDeps, &QAction::triggered, this, [this] { updateMods(true); }); + + auto depsDisabled = APPLICATION->settings()->getSetting("ModDependenciesDisabled"); + updateWithDeps->setVisible(!depsDisabled->get().toBool()); + connect(depsDisabled.get(), &Setting::SettingChanged, this, + [](const Setting& setting, QVariant value) { updateWithDeps->setVisible(!value.toBool()); }); auto actionRemoveItemMetadata = updateMenu->addAction(tr("Reset update metadata")); actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); connect(actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata); From 0e57eeca69554178bdd1817ccb01be2286e48110 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 13 Nov 2023 09:28:59 +0200 Subject: [PATCH 78/79] Added missing variable from lambda capture Signed-off-by: Trial97 --- launcher/ui/pages/instance/ModFolderPage.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index ce67324a3..a38e608f2 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -104,7 +104,8 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr auto depsDisabled = APPLICATION->settings()->getSetting("ModDependenciesDisabled"); updateWithDeps->setVisible(!depsDisabled->get().toBool()); connect(depsDisabled.get(), &Setting::SettingChanged, this, - [](const Setting& setting, QVariant value) { updateWithDeps->setVisible(!value.toBool()); }); + [updateWithDeps](const Setting& setting, QVariant value) { updateWithDeps->setVisible(!value.toBool()); }); + auto actionRemoveItemMetadata = updateMenu->addAction(tr("Reset update metadata")); actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata")); connect(actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata); From 361329d5d15d5963af35c23f0d131e51bc97a6f8 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 14 Nov 2023 23:21:53 +0200 Subject: [PATCH 79/79] Made resource columns resizable Signed-off-by: Trial97 --- launcher/minecraft/mod/ModFolderModel.cpp | 6 ++-- .../minecraft/mod/ResourceFolderModel.cpp | 29 +++++-------------- launcher/minecraft/mod/ResourceFolderModel.h | 7 ++--- .../minecraft/mod/ResourcePackFolderModel.cpp | 4 +-- .../minecraft/mod/TexturePackFolderModel.cpp | 3 +- launcher/ui/pages/global/AccountListPage.cpp | 1 + .../pages/instance/ExternalResourcesPage.cpp | 4 ++- launcher/ui/widgets/ModListView.cpp | 6 ++-- 8 files changed, 24 insertions(+), 36 deletions(-) diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index 11f7cd0f1..fc543202f 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -37,9 +37,9 @@ #include "ModFolderModel.h" #include -#include #include #include +#include #include #include #include @@ -65,8 +65,8 @@ 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_resize_modes = { QHeaderView::Interactive, QHeaderView::Interactive, QHeaderView::Stretch, + QHeaderView::Interactive, QHeaderView::Interactive, QHeaderView::Interactive }; m_columnsHideable = { false, true, false, true, true, true }; } diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp index 0503b660b..4a3ee9922 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.cpp +++ b/launcher/minecraft/mod/ResourceFolderModel.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -516,36 +517,22 @@ void ResourceFolderModel::setupHeaderAction(QAction* act, int column) act->setText(columnNames().at(column)); } -void ResourceFolderModel::saveHiddenColumn(int column, bool hidden) +void ResourceFolderModel::saveColumns(QTreeView* tree) { - auto const setting_name = QString("UI/%1_Page/HiddenColumns").arg(id()); + auto const setting_name = QString("UI/%1_Page/Columns").arg(id()); auto setting = (m_instance->settings()->contains(setting_name)) ? m_instance->settings()->getSetting(setting_name) : m_instance->settings()->registerSetting(setting_name); - auto hiddenColumns = setting->get().toStringList(); - auto name = columnNames(false).at(column); - auto index = hiddenColumns.indexOf(name); - if (index >= 0 && !hidden) { - hiddenColumns.removeAt(index); - } else if (index < 0 && hidden) { - hiddenColumns.append(name); - } - setting->set(hiddenColumns); + setting->set(tree->header()->saveState()); } -void ResourceFolderModel::loadHiddenColumns(QTreeView* tree) +void ResourceFolderModel::loadColumns(QTreeView* tree) { - auto const setting_name = QString("UI/%1_Page/HiddenColumns").arg(id()); + auto const setting_name = QString("UI/%1_Page/Columns").arg(id()); auto setting = (m_instance->settings()->contains(setting_name)) ? m_instance->settings()->getSetting(setting_name) : m_instance->settings()->registerSetting(setting_name); - auto hiddenColumns = setting->get().toStringList(); - auto col_names = columnNames(false); - for (auto col_name : hiddenColumns) { - auto index = col_names.indexOf(col_name); - if (index >= 0) - tree->setColumnHidden(index, true); - } + tree->header()->restoreState(setting->get().toByteArray()); } QMenu* ResourceFolderModel::createHeaderContextMenu(QTreeView* tree) @@ -570,7 +557,7 @@ QMenu* ResourceFolderModel::createHeaderContextMenu(QTreeView* tree) if (m_column_resize_modes.at(c) == QHeaderView::ResizeToContents) tree->resizeColumnToContents(c); } - saveHiddenColumn(col, !toggled); + saveColumns(tree); }); menu->addAction(act); diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h index 60b8879c0..b3f6d9a58 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.h +++ b/launcher/minecraft/mod/ResourceFolderModel.h @@ -117,8 +117,8 @@ class ResourceFolderModel : public QAbstractListModel { [[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; void setupHeaderAction(QAction* act, int column); - void saveHiddenColumn(int column, bool hidden); - void loadHiddenColumns(QTreeView* tree); + void saveColumns(QTreeView* tree); + void loadColumns(QTreeView* tree); QMenu* createHeaderContextMenu(QTreeView* tree); /** This creates a proxy model to filter / sort the model for a UI. @@ -201,8 +201,7 @@ class ResourceFolderModel : public QAbstractListModel { QList m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::DATE }; QStringList m_column_names = { "Enable", "Name", "Last Modified" }; QStringList m_column_names_translated = { tr("Enable"), tr("Name"), tr("Last Modified") }; - QList m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Stretch, - QHeaderView::ResizeToContents }; + QList m_column_resize_modes = { QHeaderView::Interactive, QHeaderView::Stretch, QHeaderView::Interactive }; QList m_columnsHideable = { false, false, true }; QDir m_dir; diff --git a/launcher/minecraft/mod/ResourcePackFolderModel.cpp b/launcher/minecraft/mod/ResourcePackFolderModel.cpp index efe1cc5dd..693b8af05 100644 --- a/launcher/minecraft/mod/ResourcePackFolderModel.cpp +++ b/launcher/minecraft/mod/ResourcePackFolderModel.cpp @@ -52,8 +52,8 @@ ResourcePackFolderModel::ResourcePackFolderModel(const QString& dir, BaseInstanc m_column_names = QStringList({ "Enable", "Image", "Name", "Pack Format", "Last Modified" }); m_column_names_translated = QStringList({ tr("Enable"), tr("Image"), tr("Name"), tr("Pack Format"), tr("Last Modified") }); m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME, SortType::PACK_FORMAT, SortType::DATE }; - m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Interactive, QHeaderView::Stretch, QHeaderView::ResizeToContents, - QHeaderView::ResizeToContents }; + m_column_resize_modes = { QHeaderView::Interactive, QHeaderView::Interactive, QHeaderView::Stretch, QHeaderView::Interactive, + QHeaderView::Interactive }; m_columnsHideable = { false, true, false, true, true }; } diff --git a/launcher/minecraft/mod/TexturePackFolderModel.cpp b/launcher/minecraft/mod/TexturePackFolderModel.cpp index e39be1fb9..f210501c7 100644 --- a/launcher/minecraft/mod/TexturePackFolderModel.cpp +++ b/launcher/minecraft/mod/TexturePackFolderModel.cpp @@ -47,8 +47,7 @@ TexturePackFolderModel::TexturePackFolderModel(const QString& dir, BaseInstance* m_column_names = QStringList({ "Enable", "Image", "Name", "Last Modified" }); m_column_names_translated = QStringList({ tr("Enable"), tr("Image"), tr("Name"), tr("Last Modified") }); m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME, SortType::DATE }; - m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Interactive, QHeaderView::Stretch, - QHeaderView::ResizeToContents }; + m_column_resize_modes = { QHeaderView::Interactive, QHeaderView::Interactive, QHeaderView::Stretch, QHeaderView::Interactive }; m_columnsHideable = { false, true, false, true }; } diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index 3a21cdd9b..2fd8a0402 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -231,6 +231,7 @@ void AccountListPage::updateButtonStates() ui->actionNoDefault->setEnabled(true); ui->actionNoDefault->setChecked(false); } + ui->listView->resizeColumnToContents(3); } void AccountListPage::on_actionUploadSkin_triggered() diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp index 1a8fafa9b..b04c7250c 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp +++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp @@ -42,6 +42,7 @@ #include "minecraft/mod/ResourceFolderModel.h" #include "ui/GuiUtil.h" +#include #include #include #include @@ -95,7 +96,8 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared connect(viewHeader, &QHeaderView::customContextMenuRequested, this, &ExternalResourcesPage::ShowHeaderContextMenu); - m_model->loadHiddenColumns(ui->treeView); + m_model->loadColumns(ui->treeView); + connect(ui->treeView->header(), &QHeaderView::sectionResized, this, [this] { m_model->saveColumns(ui->treeView); }); } ExternalResourcesPage::~ExternalResourcesPage() diff --git a/launcher/ui/widgets/ModListView.cpp b/launcher/ui/widgets/ModListView.cpp index c72d4c522..a38c7c86a 100644 --- a/launcher/ui/widgets/ModListView.cpp +++ b/launcher/ui/widgets/ModListView.cpp @@ -48,14 +48,14 @@ void ModListView::setModel(QAbstractItemModel* model) return; } if (!string.size()) { - head->setSectionResizeMode(0, QHeaderView::ResizeToContents); + head->setSectionResizeMode(0, QHeaderView::Interactive); head->setSectionResizeMode(1, QHeaderView::Stretch); for (int i = 2; i < head->count(); i++) - head->setSectionResizeMode(i, QHeaderView::ResizeToContents); + head->setSectionResizeMode(i, QHeaderView::Interactive); } else { head->setSectionResizeMode(0, QHeaderView::Stretch); for (int i = 1; i < head->count(); i++) - head->setSectionResizeMode(i, QHeaderView::ResizeToContents); + head->setSectionResizeMode(i, QHeaderView::Interactive); } }