From c7dbc14885f72eb2b9d166a14c7723d2fc6a3202 Mon Sep 17 00:00:00 2001 From: robotbrain Date: Mon, 9 Dec 2013 19:13:35 -0500 Subject: Make it update the instance when it creates it, so you can install forge right away --- gui/MainWindow.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 8c75776d..324b770d 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -521,7 +521,7 @@ void MainWindow::on_actionAddInstance_triggered() newInstance->setName(newInstDlg.instName()); newInstance->setIconKey(newInstDlg.iconKey()); MMC->instances()->add(InstancePtr(newInstance)); - return; + break; case InstanceFactory::InstExists: { @@ -544,6 +544,77 @@ void MainWindow::on_actionAddInstance_triggered() break; } } + + //Copy-pasta to make it so you can't play without a real account + std::shared_ptr accounts = MMC->accounts(); + MojangAccountPtr account = accounts->activeAccount(); + if (accounts->count() <= 0) + { + // Tell the user they need to log in at least one account in order to play. + auto reply = CustomMessageBox::selectable(this, tr("No Accounts"), + tr("In order to use MultiMC, you must have at least one Mojang or Minecraft account logged in to MultiMC." + "Would you like to open the account manager to add an account now?"), + QMessageBox::Information, QMessageBox::Yes | QMessageBox::No)->exec(); + + if (reply == QMessageBox::Yes) + { + // Open the account manager. + on_actionManageAccounts_triggered(); + } + } + else if (account.get() == nullptr) + { + // If no default account is set, ask the user which one to use. + AccountSelectDialog selectDialog(tr("Which account would you like to use?"), + AccountSelectDialog::GlobalDefaultCheckbox, this); + + selectDialog.exec(); + + // Launch the instance with the selected account. + account = selectDialog.selectedAccount(); + + // If the user said to use the account as default, do that. + if (selectDialog.useAsGlobalDefault() && account.get() != nullptr) + accounts->setActiveAccount(account->username()); + } + + // if no account is selected, we bail + if (!account.get()) + return; + + // do the login. if the account has an access token, try to refresh it first. + if(account->accountStatus() != NotVerified) + { + // We'll need to validate the access token to make sure the account is still logged in. + ProgressDialog progDialog(this); + auto task = account->login(); + progDialog.exec(task.get()); + + auto status = account->accountStatus(); + if(status != NotVerified) + { + ProgressDialog loadDialog(this); + auto update = newInstance->doUpdate(false); + connect(update.get(), &Task::failed , [this](QString reason) { + QString error = QString("Initial instance load failed: %1").arg(reason); + CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show(); + }); + loadDialog.exec(update.get()); + } + // revert from online to verified. + account->downgrade(); + return; + } + if (loginWithPassword(account, tr("Your account is currently not logged in. Please enter your password to log in again."))) + { + ProgressDialog loadDialog(this); + auto update = newInstance->doUpdate(false); + connect(update.get(), &Task::failed , [this](QString reason) { + QString error = QString("Instance load failed: %1").arg(reason); + CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show(); + }); + loadDialog.exec(update.get()); + } } void MainWindow::on_actionCopyInstance_triggered() -- cgit v1.2.3 From 4d348581d3e7e1dc69ea28366d628852e778df18 Mon Sep 17 00:00:00 2001 From: robotbrain Date: Mon, 9 Dec 2013 19:16:58 -0500 Subject: Fix I think. --- gui/MainWindow.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'gui') diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 324b770d..4620e41a 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -600,6 +600,7 @@ void MainWindow::on_actionAddInstance_triggered() CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show(); }); loadDialog.exec(update.get()); + return; } // revert from online to verified. account->downgrade(); -- cgit v1.2.3 From 6eb512e5d63ad3c66640ccd5dc0f1275642c5198 Mon Sep 17 00:00:00 2001 From: robotbrainify Date: Tue, 10 Dec 2013 11:05:40 -0500 Subject: Fix my utter derp --- gui/MainWindow.cpp | 60 +----------------------------------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) (limited to 'gui') diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 4620e41a..07398cb7 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -548,65 +548,7 @@ void MainWindow::on_actionAddInstance_triggered() //Copy-pasta to make it so you can't play without a real account std::shared_ptr accounts = MMC->accounts(); MojangAccountPtr account = accounts->activeAccount(); - if (accounts->count() <= 0) - { - // Tell the user they need to log in at least one account in order to play. - auto reply = CustomMessageBox::selectable(this, tr("No Accounts"), - tr("In order to use MultiMC, you must have at least one Mojang or Minecraft account logged in to MultiMC." - "Would you like to open the account manager to add an account now?"), - QMessageBox::Information, QMessageBox::Yes | QMessageBox::No)->exec(); - - if (reply == QMessageBox::Yes) - { - // Open the account manager. - on_actionManageAccounts_triggered(); - } - } - else if (account.get() == nullptr) - { - // If no default account is set, ask the user which one to use. - AccountSelectDialog selectDialog(tr("Which account would you like to use?"), - AccountSelectDialog::GlobalDefaultCheckbox, this); - - selectDialog.exec(); - - // Launch the instance with the selected account. - account = selectDialog.selectedAccount(); - - // If the user said to use the account as default, do that. - if (selectDialog.useAsGlobalDefault() && account.get() != nullptr) - accounts->setActiveAccount(account->username()); - } - - // if no account is selected, we bail - if (!account.get()) - return; - - // do the login. if the account has an access token, try to refresh it first. - if(account->accountStatus() != NotVerified) - { - // We'll need to validate the access token to make sure the account is still logged in. - ProgressDialog progDialog(this); - auto task = account->login(); - progDialog.exec(task.get()); - - auto status = account->accountStatus(); - if(status != NotVerified) - { - ProgressDialog loadDialog(this); - auto update = newInstance->doUpdate(false); - connect(update.get(), &Task::failed , [this](QString reason) { - QString error = QString("Initial instance load failed: %1").arg(reason); - CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show(); - }); - loadDialog.exec(update.get()); - return; - } - // revert from online to verified. - account->downgrade(); - return; - } - if (loginWithPassword(account, tr("Your account is currently not logged in. Please enter your password to log in again."))) + if(account.get() != nullptr && account->accountStatus() != NotVerified) { ProgressDialog loadDialog(this); auto update = newInstance->doUpdate(false); -- cgit v1.2.3 From ecf7bcf18443a0a1bef4407d2a31129009e72c5a Mon Sep 17 00:00:00 2001 From: robotbrain Date: Tue, 10 Dec 2013 18:06:35 -0500 Subject: Nuke! --- gui/MainWindow.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'gui') diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 07398cb7..6db8e464 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -545,7 +545,6 @@ void MainWindow::on_actionAddInstance_triggered() } } - //Copy-pasta to make it so you can't play without a real account std::shared_ptr accounts = MMC->accounts(); MojangAccountPtr account = accounts->activeAccount(); if(account.get() != nullptr && account->accountStatus() != NotVerified) -- cgit v1.2.3