aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/ui/pages')
-rw-r--r--launcher/ui/pages/instance/LegacyUpgradePage.ui9
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.cpp22
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.h2
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp8
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp23
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.h2
6 files changed, 42 insertions, 24 deletions
diff --git a/launcher/ui/pages/instance/LegacyUpgradePage.ui b/launcher/ui/pages/instance/LegacyUpgradePage.ui
index 4e803358..b22c03e5 100644
--- a/launcher/ui/pages/instance/LegacyUpgradePage.ui
+++ b/launcher/ui/pages/instance/LegacyUpgradePage.ui
@@ -26,7 +26,14 @@
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="html">
- <string>&lt;html&gt;&lt;body&gt;&lt;h1&gt;Upgrade is required&lt;/h1&gt;&lt;p&gt;PolyMC now supports old Minecraft versions and all the required features in the new (OneSix) instance format. As a consequence, the old (Legacy) format has been entirely disabled and old instances need to be upgraded.&lt;/p&gt;&lt;p&gt;The upgrade will create a new instance with the same contents as the current one, in the new format. The original instance will remain untouched, in case anything goes wrong in the process.&lt;/p&gt;&lt;p&gt;Please report any issues on our &lt;a href=&quot;https://github.com/PolyMC/PolyMC/issues&quot;&gt;github issues page&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;There is also a &lt;a href=&quot;https://discord.gg/GtPmv93&quot;&gt;discord channel for testing here&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;h1 style=&quot; margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:xx-large; font-weight:600;&quot;&gt;Upgrade is required&lt;/span&gt;&lt;/h1&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;PolyMC now supports old Minecraft versions and all the required features in the new (OneSix) instance format. As a consequence, the old (Legacy) format has been entirely disabled and old instances need to be upgraded.&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The upgrade will create a new instance with the same contents as the current one, in the new format. The original instance will remain untouched, in case anything goes wrong in the process.&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Please report any issues on our &lt;a href=&quot;https://github.com/PolyMC/PolyMC/issues&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#3584e4;&quot;&gt;github issues page&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
index 80f3de19..a816c681 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
@@ -140,14 +140,15 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second)
auto packProfile = ((MinecraftInstance *)m_instance)->getPackProfile();
QString mcVersion = packProfile->getComponentVersion("net.minecraft");
QString loaderString = (packProfile->getComponentVersion("net.minecraftforge").isEmpty()) ? "fabric" : "forge";
- for(const auto& version : current.versions) {
+ for(int i = 0; i < current.versions.size(); i++) {
+ auto version = current.versions[i];
if(!version.mcVersion.contains(mcVersion)){
continue;
}
- ui->versionSelectionBox->addItem(version.version, QVariant(version.downloadUrl));
+ ui->versionSelectionBox->addItem(version.version, QVariant(i));
}
if(ui->versionSelectionBox->count() == 0){
- ui->versionSelectionBox->addItem(tr("No Valid Version found!"), QVariant(""));
+ ui->versionSelectionBox->addItem(tr("No Valid Version found!"), QVariant(-1));
}
suggestCurrent();
@@ -156,11 +157,11 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second)
}
else
{
- for(auto version : current.versions) {
- ui->versionSelectionBox->addItem(version.version, QVariant(version.downloadUrl));
+ for(int i = 0; i < current.versions.size(); i++) {
+ ui->versionSelectionBox->addItem(current.versions[i].version, QVariant(i));
}
if(ui->versionSelectionBox->count() == 0){
- ui->versionSelectionBox->addItem(tr("No Valid Version found!"), QVariant(""));
+ ui->versionSelectionBox->addItem(tr("No Valid Version found!"), QVariant(-1));
}
suggestCurrent();
}
@@ -173,22 +174,23 @@ void FlameModPage::suggestCurrent()
return;
}
- if (selectedVersion.isEmpty())
+ if (selectedVersion == -1)
{
dialog->setSuggestedMod();
return;
}
- dialog->setSuggestedMod(current.name, new ModDownloadTask(selectedVersion, current.versions.at(0).fileName ,dialog->mods));
+ auto version = current.versions[selectedVersion];
+ dialog->setSuggestedMod(current.name, new ModDownloadTask(version.downloadUrl, version.fileName , dialog->mods));
}
void FlameModPage::onVersionSelectionChanged(QString data)
{
if(data.isNull() || data.isEmpty())
{
- selectedVersion = "";
+ selectedVersion = -1;
return;
}
- selectedVersion = ui->versionSelectionBox->currentData().toString();
+ selectedVersion = ui->versionSelectionBox->currentData().toInt();
suggestCurrent();
}
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.h b/launcher/ui/pages/modplatform/flame/FlameModPage.h
index 85c68620..8fa3248a 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.h
+++ b/launcher/ui/pages/modplatform/flame/FlameModPage.h
@@ -63,5 +63,5 @@ private:
FlameMod::ListModel* listModel = nullptr;
FlameMod::IndexedPack current;
- QString selectedVersion;
+ int selectedVersion = -1;
};
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
index 71574156..5a18830a 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
@@ -3,12 +3,14 @@
#include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h"
#include "ModrinthPage.h"
+#include "ui/dialogs/ModDownloadDialog.h"
#include <Json.h>
#include <MMCStrings.h>
#include <Version.h>
#include <QtMath>
+#include <QMessageBox>
namespace Modrinth {
@@ -250,6 +252,12 @@ void Modrinth::ListModel::searchRequestFinished()
void Modrinth::ListModel::searchRequestFailed(QString reason)
{
+ if(jobPtr->first()->m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 409){
+ //409 Gone, notify user to update
+ QMessageBox::critical(nullptr, tr("Error"), tr("Modrinth API version too old!\nPlease update PolyMC!"));
+ //self-destruct
+ ((ModDownloadDialog *)((ModrinthPage *)parent())->parentWidget())->reject();
+ }
jobPtr.reset();
if(searchState == ResetRequested) {
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
index ee3c9e76..c5a54c29 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
@@ -125,14 +125,15 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second)
auto packProfile = ((MinecraftInstance *)m_instance)->getPackProfile();
QString mcVersion = packProfile->getComponentVersion("net.minecraft");
QString loaderString = (packProfile->getComponentVersion("net.minecraftforge").isEmpty()) ? "fabric" : "forge";
- for(const auto& version : current.versions) {
+ for(int i = 0; i < current.versions.size(); i++) {
+ auto version = current.versions[i];
if(!version.mcVersion.contains(mcVersion) || !version.loaders.contains(loaderString)){
continue;
}
- ui->versionSelectionBox->addItem(version.version, QVariant(version.downloadUrl));
+ ui->versionSelectionBox->addItem(version.version, QVariant(i));
}
if(ui->versionSelectionBox->count() == 0){
- ui->versionSelectionBox->addItem(tr("No Valid Version found !"), QVariant(""));
+ ui->versionSelectionBox->addItem(tr("No Valid Version found !"), QVariant(-1));
}
suggestCurrent();
@@ -141,11 +142,11 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second)
}
else
{
- for(auto version : current.versions) {
- ui->versionSelectionBox->addItem(version.version, QVariant(version.downloadUrl));
+ for(int i = 0; i < current.versions.size(); i++) {
+ ui->versionSelectionBox->addItem(current.versions[i].version, QVariant(i));
}
if(ui->versionSelectionBox->count() == 0){
- ui->versionSelectionBox->addItem(tr("No Valid Version found !"), QVariant(""));
+ ui->versionSelectionBox->addItem(tr("No Valid Version found !"), QVariant(-1));
}
suggestCurrent();
}
@@ -158,22 +159,22 @@ void ModrinthPage::suggestCurrent()
return;
}
- if (selectedVersion.isEmpty())
+ if (selectedVersion == -1)
{
dialog->setSuggestedMod();
return;
}
-
- dialog->setSuggestedMod(current.name, new ModDownloadTask(selectedVersion, current.versions.at(0).fileName ,dialog->mods));
+ auto version = current.versions[selectedVersion];
+ dialog->setSuggestedMod(current.name, new ModDownloadTask(version.downloadUrl, version.fileName , dialog->mods));
}
void ModrinthPage::onVersionSelectionChanged(QString data)
{
if(data.isNull() || data.isEmpty())
{
- selectedVersion = "";
+ selectedVersion = -1;
return;
}
- selectedVersion = ui->versionSelectionBox->currentData().toString();
+ selectedVersion = ui->versionSelectionBox->currentData().toInt();
suggestCurrent();
}
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
index 3748d836..3c517069 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
@@ -63,5 +63,5 @@ private:
Modrinth::ListModel* listModel = nullptr;
Modrinth::IndexedPack current;
- QString selectedVersion;
+ int selectedVersion = -1;
};