From 50a4d61ded300c47c727f1104d17b2960ff5d0c6 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 10 Nov 2023 23:26:41 +0200 Subject: [PATCH 01/16] Fixed demo mode Signed-off-by: Trial97 --- launcher/LaunchController.cpp | 87 +++++++++++++------- launcher/LaunchController.h | 2 + launcher/minecraft/auth/AuthSession.cpp | 11 ++- launcher/minecraft/auth/AuthSession.h | 2 +- launcher/minecraft/auth/MinecraftAccount.cpp | 2 + 5 files changed, 71 insertions(+), 33 deletions(-) diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index f59cdeda8..6d5a9e93e 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -129,12 +129,63 @@ void LaunchController::decideAccount() } } +bool LaunchController::askPlayDemo() +{ + QMessageBox box(m_parentWidget); + box.setWindowTitle(tr("Play demo?")); + box.setText( + tr("This account does not own Minecraft.\nYou need to purchase the game first to play it.\n\nDo you want to play " + "the demo?")); + box.setIcon(QMessageBox::Warning); + auto demoButton = box.addButton(tr("Play Demo"), QMessageBox::ButtonRole::YesRole); + auto cancelButton = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::NoRole); + box.setDefaultButton(cancelButton); + + box.exec(); + return box.clickedButton() == demoButton; +} + +QString LaunchController::askOfflineName(QString playerName, bool demo, bool& ok) +{ + // we ask the user for a player name + QString message = tr("Choose your offline mode player name."); + if (demo) { + message = tr("Choose your demo mode player name."); + } + + QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString(); + QString usedname = lastOfflinePlayerName.isEmpty() ? playerName : lastOfflinePlayerName; + QString name = QInputDialog::getText(m_parentWidget, tr("Player name"), message, QLineEdit::Normal, usedname, &ok); + if (!ok) + return {}; + if (name.length()) { + usedname = name; + APPLICATION->settings()->set("LastOfflinePlayerName", usedname); + } + return usedname; +} + void LaunchController::login() { decideAccount(); - // if no account is selected, we bail if (!m_accountToUse) { + // if no account is selected, ask about demo + if (!m_demo) { + m_demo = askPlayDemo(); + } + if (m_demo) { + // we ask the user for a player name + bool ok = false; + auto name = askOfflineName("Player", m_demo, ok); + if (ok) { + m_session = std::make_shared(); + m_session->MakeDemo(name, MinecraftAccount::uuidFromUsername(name).toString().remove(QRegularExpression("[{}-]"))); + launchInstance(); + return; + } + } + // if no account is selected, we bail emitFailed(tr("No account selected for launch.")); return; } @@ -175,24 +226,12 @@ void LaunchController::login() if (!m_session->wants_online) { // we ask the user for a player name bool ok = false; - - QString message = tr("Choose your offline mode player name."); - if (m_session->demo) { - message = tr("Choose your demo mode player name."); - } - - QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString(); - QString usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName; - QString name = QInputDialog::getText(m_parentWidget, tr("Player name"), message, QLineEdit::Normal, usedname, &ok); + auto name = askOfflineName(m_session->player_name, m_session->demo, ok); if (!ok) { tryagain = false; break; } - if (name.length()) { - usedname = name; - APPLICATION->settings()->set("LastOfflinePlayerName", usedname); - } - m_session->MakeOffline(usedname); + m_session->MakeOffline(name); // offline flavored game from here :3 } if (m_accountToUse->ownsMinecraft()) { @@ -212,20 +251,10 @@ void LaunchController::login() return; } else { // play demo ? - QMessageBox box(m_parentWidget); - box.setWindowTitle(tr("Play demo?")); - box.setText( - tr("This account does not own Minecraft.\nYou need to purchase the game first to play it.\n\nDo you want to play " - "the demo?")); - box.setIcon(QMessageBox::Warning); - auto demoButton = box.addButton(tr("Play Demo"), QMessageBox::ButtonRole::YesRole); - auto cancelButton = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::NoRole); - box.setDefaultButton(cancelButton); - - box.exec(); - if (box.clickedButton() == demoButton) { - // play demo here - m_session->MakeDemo(); + if (!m_session->demo) { + m_session->demo = askPlayDemo(); + } + if (m_session->demo) { // play demo here launchInstance(); } else { emitFailed(tr("Launch cancelled - account does not own Minecraft.")); diff --git a/launcher/LaunchController.h b/launcher/LaunchController.h index f1c88afb7..02b1e0d33 100644 --- a/launcher/LaunchController.h +++ b/launcher/LaunchController.h @@ -74,6 +74,8 @@ class LaunchController : public Task { void login(); void launchInstance(); void decideAccount(); + bool askPlayDemo(); + QString askOfflineName(QString playerName, bool demo, bool& ok); private slots: void readyForLaunch(); diff --git a/launcher/minecraft/auth/AuthSession.cpp b/launcher/minecraft/auth/AuthSession.cpp index 37534f983..3657befec 100644 --- a/launcher/minecraft/auth/AuthSession.cpp +++ b/launcher/minecraft/auth/AuthSession.cpp @@ -30,8 +30,13 @@ bool AuthSession::MakeOffline(QString offline_playername) return true; } -void AuthSession::MakeDemo() +void AuthSession::MakeDemo(QString name, QString u) { - player_name = "Player"; + wants_online = false; demo = true; -} + uuid = u; + session = "-"; + access_token = "0"; + player_name = name; + status = PlayableOnline; // needs online to download the assets +}; \ No newline at end of file diff --git a/launcher/minecraft/auth/AuthSession.h b/launcher/minecraft/auth/AuthSession.h index cec238033..54e7d69e0 100644 --- a/launcher/minecraft/auth/AuthSession.h +++ b/launcher/minecraft/auth/AuthSession.h @@ -10,7 +10,7 @@ class QNetworkAccessManager; struct AuthSession { bool MakeOffline(QString offline_playername); - void MakeDemo(); + void MakeDemo(QString name, QString uuid); QString serializeUserProperties(); diff --git a/launcher/minecraft/auth/MinecraftAccount.cpp b/launcher/minecraft/auth/MinecraftAccount.cpp index 545d06aed..c3c29f598 100644 --- a/launcher/minecraft/auth/MinecraftAccount.cpp +++ b/launcher/minecraft/auth/MinecraftAccount.cpp @@ -269,6 +269,8 @@ void MinecraftAccount::fillSession(AuthSessionPtr session) session->player_name = data.profileName(); // profile ID session->uuid = data.profileId(); + if (session->uuid.isEmpty()) + session->uuid = uuidFromUsername(session->player_name).toString().remove(QRegularExpression("[{}-]")); // 'legacy' or 'mojang', depending on account type session->user_type = typeString(); if (!session->access_token.isEmpty()) { From c15f6fcd2a8a380b59f7f49cae5010cc93efd386 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 16 May 2024 17:21:30 +0300 Subject: [PATCH 02/16] Fix portable if manifest is missing Signed-off-by: Trial97 --- launcher/updater/prismupdater/PrismUpdater.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp index 5fe22bdd0..e9c75e080 100644 --- a/launcher/updater/prismupdater/PrismUpdater.cpp +++ b/launcher/updater/prismupdater/PrismUpdater.cpp @@ -474,8 +474,7 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar target_dir = QDir(m_rootPath).absoluteFilePath(".."); } - QMetaObject::invokeMethod( - this, [this, target_dir]() { moveAndFinishUpdate(target_dir); }, Qt::QueuedConnection); + QMetaObject::invokeMethod(this, [this, target_dir]() { moveAndFinishUpdate(target_dir); }, Qt::QueuedConnection); } else { QMetaObject::invokeMethod(this, &PrismUpdaterApp::loadReleaseList, Qt::QueuedConnection); @@ -1118,7 +1117,6 @@ void PrismUpdaterApp::backupAppDir() "Qt*.dll", }); } - file_list.append("portable.txt"); logUpdate("manifest.txt empty or missing. making best guess at files to back up."); } logUpdate(tr("Backing up:\n %1").arg(file_list.join(",\n "))); From 051e7886837090ba62ad81b6f835372649a93b69 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Thu, 16 May 2024 19:45:00 +0300 Subject: [PATCH 03/16] Update launcher/updater/prismupdater/PrismUpdater.cpp Signed-off-by: Alexandru Ionut Tripon --- launcher/updater/prismupdater/PrismUpdater.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp index e9c75e080..054206c67 100644 --- a/launcher/updater/prismupdater/PrismUpdater.cpp +++ b/launcher/updater/prismupdater/PrismUpdater.cpp @@ -474,7 +474,8 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar target_dir = QDir(m_rootPath).absoluteFilePath(".."); } - QMetaObject::invokeMethod(this, [this, target_dir]() { moveAndFinishUpdate(target_dir); }, Qt::QueuedConnection); + QMetaObject::invokeMethod( + this, [this, target_dir]() { moveAndFinishUpdate(target_dir); }, Qt::QueuedConnection);Qt::QueuedConnection); } else { QMetaObject::invokeMethod(this, &PrismUpdaterApp::loadReleaseList, Qt::QueuedConnection); From ab5f628453de6fc9301f73413027846451a78bd0 Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Tripon Date: Thu, 16 May 2024 19:45:43 +0300 Subject: [PATCH 04/16] Update launcher/updater/prismupdater/PrismUpdater.cpp Signed-off-by: Alexandru Ionut Tripon --- launcher/updater/prismupdater/PrismUpdater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/updater/prismupdater/PrismUpdater.cpp b/launcher/updater/prismupdater/PrismUpdater.cpp index 054206c67..f3cc2ad56 100644 --- a/launcher/updater/prismupdater/PrismUpdater.cpp +++ b/launcher/updater/prismupdater/PrismUpdater.cpp @@ -475,7 +475,7 @@ PrismUpdaterApp::PrismUpdaterApp(int& argc, char** argv) : QApplication(argc, ar } QMetaObject::invokeMethod( - this, [this, target_dir]() { moveAndFinishUpdate(target_dir); }, Qt::QueuedConnection);Qt::QueuedConnection); + this, [this, target_dir]() { moveAndFinishUpdate(target_dir); }, Qt::QueuedConnection); } else { QMetaObject::invokeMethod(this, &PrismUpdaterApp::loadReleaseList, Qt::QueuedConnection); From 428889a68d67aa4e110b7de9346474e27a4f3ab9 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 19 May 2024 19:35:47 +0300 Subject: [PATCH 05/16] removed + from bad chars in filenames Signed-off-by: Trial97 --- launcher/FileSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 70704e1d3..22d1ae60c 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -801,7 +801,7 @@ QString NormalizePath(QString path) } } -static const QString BAD_PATH_CHARS = "\"?<>:;*|!+\r\n"; +static const QString BAD_PATH_CHARS = "\"?<>:;*|!\r\n"; static const QString BAD_FILENAME_CHARS = BAD_PATH_CHARS + "\\/"; QString RemoveInvalidFilenameChars(QString string, QChar replaceWith) From 2b949a8059a133d06a626bae8de6bf580825532b Mon Sep 17 00:00:00 2001 From: Trial97 Date: Wed, 22 May 2024 10:53:24 +0300 Subject: [PATCH 06/16] improve login account checking Signed-off-by: Trial97 --- launcher/LaunchController.cpp | 2 +- launcher/minecraft/auth/MinecraftAccount.cpp | 2 -- launcher/minecraft/auth/MinecraftAccount.h | 2 +- launcher/ui/MainWindow.cpp | 23 -------------------- launcher/ui/MainWindow.h | 1 - 5 files changed, 2 insertions(+), 28 deletions(-) diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp index 824564a2d..30e5d215e 100644 --- a/launcher/LaunchController.cpp +++ b/launcher/LaunchController.cpp @@ -84,7 +84,7 @@ void LaunchController::decideAccount() // Find an account to use. auto accounts = APPLICATION->accounts(); - if (accounts->count() <= 0) { + if (accounts->count() <= 0 || !accounts->anyAccountIsValid()) { // 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 " diff --git a/launcher/minecraft/auth/MinecraftAccount.cpp b/launcher/minecraft/auth/MinecraftAccount.cpp index eabe9d98d..5b063604c 100644 --- a/launcher/minecraft/auth/MinecraftAccount.cpp +++ b/launcher/minecraft/auth/MinecraftAccount.cpp @@ -83,8 +83,6 @@ MinecraftAccountPtr MinecraftAccount::createOffline(const QString& username) account->data.yggdrasilToken.issueInstant = QDateTime::currentDateTimeUtc(); account->data.yggdrasilToken.extra["userName"] = username; account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegularExpression("[{}-]")); - account->data.minecraftEntitlement.ownsMinecraft = true; - account->data.minecraftEntitlement.canPlayMinecraft = true; account->data.minecraftProfile.id = uuidFromUsername(username).toString().remove(QRegularExpression("[{}-]")); account->data.minecraftProfile.name = username; account->data.minecraftProfile.validity = Validity::Certain; diff --git a/launcher/minecraft/auth/MinecraftAccount.h b/launcher/minecraft/auth/MinecraftAccount.h index b5c623a26..f6fcfada2 100644 --- a/launcher/minecraft/auth/MinecraftAccount.h +++ b/launcher/minecraft/auth/MinecraftAccount.h @@ -116,7 +116,7 @@ class MinecraftAccount : public QObject, public Usable { [[nodiscard]] AccountType accountType() const noexcept { return data.type; } - bool ownsMinecraft() const { return data.minecraftEntitlement.ownsMinecraft; } + bool ownsMinecraft() const { return data.type != AccountType::Offline && data.minecraftEntitlement.ownsMinecraft; } bool hasProfile() const { return data.profileId().size() != 0; } diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 6bbb10532..bd3aa4865 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -871,29 +871,6 @@ void MainWindow::on_actionCopyInstance_triggered() runModalTask(task.get()); } -void MainWindow::finalizeInstance(InstancePtr inst) -{ - view->updateGeometries(); - setSelectedInstanceById(inst->id()); - if (APPLICATION->accounts()->anyAccountIsValid()) { - ProgressDialog loadDialog(this); - auto update = inst->createUpdateTask(Net::Mode::Online); - connect(update.get(), &Task::failed, [this](QString reason) { - QString error = QString("Instance load failed: %1").arg(reason); - CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show(); - }); - if (update) { - loadDialog.setSkipButton(true, tr("Abort")); - loadDialog.execWithTask(update.get()); - } - } else { - CustomMessageBox::selectable(this, tr("Error"), - tr("The launcher cannot download Minecraft or update instances unless you have at least " - "one account added.\nPlease add a Microsoft account."), - QMessageBox::Warning) - ->show(); - } -} void MainWindow::addInstance(const QString& url, const QMap& extra_info) { diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index 07a6e1eba..f7fdedd15 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -228,7 +228,6 @@ class MainWindow : public QMainWindow { void runModalTask(Task* task); void instanceFromInstanceTask(InstanceTask* task); - void finalizeInstance(InstancePtr inst); private: Ui::MainWindow* ui; From eacd7758e98cf3d8e0c8dd88cf1999331af0ade7 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Wed, 22 May 2024 22:49:28 +0300 Subject: [PATCH 07/16] fix pre-commit hook Signed-off-by: Trial97 --- launcher/ui/MainWindow.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index bd3aa4865..6807a4232 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -871,7 +871,6 @@ void MainWindow::on_actionCopyInstance_triggered() runModalTask(task.get()); } - void MainWindow::addInstance(const QString& url, const QMap& extra_info) { QString groupName; From 5e36def18be96fe70fa807d987bc714070e035dc Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 30 May 2024 00:36:02 +0300 Subject: [PATCH 08/16] remove search button Signed-off-by: Trial97 --- .../pages/modplatform/atlauncher/AtlPage.ui | 7 ----- .../ui/pages/modplatform/flame/FlamePage.cpp | 1 - .../ui/pages/modplatform/flame/FlamePage.ui | 21 ++++----------- .../modplatform/import_ftb/ImportFTBPage.ui | 7 ----- .../ui/pages/modplatform/legacy_ftb/Page.ui | 7 ----- .../modplatform/modrinth/ModrinthPage.cpp | 3 +-- .../modplatform/modrinth/ModrinthPage.ui | 27 +++++-------------- .../pages/modplatform/technic/TechnicPage.cpp | 1 - .../pages/modplatform/technic/TechnicPage.ui | 7 ----- 9 files changed, 13 insertions(+), 68 deletions(-) diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlPage.ui b/launcher/ui/pages/modplatform/atlauncher/AtlPage.ui index 8b6747331..c8b9aa8c0 100644 --- a/launcher/ui/pages/modplatform/atlauncher/AtlPage.ui +++ b/launcher/ui/pages/modplatform/atlauncher/AtlPage.ui @@ -68,13 +68,6 @@ - - - - Search - - - diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.cpp b/launcher/ui/pages/modplatform/flame/FlamePage.cpp index f1fd9b5d8..8c2bcefaa 100644 --- a/launcher/ui/pages/modplatform/flame/FlamePage.cpp +++ b/launcher/ui/pages/modplatform/flame/FlamePage.cpp @@ -55,7 +55,6 @@ FlamePage::FlamePage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::FlamePage), dialog(dialog), m_fetch_progress(this, false) { ui->setupUi(this); - connect(ui->searchButton, &QPushButton::clicked, this, &FlamePage::triggerSearch); ui->searchEdit->installEventFilter(this); listModel = new Flame::ListModel(this); ui->packView->setModel(listModel); diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.ui b/launcher/ui/pages/modplatform/flame/FlamePage.ui index f9e1fe67f..a8d88050a 100644 --- a/launcher/ui/pages/modplatform/flame/FlamePage.ui +++ b/launcher/ui/pages/modplatform/flame/FlamePage.ui @@ -30,22 +30,11 @@ - - - - - Search and filter... - - - - - - - Search - - - - + + + Search and filter... + + diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui index 6613a5939..1b626745a 100644 --- a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui +++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui @@ -60,13 +60,6 @@ - - - - Search - - - diff --git a/launcher/ui/pages/modplatform/legacy_ftb/Page.ui b/launcher/ui/pages/modplatform/legacy_ftb/Page.ui index 56cba7485..ae8b2ea5d 100644 --- a/launcher/ui/pages/modplatform/legacy_ftb/Page.ui +++ b/launcher/ui/pages/modplatform/legacy_ftb/Page.ui @@ -23,13 +23,6 @@ - - - - Search - - - diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp index da5fe1e7b..94bf8715c 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp @@ -58,7 +58,6 @@ ModrinthPage::ModrinthPage(NewInstanceDialog* dialog, QWidget* parent) { ui->setupUi(this); - connect(ui->searchButton, &QPushButton::clicked, this, &ModrinthPage::triggerSearch); ui->searchEdit->installEventFilter(this); m_model = new Modrinth::ModpackListModel(this); ui->packView->setModel(m_model); @@ -75,7 +74,7 @@ ModrinthPage::ModrinthPage(NewInstanceDialog* dialog, QWidget* parent) m_fetch_progress.setFixedHeight(24); m_fetch_progress.progressFormat(""); - ui->gridLayout->addWidget(&m_fetch_progress, 2, 0, 1, ui->gridLayout->columnCount()); + ui->gridLayout->addWidget(&m_fetch_progress, 1, 0, 1, ui->gridLayout->columnCount()); ui->sortByBox->addItem(tr("Sort by Relevance")); ui->sortByBox->addItem(tr("Sort by Total Downloads")); diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui index 68b1d4e24..16d2b3835 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui @@ -11,6 +11,13 @@ + + + + Search and filter ... + + + @@ -61,24 +68,6 @@ - - - - - - Search and filter ... - - - - - - - Search - - - - - @@ -89,8 +78,6 @@ - searchEdit - searchButton packView packDescription sortByBox diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.cpp b/launcher/ui/pages/modplatform/technic/TechnicPage.cpp index 6b1ec8cb5..a6bce9ac2 100644 --- a/launcher/ui/pages/modplatform/technic/TechnicPage.cpp +++ b/launcher/ui/pages/modplatform/technic/TechnicPage.cpp @@ -57,7 +57,6 @@ TechnicPage::TechnicPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::TechnicPage), dialog(dialog), m_fetch_progress(this, false) { ui->setupUi(this); - connect(ui->searchButton, &QPushButton::clicked, this, &TechnicPage::triggerSearch); ui->searchEdit->installEventFilter(this); model = new Technic::ListModel(this); ui->packView->setModel(model); diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.ui b/launcher/ui/pages/modplatform/technic/TechnicPage.ui index b988eda2b..1e825ff7a 100644 --- a/launcher/ui/pages/modplatform/technic/TechnicPage.ui +++ b/launcher/ui/pages/modplatform/technic/TechnicPage.ui @@ -75,13 +75,6 @@ - - - - Search - - - From a7a1b2876569704e842d942976ce39061ee5e899 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 30 May 2024 13:49:23 +0300 Subject: [PATCH 09/16] improve invalid path name Signed-off-by: Trial97 --- launcher/FileSystem.cpp | 89 +++++++++++++++++-- launcher/MMCZip.cpp | 2 - launcher/minecraft/Library.cpp | 1 + .../flame/FlameInstanceCreationTask.cpp | 2 - launcher/modplatform/flame/FlameModIndex.cpp | 2 - .../modrinth/ModrinthInstanceCreationTask.cpp | 2 - .../modrinth/ModrinthPackIndex.cpp | 2 - launcher/net/HttpMetaCache.cpp | 2 - 8 files changed, 82 insertions(+), 20 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 22d1ae60c..72df9368a 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -74,6 +74,7 @@ #include #include #else +#include #include #endif @@ -801,25 +802,97 @@ QString NormalizePath(QString path) } } -static const QString BAD_PATH_CHARS = "\"?<>:;*|!\r\n"; -static const QString BAD_FILENAME_CHARS = BAD_PATH_CHARS + "\\/"; +QString removeDuplicates(QString a) +{ + auto b = a.split(""); + b.removeDuplicates(); + return b.join(""); +} + +QString getFileSystemType(const QString& path) +{ + QString fileSystemType; + +#ifdef Q_OS_WIN + wchar_t volume[MAX_PATH + 1] = { 0 }; + if (GetVolumeInformationW((LPCWSTR)path.utf16(), nullptr, 0, nullptr, nullptr, nullptr, volume, MAX_PATH)) { + fileSystemType = QString::fromWCharArray(volume); + } +#elif defined(Q_OS_UNIX) + struct statvfs buf; + if (statvfs(path.toUtf8().constData(), &buf) == 0) { + switch (buf.f_type) { + case 0x4d44: // "MSDOS" + fileSystemType = "FAT32"; + break; + case 0x5346544e: // "NTFS" + fileSystemType = "NTFS"; + break; + case 0x4244: // "HFS+" or "H+" on some systems + case 0x482b: // "HFS+" or "H+" on some systems + fileSystemType = "HFS+"; + break; + case 0x41465342: // "APFS" + fileSystemType = "APFS"; + break; + case 0x65735546: // "exFAT" + fileSystemType = "exFAT"; + break; + default: + break; + } + } +#endif + + return fileSystemType; +} + +static const QString BAD_WIN_CHARS = "\"?<>:*|\r\n"; + +static const QString BAD_FAT32_CHARS = "<>:\"|?*+.,;=[]!"; +static const QString BAD_NTFS_CHARS = "<>:\"|?*"; +static const QString BAD_HFS_CHARS = ":"; +static const QString BAD_EXFAT_CHARS = "<>:\"|?*"; + +static const QString BAD_FILENAME_CHARS = + removeDuplicates(BAD_WIN_CHARS + BAD_FAT32_CHARS + BAD_NTFS_CHARS + BAD_HFS_CHARS + BAD_EXFAT_CHARS) + "\\/"; QString RemoveInvalidFilenameChars(QString string, QChar replaceWith) { for (int i = 0; i < string.length(); i++) if (string.at(i) < ' ' || BAD_FILENAME_CHARS.contains(string.at(i))) string[i] = replaceWith; - return string; } -QString RemoveInvalidPathChars(QString string, QChar replaceWith) +QString RemoveInvalidPathChars(QString path, QChar replaceWith) { - for (int i = 0; i < string.length(); i++) - if (string.at(i) < ' ' || BAD_PATH_CHARS.contains(string.at(i))) - string[i] = replaceWith; + QString invalidChars; +#ifdef Q_OS_WIN + invalidChars = BAD_WIN_CHARS; +#endif - return string; + QString fileSystemType = getFileSystemType(QFileInfo(path).absolutePath()); + + if (fileSystemType == "FAT32") { + invalidChars += BAD_FAT32_CHARS; + } else if (fileSystemType == "NTFS") { + invalidChars += BAD_NTFS_CHARS; + } else if (fileSystemType == "HFS+" || fileSystemType == "APFS") { + invalidChars += BAD_HFS_CHARS; + } else if (fileSystemType == "exFAT") { + invalidChars += BAD_EXFAT_CHARS; + } + + if (invalidChars.size() != 0) { + for (int i = 0; i < path.length(); i++) { + if (path.at(i) < ' ' || invalidChars.contains(path.at(i))) { + path[i] = replaceWith; + } + } + } + + return path; } QString DirNameFromString(QString string, QString inDir) diff --git a/launcher/MMCZip.cpp b/launcher/MMCZip.cpp index 9a5ae7a9d..9acde90e1 100644 --- a/launcher/MMCZip.cpp +++ b/launcher/MMCZip.cpp @@ -288,9 +288,7 @@ std::optional extractSubDir(QuaZip* zip, const QString& subdir, con do { QString file_name = zip->getCurrentFileName(); -#ifdef Q_OS_WIN file_name = FS::RemoveInvalidPathChars(file_name); -#endif if (!file_name.startsWith(subdir)) continue; diff --git a/launcher/minecraft/Library.cpp b/launcher/minecraft/Library.cpp index 2c3f2035f..4e30f72d1 100644 --- a/launcher/minecraft/Library.cpp +++ b/launcher/minecraft/Library.cpp @@ -51,6 +51,7 @@ void Library::getApplicableFiles(const RuntimeContext& runtimeContext, { bool local = isLocal(); auto actualPath = [&](QString relPath) { + relPath = FS::RemoveInvalidPathChars(relPath); QFileInfo out(FS::PathCombine(storagePrefix(), relPath)); if (local && !overridePath.isEmpty()) { QString fileName = out.fileName(); diff --git a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp index a1f10c156..003203879 100644 --- a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp +++ b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp @@ -538,9 +538,7 @@ void FlameCreationTask::setupDownloadJob(QEventLoop& loop) } for (const auto& result : results) { auto fileName = result.fileName; -#ifdef Q_OS_WIN fileName = FS::RemoveInvalidPathChars(fileName); -#endif auto relpath = FS::PathCombine(result.targetFolder, fileName); if (!result.required && !selectedOptionalMods.contains(relpath)) { diff --git a/launcher/modplatform/flame/FlameModIndex.cpp b/launcher/modplatform/flame/FlameModIndex.cpp index 83a28fa2b..1ca9237f4 100644 --- a/launcher/modplatform/flame/FlameModIndex.cpp +++ b/launcher/modplatform/flame/FlameModIndex.cpp @@ -139,9 +139,7 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) -> file.version = Json::requireString(obj, "displayName"); file.downloadUrl = Json::ensureString(obj, "downloadUrl"); file.fileName = Json::requireString(obj, "fileName"); -#ifdef Q_OS_WIN file.fileName = FS::RemoveInvalidPathChars(file.fileName); -#endif ModPlatform::IndexedVersionType::VersionType ver_type; switch (Json::requireInteger(obj, "releaseType")) { diff --git a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp index e92489999..cbb8e8e67 100644 --- a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp +++ b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp @@ -241,9 +241,7 @@ bool ModrinthCreationTask::createInstance() for (auto file : m_files) { auto fileName = file.path; -#ifdef Q_OS_WIN fileName = FS::RemoveInvalidPathChars(fileName); -#endif auto file_path = FS::PathCombine(root_modpack_path, fileName); if (!root_modpack_url.isParentOf(QUrl::fromLocalFile(file_path))) { // This means we somehow got out of the root folder, so abort here to prevent exploits diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp index 4671a330d..6c3df0902 100644 --- a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp +++ b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp @@ -227,9 +227,7 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_t if (parent.contains("url")) { file.downloadUrl = Json::requireString(parent, "url"); file.fileName = Json::requireString(parent, "filename"); -#ifdef Q_OS_WIN file.fileName = FS::RemoveInvalidPathChars(file.fileName); -#endif file.is_preferred = Json::requireBoolean(parent, "primary") || (files.count() == 1); auto hash_list = Json::requireObject(parent, "hashes"); diff --git a/launcher/net/HttpMetaCache.cpp b/launcher/net/HttpMetaCache.cpp index 648155412..d8b1c7636 100644 --- a/launcher/net/HttpMetaCache.cpp +++ b/launcher/net/HttpMetaCache.cpp @@ -84,9 +84,7 @@ auto HttpMetaCache::getEntry(QString base, QString resource_path) -> MetaEntryPt auto HttpMetaCache::resolveEntry(QString base, QString resource_path, QString expected_etag) -> MetaEntryPtr { -#ifdef Q_OS_WIN resource_path = FS::RemoveInvalidPathChars(resource_path); -#endif auto entry = getEntry(base, resource_path); // it's not present? generate a default stale entry if (!entry) { From 44a16c1ca1c340d3f7641fa12b0ffe59cdf92992 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 30 May 2024 14:20:35 +0300 Subject: [PATCH 10/16] fix CI Signed-off-by: Trial97 --- launcher/FileSystem.cpp | 84 +++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 53 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 72df9368a..3ded638ae 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -74,7 +74,6 @@ #include #include #else -#include #include #endif @@ -809,53 +808,13 @@ QString removeDuplicates(QString a) return b.join(""); } -QString getFileSystemType(const QString& path) -{ - QString fileSystemType; - -#ifdef Q_OS_WIN - wchar_t volume[MAX_PATH + 1] = { 0 }; - if (GetVolumeInformationW((LPCWSTR)path.utf16(), nullptr, 0, nullptr, nullptr, nullptr, volume, MAX_PATH)) { - fileSystemType = QString::fromWCharArray(volume); - } -#elif defined(Q_OS_UNIX) - struct statvfs buf; - if (statvfs(path.toUtf8().constData(), &buf) == 0) { - switch (buf.f_type) { - case 0x4d44: // "MSDOS" - fileSystemType = "FAT32"; - break; - case 0x5346544e: // "NTFS" - fileSystemType = "NTFS"; - break; - case 0x4244: // "HFS+" or "H+" on some systems - case 0x482b: // "HFS+" or "H+" on some systems - fileSystemType = "HFS+"; - break; - case 0x41465342: // "APFS" - fileSystemType = "APFS"; - break; - case 0x65735546: // "exFAT" - fileSystemType = "exFAT"; - break; - default: - break; - } - } -#endif - - return fileSystemType; -} - static const QString BAD_WIN_CHARS = "\"?<>:*|\r\n"; -static const QString BAD_FAT32_CHARS = "<>:\"|?*+.,;=[]!"; +static const QString BAD_FAT_CHARS = "<>:\"|?*+.,;=[]!"; static const QString BAD_NTFS_CHARS = "<>:\"|?*"; static const QString BAD_HFS_CHARS = ":"; -static const QString BAD_EXFAT_CHARS = "<>:\"|?*"; -static const QString BAD_FILENAME_CHARS = - removeDuplicates(BAD_WIN_CHARS + BAD_FAT32_CHARS + BAD_NTFS_CHARS + BAD_HFS_CHARS + BAD_EXFAT_CHARS) + "\\/"; +static const QString BAD_FILENAME_CHARS = removeDuplicates(BAD_WIN_CHARS + BAD_FAT_CHARS + BAD_NTFS_CHARS + BAD_HFS_CHARS) + "\\/"; QString RemoveInvalidFilenameChars(QString string, QChar replaceWith) { @@ -872,16 +831,35 @@ QString RemoveInvalidPathChars(QString path, QChar replaceWith) invalidChars = BAD_WIN_CHARS; #endif - QString fileSystemType = getFileSystemType(QFileInfo(path).absolutePath()); - - if (fileSystemType == "FAT32") { - invalidChars += BAD_FAT32_CHARS; - } else if (fileSystemType == "NTFS") { - invalidChars += BAD_NTFS_CHARS; - } else if (fileSystemType == "HFS+" || fileSystemType == "APFS") { - invalidChars += BAD_HFS_CHARS; - } else if (fileSystemType == "exFAT") { - invalidChars += BAD_EXFAT_CHARS; + switch (statFS(path).fsType) { + case FilesystemType::FAT: + invalidChars += BAD_FAT_CHARS; + break; + case FilesystemType::NTFS: + invalidChars += BAD_NTFS_CHARS; + break; + // case FilesystemType::REFS: + // case FilesystemType::EXT: + // case FilesystemType::EXT_2_OLD: + // case FilesystemType::EXT_2_3_4: + // case FilesystemType::XFS: + // case FilesystemType::BTRFS: + // case FilesystemType::NFS: + // case FilesystemType::ZFS: + case FilesystemType::APFS: + /* fallthrough */ + case FilesystemType::HFS: + /* fallthrough */ + case FilesystemType::HFSPLUS: + /* fallthrough */ + case FilesystemType::HFSX: + invalidChars += BAD_HFS_CHARS; + break; + // case FilesystemType::FUSEBLK: + // case FilesystemType::F2FS: + // case FilesystemType::UNKNOWN: + default: + break; } if (invalidChars.size() != 0) { From d1286bbe909bb51b74ab266ed190682d38e29776 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 30 May 2024 21:54:32 +0300 Subject: [PATCH 11/16] add some comments Signed-off-by: Trial97 --- launcher/FileSystem.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 3ded638ae..7a34e8a5d 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -831,14 +831,16 @@ QString RemoveInvalidPathChars(QString path, QChar replaceWith) invalidChars = BAD_WIN_CHARS; #endif + // the null character is ignored in this check as it was not a problem until now switch (statFS(path).fsType) { case FilesystemType::FAT: invalidChars += BAD_FAT_CHARS; break; case FilesystemType::NTFS: + /* fallthrough */ + case FilesystemType::REFS: // similar to NTFS(should be available only on windows) invalidChars += BAD_NTFS_CHARS; break; - // case FilesystemType::REFS: // case FilesystemType::EXT: // case FilesystemType::EXT_2_OLD: // case FilesystemType::EXT_2_3_4: From 2635d7c3be79f888d7a0bdfafda8024432b6fa98 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 31 May 2024 09:07:51 +0300 Subject: [PATCH 12/16] replaced grid with vertical layout on all add modpack pages Signed-off-by: Trial97 --- .../pages/modplatform/atlauncher/AtlPage.ui | 118 +++++++++--------- .../ui/pages/modplatform/flame/FlamePage.cpp | 2 +- .../ui/pages/modplatform/flame/FlamePage.ui | 10 +- .../modplatform/import_ftb/ImportFTBPage.ui | 86 ++++++------- .../ui/pages/modplatform/legacy_ftb/Page.ui | 38 +++--- .../modplatform/modrinth/ModrinthPage.cpp | 2 +- .../modplatform/modrinth/ModrinthPage.ui | 8 +- .../pages/modplatform/technic/TechnicPage.cpp | 2 +- .../pages/modplatform/technic/TechnicPage.ui | 78 ++++++------ 9 files changed, 172 insertions(+), 172 deletions(-) diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlPage.ui b/launcher/ui/pages/modplatform/atlauncher/AtlPage.ui index c8b9aa8c0..0b1411b96 100644 --- a/launcher/ui/pages/modplatform/atlauncher/AtlPage.ui +++ b/launcher/ui/pages/modplatform/atlauncher/AtlPage.ui @@ -10,65 +10,8 @@ 685 - - - - - - - - - - Version selected: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - true - - - true - - - - - - - true - - - - 96 - 48 - - - - - - - - - - Search and filter... - - - true - - - - + + @@ -86,6 +29,63 @@ + + + + Search and filter... + + + true + + + + + + + + + true + + + + 96 + 48 + + + + + + + + true + + + true + + + + + + + + + + + + + + Version selected: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.cpp b/launcher/ui/pages/modplatform/flame/FlamePage.cpp index 8c2bcefaa..dbb5fb8bc 100644 --- a/launcher/ui/pages/modplatform/flame/FlamePage.cpp +++ b/launcher/ui/pages/modplatform/flame/FlamePage.cpp @@ -71,7 +71,7 @@ FlamePage::FlamePage(NewInstanceDialog* dialog, QWidget* parent) m_fetch_progress.setFixedHeight(24); m_fetch_progress.progressFormat(""); - ui->gridLayout->addWidget(&m_fetch_progress, 2, 0, 1, ui->gridLayout->columnCount()); + ui->verticalLayout->insertWidget(2, &m_fetch_progress); // index is used to set the sorting with the curseforge api ui->sortByBox->addItem(tr("Sort by Featured")); diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.ui b/launcher/ui/pages/modplatform/flame/FlamePage.ui index a8d88050a..d4ddb37a4 100644 --- a/launcher/ui/pages/modplatform/flame/FlamePage.ui +++ b/launcher/ui/pages/modplatform/flame/FlamePage.ui @@ -10,8 +10,8 @@ 600 - - + + @@ -29,14 +29,14 @@ - + Search and filter... - + @@ -66,7 +66,7 @@ - + diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui index 1b626745a..18c604ca4 100644 --- a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui +++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui @@ -10,45 +10,18 @@ 1011 - - - - - - 16777215 - 16777215 - + + + + + Note: If your FTB instances are not in the default location, select it using the button next to search. + + + Qt::AlignCenter - - - - - - - 265 - 0 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - + @@ -79,16 +52,43 @@ - - - - Note: If your FTB instances are not in the default location, select it using the button next to search. - - - Qt::AlignCenter + + + + + 16777215 + 16777215 + + + + + + + + 265 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/launcher/ui/pages/modplatform/legacy_ftb/Page.ui b/launcher/ui/pages/modplatform/legacy_ftb/Page.ui index ae8b2ea5d..544ad77d3 100644 --- a/launcher/ui/pages/modplatform/legacy_ftb/Page.ui +++ b/launcher/ui/pages/modplatform/legacy_ftb/Page.ui @@ -10,8 +10,8 @@ 602 - - + + @@ -25,7 +25,7 @@ - + 0 @@ -127,22 +127,9 @@ - - - - - - Version selected: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - + + + @@ -152,6 +139,19 @@ + + + + Version selected: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp index 94bf8715c..e76e5bf70 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp @@ -74,7 +74,7 @@ ModrinthPage::ModrinthPage(NewInstanceDialog* dialog, QWidget* parent) m_fetch_progress.setFixedHeight(24); m_fetch_progress.progressFormat(""); - ui->gridLayout->addWidget(&m_fetch_progress, 1, 0, 1, ui->gridLayout->columnCount()); + ui->verticalLayout->insertWidget(1, &m_fetch_progress); ui->sortByBox->addItem(tr("Sort by Relevance")); ui->sortByBox->addItem(tr("Sort by Total Downloads")); diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui index 16d2b3835..7f4f903f6 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui @@ -10,15 +10,15 @@ 600 - - + + Search and filter ... - + @@ -48,7 +48,7 @@ - + diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.cpp b/launcher/ui/pages/modplatform/technic/TechnicPage.cpp index a6bce9ac2..43f006a6b 100644 --- a/launcher/ui/pages/modplatform/technic/TechnicPage.cpp +++ b/launcher/ui/pages/modplatform/technic/TechnicPage.cpp @@ -70,7 +70,7 @@ TechnicPage::TechnicPage(NewInstanceDialog* dialog, QWidget* parent) m_fetch_progress.setFixedHeight(24); m_fetch_progress.progressFormat(""); - ui->gridLayout->addWidget(&m_fetch_progress, 2, 0, 1, ui->gridLayout->columnCount()); + ui->verticalLayout->insertWidget(1, &m_fetch_progress); connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &TechnicPage::onSelectionChanged); connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &TechnicPage::onVersionSelectionChanged); diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.ui b/launcher/ui/pages/modplatform/technic/TechnicPage.ui index 1e825ff7a..f4e75ae12 100644 --- a/launcher/ui/pages/modplatform/technic/TechnicPage.ui +++ b/launcher/ui/pages/modplatform/technic/TechnicPage.ui @@ -10,23 +10,41 @@ 405 - - - - - - - - - - Version selected: + + + + + Search and filter... + + + + + + + + + true - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 48 + 48 + - + + + + true + + + + + + + + Qt::Horizontal @@ -42,39 +60,21 @@ - - - - - - - - true + + + + Version selected: - - - 48 - 48 - + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - true - - + + - - - - Search and filter... - - - From f4f0a61bf23d5c40fa4310c050e4c39e6a8ce746 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 26 May 2024 09:59:38 +0300 Subject: [PATCH 13/16] fix vanilla technic modpacks Signed-off-by: Trial97 --- launcher/modplatform/technic/TechnicPackProcessor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/launcher/modplatform/technic/TechnicPackProcessor.cpp b/launcher/modplatform/technic/TechnicPackProcessor.cpp index a47a4811f..9050e14d8 100644 --- a/launcher/modplatform/technic/TechnicPackProcessor.cpp +++ b/launcher/modplatform/technic/TechnicPackProcessor.cpp @@ -83,8 +83,10 @@ void Technic::TechnicPackProcessor::run(SettingsObjectPtr globalSettings, data = file.readAll(); file.close(); } else { - if (minecraftVersion.isEmpty()) + if (minecraftVersion.isEmpty()) { emit failed(tr("Could not find \"version.json\" inside \"bin/modpack.jar\", but Minecraft version is unknown")); + return; + } components->setComponentVersion("net.minecraft", minecraftVersion, true); components->installJarMods({ modpackJar }); @@ -131,7 +133,9 @@ void Technic::TechnicPackProcessor::run(SettingsObjectPtr globalSettings, file.close(); } else { // This is the "Vanilla" modpack, excluded by the search code - emit failed(tr("Unable to find a \"version.json\"!")); + components->setComponentVersion("net.minecraft", minecraftVersion, true); + components->saveNow(); + emit succeeded(); return; } From 1c1e296960783896358d8db51d9e30819f1466ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=AB=E4=B9=90=E7=9A=84=E8=80=81=E9=BC=A0=E5=AE=9D?= =?UTF-8?q?=E5=AE=9D?= Date: Mon, 10 Jun 2024 17:15:38 +0800 Subject: [PATCH 14/16] fix(SkinManageDialog.cpp): typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 快乐的老鼠宝宝 --- launcher/ui/dialogs/skins/SkinManageDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/dialogs/skins/SkinManageDialog.cpp b/launcher/ui/dialogs/skins/SkinManageDialog.cpp index eb22102ee..d676ac38c 100644 --- a/launcher/ui/dialogs/skins/SkinManageDialog.cpp +++ b/launcher/ui/dialogs/skins/SkinManageDialog.cpp @@ -484,7 +484,7 @@ void SkinManageDialog::on_userBtn_clicked() if (failReason.isEmpty()) { failReason = tr("the skin is invalid"); } - CustomMessageBox::selectable(this, tr("Usename not found"), + CustomMessageBox::selectable(this, tr("Username not found"), tr("Unable to find the skin for '%1'\n because: %2.").arg(user, failReason), QMessageBox::Critical) ->show(); QFile::remove(path); @@ -497,4 +497,4 @@ void SkinManageDialog::on_userBtn_clicked() s.setCapeId(mcProfile.currentCape); } m_list.updateSkin(&s); -} \ No newline at end of file +} From c1c182fd0c9051a202a0cc7c1d471b9de6997697 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 10 Jun 2024 12:38:59 +0300 Subject: [PATCH 15/16] update imgur upload Signed-off-by: Trial97 --- launcher/screenshots/ImgurAlbumCreation.cpp | 4 ++-- launcher/screenshots/ImgurUpload.cpp | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/launcher/screenshots/ImgurAlbumCreation.cpp b/launcher/screenshots/ImgurAlbumCreation.cpp index 7e42ff40c..c63c8b39b 100644 --- a/launcher/screenshots/ImgurAlbumCreation.cpp +++ b/launcher/screenshots/ImgurAlbumCreation.cpp @@ -51,7 +51,7 @@ Net::NetRequest::Ptr ImgurAlbumCreation::make(std::shared_ptr output, QList screenshots) { auto up = makeShared(); - up->m_url = BuildConfig.IMGUR_BASE_URL + "album.json"; + up->m_url = BuildConfig.IMGUR_BASE_URL + "album"; up->m_sink.reset(new Sink(output)); up->m_screenshots = screenshots; return up; @@ -72,7 +72,7 @@ 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() }, + { "Authorization", QString("Client-ID %1").arg(BuildConfig.IMGUR_CLIENT_ID).toUtf8() }, { "Accept", "application/json" } }); addHeaderProxy(api_headers); } diff --git a/launcher/screenshots/ImgurUpload.cpp b/launcher/screenshots/ImgurUpload.cpp index 15fb043e4..941b92ce6 100644 --- a/launcher/screenshots/ImgurUpload.cpp +++ b/launcher/screenshots/ImgurUpload.cpp @@ -50,9 +50,8 @@ void ImgurUpload::init() { 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" } }); + auto api_headers = new Net::StaticHeaderProxy(QList{ + { "Authorization", QString("Client-ID %1").arg(BuildConfig.IMGUR_CLIENT_ID).toUtf8() }, { "Accept", "application/json" } }); addHeaderProxy(api_headers); } @@ -70,14 +69,14 @@ QNetworkReply* ImgurUpload::getReply(QNetworkRequest& request) QHttpPart filePart; filePart.setBodyDevice(file); filePart.setHeader(QNetworkRequest::ContentTypeHeader, "image/png"); - filePart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"image\""); + filePart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"image\"; filename=\"" + file->fileName() + "\""); multipart->append(filePart); QHttpPart typePart; typePart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"type\""); typePart.setBody("file"); multipart->append(typePart); QHttpPart namePart; - namePart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"name\""); + namePart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"title\""); namePart.setBody(m_fileInfo.baseName().toUtf8()); multipart->append(namePart); @@ -124,7 +123,7 @@ auto ImgurUpload::Sink::finalize(QNetworkReply&) -> Task::State Net::NetRequest::Ptr ImgurUpload::make(ScreenShot::Ptr m_shot) { auto up = makeShared(m_shot->m_file); - up->m_url = std::move(BuildConfig.IMGUR_BASE_URL + "upload.json"); + up->m_url = std::move(BuildConfig.IMGUR_BASE_URL + "image"); up->m_sink.reset(new Sink(m_shot)); return up; } From 52338f0e884bd4f7f22cca6ae34ef6dd06f4374b Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 13 Jun 2024 19:55:50 +0200 Subject: [PATCH 16/16] fix(flatpak): disable docs for glfw Signed-off-by: Sefa Eyeoglu --- flatpak/org.prismlauncher.PrismLauncher.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flatpak/org.prismlauncher.PrismLauncher.yml b/flatpak/org.prismlauncher.PrismLauncher.yml index 352992c77..bd09f7fd8 100644 --- a/flatpak/org.prismlauncher.PrismLauncher.yml +++ b/flatpak/org.prismlauncher.PrismLauncher.yml @@ -64,7 +64,8 @@ modules: config-opts: - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DBUILD_SHARED_LIBS:BOOL=ON - - -DGLFW_USE_WAYLAND=ON + - -DGLFW_USE_WAYLAND:BOOL=ON + - -DGLFW_BUILD_DOCS:BOOL=OFF sources: - type: git url: https://github.com/glfw/glfw.git