mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-10-04 17:09:25 +00:00
Fix conflict
This commit is contained in:
@@ -35,6 +35,8 @@ void LaunchController::executeTask()
|
||||
return;
|
||||
}
|
||||
|
||||
JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget);
|
||||
|
||||
login();
|
||||
}
|
||||
|
||||
@@ -90,8 +92,6 @@ void LaunchController::decideAccount()
|
||||
|
||||
|
||||
void LaunchController::login() {
|
||||
JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget);
|
||||
|
||||
decideAccount();
|
||||
|
||||
// if no account is selected, we bail
|
||||
@@ -113,120 +113,107 @@ void LaunchController::login() {
|
||||
{
|
||||
m_session = std::make_shared<AuthSession>();
|
||||
m_session->wants_online = m_online;
|
||||
shared_qobject_ptr<AccountTask> task;
|
||||
if(!password.isNull()) {
|
||||
task = m_accountToUse->login(m_session, password);
|
||||
}
|
||||
else {
|
||||
task = m_accountToUse->refresh(m_session);
|
||||
}
|
||||
if (task)
|
||||
{
|
||||
// We'll need to validate the access token to make sure the account
|
||||
// is still logged in.
|
||||
ProgressDialog progDialog(m_parentWidget);
|
||||
if (m_online)
|
||||
{
|
||||
progDialog.setSkipButton(true, tr("Play Offline"));
|
||||
m_accountToUse->fillSession(m_session);
|
||||
|
||||
switch(m_accountToUse->accountState()) {
|
||||
case AccountState::Offline: {
|
||||
m_session->wants_online = false;
|
||||
// NOTE: fallthrough is intentional
|
||||
}
|
||||
progDialog.execWithTask(task.get());
|
||||
if (!task->wasSuccessful())
|
||||
{
|
||||
auto failReasonNew = task->failReason();
|
||||
if(failReasonNew == "Invalid token." || failReasonNew == "Invalid Signature")
|
||||
{
|
||||
// account->invalidateClientToken();
|
||||
failReason = needLoginAgain;
|
||||
case AccountState::Online: {
|
||||
if(!m_session->wants_online) {
|
||||
// we ask the user for a player name
|
||||
bool ok = false;
|
||||
QString usedname = m_session->player_name;
|
||||
QString name = QInputDialog::getText(
|
||||
m_parentWidget,
|
||||
tr("Player name"),
|
||||
tr("Choose your offline mode player name."),
|
||||
QLineEdit::Normal,
|
||||
m_session->player_name,
|
||||
&ok
|
||||
);
|
||||
if (!ok)
|
||||
{
|
||||
tryagain = false;
|
||||
break;
|
||||
}
|
||||
if (name.length())
|
||||
{
|
||||
usedname = name;
|
||||
}
|
||||
m_session->MakeOffline(usedname);
|
||||
// offline flavored game from here :3
|
||||
}
|
||||
if(m_accountToUse->ownsMinecraft() && !m_accountToUse->hasProfile()) {
|
||||
auto entitlement = m_accountToUse->accountData()->minecraftEntitlement;
|
||||
QString errorString;
|
||||
if(!entitlement.canPlayMinecraft) {
|
||||
errorString = tr("The account does not own Minecraft. You need to purchase the game first to play it.");
|
||||
QMessageBox::warning(
|
||||
nullptr,
|
||||
tr("Missing Minecraft profile"),
|
||||
errorString,
|
||||
QMessageBox::StandardButton::Ok,
|
||||
QMessageBox::StandardButton::Ok
|
||||
);
|
||||
emitFailed(errorString);
|
||||
return;
|
||||
}
|
||||
// Now handle setting up a profile name here...
|
||||
ProfileSetupDialog dialog(m_accountToUse, m_parentWidget);
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
tryagain = true;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
emitFailed(tr("Received undetermined session status during login."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
launchInstance();
|
||||
}
|
||||
else failReason = failReasonNew;
|
||||
}
|
||||
}
|
||||
switch (m_session->status)
|
||||
{
|
||||
case AuthSession::Undetermined: {
|
||||
qCritical() << "Received undetermined session status during login. Bye.";
|
||||
tryagain = false;
|
||||
emitFailed(tr("Received undetermined session status during login."));
|
||||
return;
|
||||
}
|
||||
case AuthSession::RequiresPassword: {
|
||||
// FIXME: this needs to understand MSA
|
||||
EditAccountDialog passDialog(failReason, m_parentWidget, EditAccountDialog::PasswordField);
|
||||
auto username = m_session->username;
|
||||
auto chopN = [](QString toChop, int N) -> QString
|
||||
{
|
||||
if(toChop.size() > N)
|
||||
{
|
||||
auto left = toChop.left(N);
|
||||
left += QString("\u25CF").repeated(toChop.size() - N);
|
||||
return left;
|
||||
}
|
||||
return toChop;
|
||||
};
|
||||
|
||||
if(username.contains('@'))
|
||||
{
|
||||
auto parts = username.split('@');
|
||||
auto mailbox = chopN(parts[0],3);
|
||||
QString domain = chopN(parts[1], 3);
|
||||
username = mailbox + '@' + domain;
|
||||
}
|
||||
passDialog.setUsername(username);
|
||||
if (passDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
password = passDialog.password();
|
||||
}
|
||||
else
|
||||
{
|
||||
tryagain = false;
|
||||
emitFailed(tr("Received undetermined session status during login."));
|
||||
}
|
||||
break;
|
||||
case AccountState::Errored:
|
||||
// This means some sort of soft error that we can fix with a refresh ... so let's refresh.
|
||||
case AccountState::Unchecked: {
|
||||
m_accountToUse->refresh();
|
||||
// NOTE: fallthrough intentional
|
||||
}
|
||||
case AuthSession::RequiresProfileSetup: {
|
||||
auto entitlement = m_accountToUse->accountData()->minecraftEntitlement;
|
||||
QString errorString;
|
||||
if(!entitlement.canPlayMinecraft) {
|
||||
errorString = tr("The account does not own Minecraft. You need to purchase the game first to play it.");
|
||||
QMessageBox::warning(
|
||||
nullptr,
|
||||
tr("Missing Minecraft profile"),
|
||||
errorString,
|
||||
QMessageBox::StandardButton::Ok,
|
||||
QMessageBox::StandardButton::Ok
|
||||
);
|
||||
tryagain = false;
|
||||
emitFailed(errorString);
|
||||
return;
|
||||
}
|
||||
// Now handle setting up a profile name here...
|
||||
ProfileSetupDialog dialog(m_accountToUse, m_parentWidget);
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
case AccountState::Working: {
|
||||
// refresh is in progress, we need to wait for it to finish to proceed.
|
||||
ProgressDialog progDialog(m_parentWidget);
|
||||
if (m_online)
|
||||
{
|
||||
tryagain = true;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
tryagain = false;
|
||||
emitFailed(tr("Received undetermined session status during login."));
|
||||
return;
|
||||
progDialog.setSkipButton(true, tr("Play Offline"));
|
||||
}
|
||||
auto task = m_accountToUse->currentTask();
|
||||
progDialog.execWithTask(task.get());
|
||||
continue;
|
||||
}
|
||||
case AuthSession::RequiresOAuth: {
|
||||
auto errorString = tr("Microsoft account has expired and needs to be logged into manually again.");
|
||||
// FIXME: this is missing - the meaning is that the account is queued for refresh and we should wait for that
|
||||
/*
|
||||
case AccountState::Queued: {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
case AccountState::Expired: {
|
||||
auto errorString = tr("The account has expired and needs to be logged into manually again.");
|
||||
QMessageBox::warning(
|
||||
m_parentWidget,
|
||||
tr("Microsoft Account refresh failed"),
|
||||
tr("Account refresh failed"),
|
||||
errorString,
|
||||
QMessageBox::StandardButton::Ok,
|
||||
QMessageBox::StandardButton::Ok
|
||||
);
|
||||
tryagain = false;
|
||||
emitFailed(errorString);
|
||||
return;
|
||||
}
|
||||
case AuthSession::GoneOrMigrated: {
|
||||
case AccountState::Gone: {
|
||||
auto errorString = tr("The account no longer exists on the servers. It may have been migrated, in which case please add the new account you migrated this one to.");
|
||||
QMessageBox::warning(
|
||||
m_parentWidget,
|
||||
@@ -235,40 +222,9 @@ void LaunchController::login() {
|
||||
QMessageBox::StandardButton::Ok,
|
||||
QMessageBox::StandardButton::Ok
|
||||
);
|
||||
tryagain = false;
|
||||
emitFailed(errorString);
|
||||
return;
|
||||
}
|
||||
case AuthSession::PlayableOffline: {
|
||||
// we ask the user for a player name
|
||||
bool ok = false;
|
||||
QString usedname = m_session->player_name;
|
||||
QString name = QInputDialog::getText(
|
||||
m_parentWidget,
|
||||
tr("Player name"),
|
||||
tr("Choose your offline mode player name."),
|
||||
QLineEdit::Normal,
|
||||
m_session->player_name,
|
||||
&ok
|
||||
);
|
||||
if (!ok)
|
||||
{
|
||||
tryagain = false;
|
||||
break;
|
||||
}
|
||||
if (name.length())
|
||||
{
|
||||
usedname = name;
|
||||
}
|
||||
m_session->MakeOffline(usedname);
|
||||
// offline flavored game from here :3
|
||||
}
|
||||
case AuthSession::PlayableOnline:
|
||||
{
|
||||
launchInstance();
|
||||
tryagain = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
emitFailed(tr("Failed to launch."));
|
||||
@@ -334,14 +290,7 @@ void LaunchController::launchInstance()
|
||||
online_mode = "offline";
|
||||
}
|
||||
|
||||
QString auth_server_status;
|
||||
if(m_session->auth_server_online) {
|
||||
auth_server_status = "online";
|
||||
} else {
|
||||
auth_server_status = "offline";
|
||||
}
|
||||
|
||||
m_launcher->prependStep(new TextPrint(m_launcher.get(), "Launched instance in " + online_mode + " mode\nAuthentication server is " + auth_server_status + "\n", MessageLevel::Launcher));
|
||||
m_launcher->prependStep(new TextPrint(m_launcher.get(), "Launched instance in " + online_mode + " mode\n", MessageLevel::Launcher));
|
||||
|
||||
// Prepend Version
|
||||
m_launcher->prependStep(new TextPrint(m_launcher.get(), BuildConfig.LAUNCHER_NAME + " version: " + BuildConfig.printableVersionString() + "\n\n", MessageLevel::Launcher));
|
||||
|
Reference in New Issue
Block a user