From 9d23ac562f3e9ea5a20662551cd98ae0f0a1fa73 Mon Sep 17 00:00:00 2001
From: bexnoss <82064510+bexnoss@users.noreply.github.com>
Date: Mon, 17 Jan 2022 12:08:10 +0100
Subject: Add offline mode support
---
launcher/ui/pages/global/AccountListPage.cpp | 17 +++++++++++++++++
launcher/ui/pages/global/AccountListPage.h | 1 +
launcher/ui/pages/global/AccountListPage.ui | 6 ++++++
3 files changed, 24 insertions(+)
(limited to 'launcher/ui/pages')
diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp
index b8da6c75..b9aa7628 100644
--- a/launcher/ui/pages/global/AccountListPage.cpp
+++ b/launcher/ui/pages/global/AccountListPage.cpp
@@ -24,6 +24,7 @@
#include "net/NetJob.h"
#include "ui/dialogs/ProgressDialog.h"
+#include "ui/dialogs/OfflineLoginDialog.h"
#include "ui/dialogs/LoginDialog.h"
#include "ui/dialogs/MSALoginDialog.h"
#include "ui/dialogs/CustomMessageBox.h"
@@ -153,6 +154,22 @@ void AccountListPage::on_actionAddMicrosoft_triggered()
}
}
+void AccountListPage::on_actionAddOffline_triggered()
+{
+ MinecraftAccountPtr account = OfflineLoginDialog::newAccount(
+ this,
+ tr("Please enter your desired username to add your offline account.")
+ );
+
+ if (account)
+ {
+ m_accounts->addAccount(account);
+ if (m_accounts->count() == 1) {
+ m_accounts->setDefaultAccount(account);
+ }
+ }
+}
+
void AccountListPage::on_actionRemove_triggered()
{
QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes();
diff --git a/launcher/ui/pages/global/AccountListPage.h b/launcher/ui/pages/global/AccountListPage.h
index 1c65e708..841c3fd2 100644
--- a/launcher/ui/pages/global/AccountListPage.h
+++ b/launcher/ui/pages/global/AccountListPage.h
@@ -62,6 +62,7 @@ public:
public slots:
void on_actionAddMojang_triggered();
void on_actionAddMicrosoft_triggered();
+ void on_actionAddOffline_triggered();
void on_actionRemove_triggered();
void on_actionRefresh_triggered();
void on_actionSetDefault_triggered();
diff --git a/launcher/ui/pages/global/AccountListPage.ui b/launcher/ui/pages/global/AccountListPage.ui
index 29738c02..d21a92e2 100644
--- a/launcher/ui/pages/global/AccountListPage.ui
+++ b/launcher/ui/pages/global/AccountListPage.ui
@@ -54,6 +54,7 @@
+
@@ -103,6 +104,11 @@
Add Microsoft
+
+
+ Add Offline
+
+
Refresh
--
cgit
From e0a04c50316089b9a443355394c5babf39a1771d Mon Sep 17 00:00:00 2001
From: bexnoss <82064510+bexnoss@users.noreply.github.com>
Date: Mon, 17 Jan 2022 12:27:48 +0100
Subject: Lock offline mode support behind insertion of at least one Minecraft
account
Co-Authored-By: Naomi Calabretta
---
launcher/ui/pages/global/AccountListPage.cpp | 13 +++++++++++++
1 file changed, 13 insertions(+)
(limited to 'launcher/ui/pages')
diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp
index b9aa7628..396d320f 100644
--- a/launcher/ui/pages/global/AccountListPage.cpp
+++ b/launcher/ui/pages/global/AccountListPage.cpp
@@ -156,6 +156,19 @@ void AccountListPage::on_actionAddMicrosoft_triggered()
void AccountListPage::on_actionAddOffline_triggered()
{
+ if (!m_accounts->anyAccountIsValid()) {
+ QMessageBox::warning(
+ this,
+ tr("Error"),
+ tr(
+ "You must add a Microsoft or Mojang account that owns Minecraft before you can add an offline account."
+ "
"
+ "If you have lost your account you can contact Microsoft for support."
+ )
+ );
+ return;
+ }
+
MinecraftAccountPtr account = OfflineLoginDialog::newAccount(
this,
tr("Please enter your desired username to add your offline account.")
--
cgit