| 80 | } |
| 81 | |
| 82 | void LaunchController::decideAccount() |
| 83 | { |
| 84 | if(m_accountToUse) { |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | // Find an account to use. |
| 89 | auto accounts = APPLICATION->accounts(); |
| 90 | if (accounts->count() <= 0) |
| 91 | { |
| 92 | // Tell the user they need to log in at least one account in order to play. |
| 93 | auto reply = CustomMessageBox::selectable( |
| 94 | m_parentWidget, |
| 95 | tr("No Accounts"), |
| 96 | tr("In order to play Minecraft, you must have at least one Microsoft or Mojang " |
| 97 | "account logged in. Mojang accounts can only be used offline. " |
| 98 | "Would you like to open the account manager to add an account now?"), |
| 99 | QMessageBox::Information, |
| 100 | QMessageBox::Yes | QMessageBox::No |
| 101 | )->exec(); |
| 102 | |
| 103 | if (reply == QMessageBox::Yes) |
| 104 | { |
| 105 | // Open the account manager. |
| 106 | APPLICATION->ShowGlobalSettings(m_parentWidget, "accounts"); |
| 107 | } |
| 108 | else if (reply == QMessageBox::No) |
| 109 | { |
| 110 | // Do not open "profile select" dialog. |
| 111 | return; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | bool overrideAccount = m_instance->settings()->get("OverrideAccount").toBool(); |
| 116 | QString overrideAccountProfileId = m_instance->settings()->get("OverrideAccountProfileId").toString(); |
| 117 | |
| 118 | m_accountToUse = accounts->defaultAccount(); |
| 119 | |
| 120 | if (overrideAccount) { |
| 121 | int overrideIndex = accounts->findAccountByProfileId(overrideAccountProfileId); |
| 122 | if (overrideIndex != -1) { |
| 123 | m_accountToUse = accounts->at(overrideIndex); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | if (!m_accountToUse) |
| 128 | { |
| 129 | // If no default account is set, ask the user which one to use. |
| 130 | ProfileSelectDialog selectDialog( |
| 131 | tr("Which account would you like to use?"), |
| 132 | ProfileSelectDialog::GlobalDefaultCheckbox, |
| 133 | m_parentWidget |
| 134 | ); |
| 135 | |
| 136 | selectDialog.exec(); |
| 137 | |
| 138 | // Launch the instance with the selected account. |
| 139 | m_accountToUse = selectDialog.selectedAccount(); |
nothing calls this directly
no test coverage detected