aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/ui/pages')
-rw-r--r--launcher/ui/pages/global/APIPage.cpp16
-rw-r--r--launcher/ui/pages/global/APIPage.ui6
-rw-r--r--launcher/ui/pages/global/AccountListPage.cpp2
-rw-r--r--launcher/ui/pages/instance/ExternalResourcesPage.ui11
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.cpp83
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.h1
-rw-r--r--launcher/ui/pages/modplatform/ImportPage.ui2
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.cpp2
8 files changed, 110 insertions, 13 deletions
diff --git a/launcher/ui/pages/global/APIPage.cpp b/launcher/ui/pages/global/APIPage.cpp
index b889e6f7..e3d30475 100644
--- a/launcher/ui/pages/global/APIPage.cpp
+++ b/launcher/ui/pages/global/APIPage.cpp
@@ -40,8 +40,10 @@
#include <QMessageBox>
#include <QFileDialog>
+#include <QRegularExpression>
#include <QStandardPaths>
#include <QTabBar>
+#include <QValidator>
#include <QVariant>
#include "settings/SettingsObject.h"
@@ -63,6 +65,10 @@ APIPage::APIPage(QWidget *parent) :
};
static QRegularExpression validUrlRegExp("https?://.+");
+ static QRegularExpression validMSAClientID(QRegularExpression::anchoredPattern(
+ "[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}"));
+ static QRegularExpression validFlameKey(QRegularExpression::anchoredPattern(
+ "\\$2[ayb]\\$.{56}"));
ui->setupUi(this);
@@ -75,6 +81,8 @@ APIPage::APIPage(QWidget *parent) :
// This function needs to be called even when the ComboBox's index is still in its default state.
updateBaseURLPlaceholder(ui->pasteTypeComboBox->currentIndex());
ui->baseURLEntry->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->baseURLEntry));
+ ui->msaClientID->setValidator(new QRegularExpressionValidator(validMSAClientID, ui->msaClientID));
+ ui->flameKey->setValidator(new QRegularExpressionValidator(validFlameKey, ui->flameKey));
ui->metaURL->setPlaceholderText(BuildConfig.META_URL);
ui->userAgentLineEdit->setPlaceholderText(BuildConfig.USER_AGENT);
@@ -137,8 +145,8 @@ void APIPage::loadSettings()
ui->msaClientID->setText(msaClientID);
QString metaURL = s->get("MetaURLOverride").toString();
ui->metaURL->setText(metaURL);
- QString curseKey = s->get("CFKeyOverride").toString();
- ui->curseKey->setText(curseKey);
+ QString flameKey = s->get("FlameKeyOverride").toString();
+ ui->flameKey->setText(flameKey);
QString customUserAgent = s->get("UserAgentOverride").toString();
ui->userAgentLineEdit->setText(customUserAgent);
}
@@ -167,8 +175,8 @@ void APIPage::applySettings()
}
s->set("MetaURLOverride", metaURL);
- QString curseKey = ui->curseKey->text();
- s->set("CFKeyOverride", curseKey);
+ QString flameKey = ui->flameKey->text();
+ s->set("FlameKeyOverride", flameKey);
s->set("UserAgentOverride", ui->userAgentLineEdit->text());
}
diff --git a/launcher/ui/pages/global/APIPage.ui b/launcher/ui/pages/global/APIPage.ui
index 5327771c..1ae788c7 100644
--- a/launcher/ui/pages/global/APIPage.ui
+++ b/launcher/ui/pages/global/APIPage.ui
@@ -196,7 +196,7 @@
</widget>
</item>
<item>
- <widget class="QGroupBox" name="groupBox_curse">
+ <widget class="QGroupBox" name="groupBox_flame">
<property name="enabled">
<bool>true</bool>
</property>
@@ -214,7 +214,7 @@
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
- <string>Enter a custom API Key for CurseForge here. </string>
+ <string>Enter a custom API Key for CurseForge here.</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
@@ -228,7 +228,7 @@
</widget>
</item>
<item row="1" column="0">
- <widget class="QLineEdit" name="curseKey">
+ <widget class="QLineEdit" name="flameKey">
<property name="enabled">
<bool>true</bool>
</property>
diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp
index a608771e..fcc43add 100644
--- a/launcher/ui/pages/global/AccountListPage.cpp
+++ b/launcher/ui/pages/global/AccountListPage.cpp
@@ -96,7 +96,7 @@ AccountListPage::AccountListPage(QWidget *parent)
updateButtonStates();
// Xbox authentication won't work without a client identifier, so disable the button if it is missing
- if (APPLICATION->getMSAClientID().isEmpty()) {
+ if (~APPLICATION->currentCapabilities() & Application::SupportsMSA) {
ui->actionAddMicrosoft->setVisible(false);
ui->actionAddMicrosoft->setToolTip(tr("No Microsoft Authentication client ID was set."));
}
diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.ui b/launcher/ui/pages/instance/ExternalResourcesPage.ui
index 17bf455a..a13666b2 100644
--- a/launcher/ui/pages/instance/ExternalResourcesPage.ui
+++ b/launcher/ui/pages/instance/ExternalResourcesPage.ui
@@ -147,6 +147,17 @@
<string>Download a new resource</string>
</property>
</action>
+ <action name="actionUpdateItem">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Check for &amp;Updates</string>
+ </property>
+ <property name="toolTip">
+ <string>Try to check or update all selected resources (all resources if none are selected)</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp
index 4432ccc8..14e1f1e5 100644
--- a/launcher/ui/pages/instance/ModFolderPage.cpp
+++ b/launcher/ui/pages/instance/ModFolderPage.cpp
@@ -49,6 +49,7 @@
#include "ui/GuiUtil.h"
#include "ui/dialogs/CustomMessageBox.h"
#include "ui/dialogs/ModDownloadDialog.h"
+#include "ui/dialogs/ModUpdateDialog.h"
#include "DesktopServices.h"
@@ -78,6 +79,23 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
ui->actionsToolbar->insertActionBefore(ui->actionAddItem, ui->actionDownloadItem);
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);
+
+ connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
+ [this] { ui->actionUpdateItem->setEnabled(ui->treeView->selectionModel()->hasSelection() || !m_model->empty()); });
+
+ connect(mods.get(), &ModFolderModel::rowsInserted, this,
+ [this] { ui->actionUpdateItem->setEnabled(ui->treeView->selectionModel()->hasSelection() || !m_model->empty()); });
+
+ connect(mods.get(), &ModFolderModel::updateFinished, this, [this, mods] {
+ ui->actionUpdateItem->setEnabled(ui->treeView->selectionModel()->hasSelection() || !m_model->empty());
+
+ // Prevent a weird crash when trying to open the mods page twice in a session o.O
+ disconnect(mods.get(), &ModFolderModel::updateFinished, this, 0);
+ });
}
}
@@ -107,7 +125,6 @@ bool CoreModFolderPage::shouldDisplay() const
return false;
if (version->getComponent("net.minecraft")->getReleaseDateTime() < g_VersionFilterData.legacyCutoffDate)
return true;
-
}
return false;
}
@@ -118,7 +135,7 @@ void ModFolderPage::installMods()
return;
if (m_instance->typeName() != "Minecraft")
return; // this is a null instance or a legacy instance
-
+
auto profile = static_cast<MinecraftInstance*>(m_instance)->getPackProfile();
if (profile->getModLoaders() == ModAPI::Unspecified) {
QMessageBox::critical(this, tr("Error"), tr("Please install a mod loader first!"));
@@ -140,7 +157,7 @@ void ModFolderPage::installMods()
QStringList warnings = tasks->warnings();
if (warnings.count())
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
-
+
tasks->deleteLater();
});
@@ -155,3 +172,63 @@ void ModFolderPage::installMods()
m_model->update();
}
}
+
+void ModFolderPage::updateMods()
+{
+ auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
+
+ auto mods_list = m_model->selectedMods(selection);
+ bool use_all = mods_list.empty();
+ if (use_all)
+ mods_list = m_model->allMods();
+
+ ModUpdateDialog update_dialog(this, m_instance, m_model, mods_list);
+ update_dialog.checkCandidates();
+
+ if (update_dialog.aborted()) {
+ CustomMessageBox::selectable(this, tr("Aborted"), tr("The mod updater was aborted!"), QMessageBox::Warning)->show();
+ return;
+ }
+ if (update_dialog.noUpdates()) {
+ QString message{ tr("'%1' is up-to-date! :)").arg(mods_list.front()->name()) };
+ if (mods_list.size() > 1) {
+ if (use_all) {
+ message = tr("All mods are up-to-date! :)");
+ } else {
+ message = tr("All selected mods are up-to-date! :)");
+ }
+ }
+ CustomMessageBox::selectable(this, tr("Update checker"), message)
+ ->exec();
+ return;
+ }
+
+ if (update_dialog.exec()) {
+ ConcurrentTask* tasks = new ConcurrentTask(this);
+ connect(tasks, &Task::failed, [this, tasks](QString reason) {
+ CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
+ tasks->deleteLater();
+ });
+ connect(tasks, &Task::aborted, [this, tasks]() {
+ CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show();
+ tasks->deleteLater();
+ });
+ connect(tasks, &Task::succeeded, [this, tasks]() {
+ QStringList warnings = tasks->warnings();
+ if (warnings.count()) {
+ CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
+ }
+ tasks->deleteLater();
+ });
+
+ for (auto task : update_dialog.getTasks()) {
+ tasks->addTask(task);
+ }
+
+ ProgressDialog loadDialog(this);
+ loadDialog.setSkipButton(true, tr("Abort"));
+ loadDialog.execWithTask(tasks);
+
+ m_model->update();
+ }
+}
diff --git a/launcher/ui/pages/instance/ModFolderPage.h b/launcher/ui/pages/instance/ModFolderPage.h
index 19caa732..0a7fc9fa 100644
--- a/launcher/ui/pages/instance/ModFolderPage.h
+++ b/launcher/ui/pages/instance/ModFolderPage.h
@@ -56,6 +56,7 @@ class ModFolderPage : public ExternalResourcesPage {
private slots:
void installMods();
+ void updateMods();
};
class CoreModFolderPage : public ModFolderPage {
diff --git a/launcher/ui/pages/modplatform/ImportPage.ui b/launcher/ui/pages/modplatform/ImportPage.ui
index 77bc5da5..0a50e871 100644
--- a/launcher/ui/pages/modplatform/ImportPage.ui
+++ b/launcher/ui/pages/modplatform/ImportPage.ui
@@ -40,7 +40,7 @@
<item>
<widget class="QLabel" name="label_5">
<property name="text">
- <string>- Curseforge modpacks (ZIP)</string>
+ <string>- CurseForge modpacks (ZIP)</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
index 10d34218..772fd2e0 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
@@ -64,7 +64,7 @@ FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance* instance)
auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, ModAPI::ModLoaderTypes loaders) const -> bool
{
Q_UNUSED(loaders);
- return ver.mcVersion.contains(mineVer);
+ return ver.mcVersion.contains(mineVer) && !ver.downloadUrl.isEmpty();
}
// I don't know why, but doing this on the parent class makes it so that