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