| 45 | } |
| 46 | |
| 47 | void LaunchController::decideAccount() |
| 48 | { |
| 49 | if(m_accountToUse) { |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | // Find an account to use. |
| 54 | auto accounts = APPLICATION->accounts(); |
| 55 | if (accounts->count() <= 0) |
| 56 | { |
| 57 | // Tell the user they need to log in at least one account in order to play. |
| 58 | auto reply = CustomMessageBox::selectable( |
| 59 | m_parentWidget, |
| 60 | tr("No Accounts"), |
| 61 | tr("In order to play Minecraft, you must have at least one Mojang or Minecraft " |
| 62 | "account logged in." |
| 63 | "Would you like to open the account manager to add an account now?"), |
| 64 | QMessageBox::Information, |
| 65 | QMessageBox::Yes | QMessageBox::No |
| 66 | )->exec(); |
| 67 | |
| 68 | if (reply == QMessageBox::Yes) |
| 69 | { |
| 70 | // Open the account manager. |
| 71 | APPLICATION->ShowGlobalSettings(m_parentWidget, "accounts"); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | m_accountToUse = accounts->defaultAccount(); |
| 76 | if (!m_accountToUse) |
| 77 | { |
| 78 | // If no default account is set, ask the user which one to use. |
| 79 | ProfileSelectDialog selectDialog( |
| 80 | tr("Which account would you like to use?"), |
| 81 | ProfileSelectDialog::GlobalDefaultCheckbox, |
| 82 | m_parentWidget |
| 83 | ); |
| 84 | |
| 85 | selectDialog.exec(); |
| 86 | |
| 87 | // Launch the instance with the selected account. |
| 88 | m_accountToUse = selectDialog.selectedAccount(); |
| 89 | |
| 90 | // If the user said to use the account as default, do that. |
| 91 | if (selectDialog.useAsGlobalDefault() && m_accountToUse) { |
| 92 | accounts->setDefaultAccount(m_accountToUse); |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | |
| 98 | void LaunchController::login() { |
nothing calls this directly
no test coverage detected