mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
merge dialogs
Signed-off-by: Tayou <git@tayou.org>
(cherry picked from commit 2425d2f8a3)
This commit is contained in:
parent
3fd432153c
commit
9c6e032404
2 changed files with 14 additions and 41 deletions
|
|
@ -40,8 +40,8 @@
|
||||||
#include "minecraft/auth/AccountData.h"
|
#include "minecraft/auth/AccountData.h"
|
||||||
#include "minecraft/auth/AccountList.h"
|
#include "minecraft/auth/AccountList.h"
|
||||||
|
|
||||||
#include "ui/InstanceWindow.h"
|
|
||||||
#include "net/NetUtils.h"
|
#include "net/NetUtils.h"
|
||||||
|
#include "ui/InstanceWindow.h"
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
#include "ui/dialogs/MSALoginDialog.h"
|
#include "ui/dialogs/MSALoginDialog.h"
|
||||||
#include "ui/dialogs/ProfileSelectDialog.h"
|
#include "ui/dialogs/ProfileSelectDialog.h"
|
||||||
|
|
@ -183,41 +183,6 @@ LaunchDecision LaunchController::decideLaunchMode()
|
||||||
|
|
||||||
QString reauthReason;
|
QString reauthReason;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case AccountState::Offline: {
|
|
||||||
if (m_wantedLaunchMode == LaunchMode::Normal) {
|
|
||||||
QMessageBox msg(m_parentWidget);
|
|
||||||
|
|
||||||
auto netErr = accountToCheck->accountData()->networkError;
|
|
||||||
if (Net::isServerError(netErr)) {
|
|
||||||
msg.setWindowTitle(tr("Auth servers offline"));
|
|
||||||
msg.setText(tr("The Minecraft authentication servers are currently unavailable.\n\n%1").arg(accountToCheck->lastError()));
|
|
||||||
} else {
|
|
||||||
msg.setWindowTitle(tr("No internet connection"));
|
|
||||||
msg.setText(tr("Unable to connect to the internet.\n\n%1").arg(accountToCheck->lastError()));
|
|
||||||
}
|
|
||||||
|
|
||||||
msg.setIcon(QMessageBox::Warning);
|
|
||||||
|
|
||||||
auto* launchOfflineButton = msg.addButton(tr("Launch Offline"), QMessageBox::AcceptRole);
|
|
||||||
auto* retryButton = msg.addButton(tr("Retry"), QMessageBox::ActionRole);
|
|
||||||
msg.addButton(tr("Cancel"), QMessageBox::RejectRole);
|
|
||||||
msg.setDefaultButton(launchOfflineButton);
|
|
||||||
|
|
||||||
msg.exec();
|
|
||||||
|
|
||||||
if (msg.clickedButton() == launchOfflineButton) {
|
|
||||||
m_actualLaunchMode = LaunchMode::Offline;
|
|
||||||
return LaunchDecision::Continue;
|
|
||||||
}
|
|
||||||
if (msg.clickedButton() == retryButton) {
|
|
||||||
return LaunchDecision::Undecided;
|
|
||||||
}
|
|
||||||
return LaunchDecision::Abort;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_actualLaunchMode = LaunchMode::Offline;
|
|
||||||
return LaunchDecision::Continue;
|
|
||||||
}
|
|
||||||
case AccountState::Errored:
|
case AccountState::Errored:
|
||||||
reauthReason = tr("An error occurred while refreshing '%1'").arg(accountToCheck->profileName());
|
reauthReason = tr("An error occurred while refreshing '%1'").arg(accountToCheck->profileName());
|
||||||
break;
|
break;
|
||||||
|
|
@ -261,13 +226,14 @@ bool LaunchController::askPlayDemo() const
|
||||||
return box.clickedButton() == demoButton;
|
return box.clickedButton() == demoButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LaunchController::askOfflineName(const QString& playerName, bool* ok) const
|
QString LaunchController::askOfflineName(const QString& playerName, bool* ok)
|
||||||
{
|
{
|
||||||
if (ok != nullptr) {
|
if (ok != nullptr) {
|
||||||
*ok = false;
|
*ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString message;
|
QString title, message;
|
||||||
|
title = tr("Player name");
|
||||||
switch (m_actualLaunchMode) {
|
switch (m_actualLaunchMode) {
|
||||||
case LaunchMode::Normal:
|
case LaunchMode::Normal:
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
|
|
@ -277,7 +243,14 @@ QString LaunchController::askOfflineName(const QString& playerName, bool* ok) co
|
||||||
break;
|
break;
|
||||||
case LaunchMode::Offline:
|
case LaunchMode::Offline:
|
||||||
if (m_wantedLaunchMode == LaunchMode::Normal) {
|
if (m_wantedLaunchMode == LaunchMode::Normal) {
|
||||||
message = tr("You are not connected to the Internet, launching in offline mode\n\n");
|
auto netErr = m_accountToUse->accountData()->networkError;
|
||||||
|
if (Net::isServerError(netErr)) {
|
||||||
|
title = tr("Auth servers offline");
|
||||||
|
message = tr("The Minecraft authentication servers are currently unavailable, launching in offline mode.\n\n");
|
||||||
|
} else {
|
||||||
|
title = tr("No internet connection");
|
||||||
|
message = tr("You are not connected to the Internet, launching in offline mode.\n\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
message += tr("Choose your offline mode player name");
|
message += tr("Choose your offline mode player name");
|
||||||
break;
|
break;
|
||||||
|
|
@ -287,7 +260,7 @@ QString LaunchController::askOfflineName(const QString& playerName, bool* ok) co
|
||||||
QString usedname = lastOfflinePlayerName.isEmpty() ? playerName : lastOfflinePlayerName;
|
QString usedname = lastOfflinePlayerName.isEmpty() ? playerName : lastOfflinePlayerName;
|
||||||
|
|
||||||
ChooseOfflineNameDialog dialog(message, m_parentWidget);
|
ChooseOfflineNameDialog dialog(message, m_parentWidget);
|
||||||
dialog.setWindowTitle(tr("Player name"));
|
dialog.setWindowTitle(title);
|
||||||
dialog.setUsername(usedname);
|
dialog.setUsername(usedname);
|
||||||
if (dialog.exec() != QDialog::Accepted) {
|
if (dialog.exec() != QDialog::Accepted) {
|
||||||
return {};
|
return {};
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class LaunchController : public Task {
|
||||||
void decideAccount();
|
void decideAccount();
|
||||||
LaunchDecision decideLaunchMode();
|
LaunchDecision decideLaunchMode();
|
||||||
bool askPlayDemo() const;
|
bool askPlayDemo() const;
|
||||||
QString askOfflineName(const QString& playerName, bool* ok = nullptr) const;
|
QString askOfflineName(const QString& playerName, bool* ok = nullptr);
|
||||||
bool reauthenticateAccount(const MinecraftAccountPtr& account, const QString& reason);
|
bool reauthenticateAccount(const MinecraftAccountPtr& account, const QString& reason);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue