aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
authorTheKodeToad <TheKodeToad@proton.me>2022-11-06 10:08:54 +0000
committerTheKodeToad <TheKodeToad@proton.me>2022-11-06 10:09:06 +0000
commit16e3b786fc04ffd8d510bfb2a60157648825954f (patch)
tree7b4875fd4e5c76f0f5e2b35e365060f21775824b /launcher
parentcb796dbdfbe2099bc77911c01c8633d9f28aedac (diff)
downloadPrismLauncher-16e3b786fc04ffd8d510bfb2a60157648825954f.tar.gz
PrismLauncher-16e3b786fc04ffd8d510bfb2a60157648825954f.tar.bz2
PrismLauncher-16e3b786fc04ffd8d510bfb2a60157648825954f.zip
Implement Scrumplex's suggestions
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Diffstat (limited to 'launcher')
-rw-r--r--launcher/ui/dialogs/ModDownloadDialog.cpp4
-rw-r--r--launcher/ui/dialogs/ModDownloadDialog.h2
-rw-r--r--launcher/ui/pages/modplatform/ModPage.cpp46
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.cpp5
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.h2
5 files changed, 27 insertions, 32 deletions
diff --git a/launcher/ui/dialogs/ModDownloadDialog.cpp b/launcher/ui/dialogs/ModDownloadDialog.cpp
index 0a0e61e3..24d23ba9 100644
--- a/launcher/ui/dialogs/ModDownloadDialog.cpp
+++ b/launcher/ui/dialogs/ModDownloadDialog.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
*
@@ -199,4 +199,4 @@ bool ModDownloadDialog::selectPage(QString pageId)
ModPage* ModDownloadDialog::getSelectedPage()
{
return m_selectedPage;
-} \ No newline at end of file
+}
diff --git a/launcher/ui/dialogs/ModDownloadDialog.h b/launcher/ui/dialogs/ModDownloadDialog.h
index 29bdcf82..fcf6f4fc 100644
--- a/launcher/ui/dialogs/ModDownloadDialog.h
+++ b/launcher/ui/dialogs/ModDownloadDialog.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
*
diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp
index ec6f488f..2f5f95bf 100644
--- a/launcher/ui/pages/modplatform/ModPage.cpp
+++ b/launcher/ui/pages/modplatform/ModPage.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
*
@@ -43,6 +43,7 @@
#include <memory>
#include <HoeDown.h>
+#include <qregularexpression.h>
#include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h"
@@ -254,32 +255,25 @@ void ModPage::openUrl(const QUrl& url)
}
// detect mod URLs and search instead
- int prefixLength = 0;
+ static const QRegularExpression modrinth(QRegularExpression::anchoredPattern("(?:www\\.)?modrinth\\.com\\/mod\\/([^\\/]+)\\/?")),
+ curseForge(QRegularExpression::anchoredPattern("(?:www\\.)?curseforge\\.com\\/minecraft\\/mc-mods\\/([^\\/]+)\\/?")),
+ curseForgeOld(QRegularExpression::anchoredPattern("minecraft\\.curseforge\\.com\\/projects\\/([^\\/]+)\\/?"));
+
+ const QString address = url.host() + url.path();
+ QRegularExpressionMatch match;
const char* page;
- if ((url.host() == "modrinth.com" || url.host() == "www.modrinth.com") && url.path().startsWith("/mod/")) {
- prefixLength = 5;
+ if ((match = modrinth.match(address)).hasMatch())
page = "modrinth";
- } else if (APPLICATION->capabilities() & Application::SupportsFlame &&
- (url.host() == "curseforge.com" || url.host().endsWith(".curseforge.com"))) {
- if (url.path().toLower().startsWith("/minecraft/mc-mods/"))
- prefixLength = 19;
- else if (url.path().toLower().startsWith("/projects/"))
- prefixLength = 10;
+ else if (APPLICATION->capabilities() & Application::SupportsFlame &&
+ ((match = curseForge.match(address)).hasMatch() || (match = curseForgeOld.match(address)).hasMatch()))
page = "curseforge";
- }
- if (prefixLength != 0) {
- QString slug = url.path().mid(prefixLength);
+ if (match.hasMatch()) {
+ const QString slug = match.captured(1);
- // remove trailing slash(es)
- while (slug.endsWith('/'))
- slug.remove(slug.length() - 1, 1);
-
- // ensure that the path doesn't contain any further slashes,
- // and the user isn't opening the same mod; they probably
- // intended to view in their web browser
- if (!slug.isEmpty() && !slug.contains('/') && slug != current.slug) {
+ // ensure the user isn't opening the same mod
+ if (slug != current.slug) {
dialog->selectPage(page);
ModPage* newPage = dialog->getSelectedPage();
@@ -290,8 +284,8 @@ void ModPage::openUrl(const QUrl& url)
auto jump = [url, slug, model, view] {
for (int row = 0; row < model->rowCount({}); row++) {
- QModelIndex index = model->index(row);
- auto pack = model->data(index, Qt::UserRole).value<ModPlatform::IndexedPack>();
+ const QModelIndex index = model->index(row);
+ const auto pack = model->data(index, Qt::UserRole).value<ModPlatform::IndexedPack>();
if (pack.slug == slug) {
view->setCurrentIndex(index);
@@ -306,10 +300,10 @@ void ModPage::openUrl(const QUrl& url)
searchEdit->setText(slug);
newPage->triggerSearch();
- if (!model->activeJob())
- jump();
- else
+ if (model->activeJob())
connect(model->activeJob(), &Task::finished, jump);
+ else
+ jump();
return;
}
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
index faf12cea..bad78c97 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
*
@@ -84,6 +84,7 @@ void FlameModPage::openUrl(const QUrl& url)
{
if (url.scheme().isEmpty()) {
QString query = url.query(QUrl::FullyDecoded);
+
if (query.startsWith("remoteUrl=")) {
// attempt to resolve url from warning page
query.remove(0, 10);
@@ -93,4 +94,4 @@ void FlameModPage::openUrl(const QUrl& url)
}
ModPage::openUrl(url);
-} \ No newline at end of file
+}
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.h b/launcher/ui/pages/modplatform/flame/FlameModPage.h
index da4fcdff..58479ab9 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.h
+++ b/launcher/ui/pages/modplatform/flame/FlameModPage.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
*