| 365 | } |
| 366 | |
| 367 | void LaunchController::launchInstance() |
| 368 | { |
| 369 | Q_ASSERT(m_instance != nullptr); |
| 370 | Q_ASSERT(m_session.get() != nullptr); |
| 371 | |
| 372 | if (!m_instance->reloadSettings()) { |
| 373 | QMessageBox::critical(m_parentWidget, tr("Error!"), tr("Couldn't load the instance profile.")); |
| 374 | emitFailed(tr("Couldn't load the instance profile.")); |
| 375 | return; |
| 376 | } |
| 377 | |
| 378 | m_launcher = m_instance->createLaunchTask(m_session, m_targetToJoin); |
| 379 | if (!m_launcher) { |
| 380 | emitFailed(tr("Couldn't instantiate a launcher.")); |
| 381 | return; |
| 382 | } |
| 383 | |
| 384 | const auto* console = qobject_cast<InstanceWindow*>(m_parentWidget); |
| 385 | const auto showConsole = m_instance->settings()->get("ShowConsole").toBool(); |
| 386 | if (!console && showConsole) { |
| 387 | APPLICATION->showInstanceWindow(m_instance); |
| 388 | } |
| 389 | connect(m_launcher, &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch); |
| 390 | connect(m_launcher, &LaunchTask::succeeded, this, &LaunchController::onSucceeded); |
| 391 | connect(m_launcher, &LaunchTask::failed, this, &LaunchController::onFailed); |
| 392 | connect(m_launcher, &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested); |
| 393 | |
| 394 | // Prepend Online and Auth Status |
| 395 | QString online_mode; |
| 396 | if (m_actualLaunchMode == LaunchMode::Normal) { |
| 397 | online_mode = "online"; |
| 398 | |
| 399 | // Prepend Server Status |
| 400 | QStringList servers; |
| 401 | if (m_session->wantsElyPatch) { |
| 402 | servers = { "ely.by", "account.ely.by", "skinsystem.ely.by" }; |
| 403 | } else { |
| 404 | servers = { "login.microsoftonline.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com" }; |
| 405 | } |
| 406 | |
| 407 | const auto s = APPLICATION->settings(); |
| 408 | const QString metaOverride = s->get("MetaURLOverride").toString(); |
| 409 | const QUrl metaUrl = !metaOverride.isEmpty() ? QUrl(metaOverride) : QUrl(BuildConfig.META_URL); |
| 410 | servers.prepend(metaUrl.host(QUrl::FullyEncoded)); |
| 411 | |
| 412 | m_launcher->prependStep(makeShared<PrintServers>(m_launcher, servers)); |
| 413 | } else { |
| 414 | online_mode = m_actualLaunchMode == LaunchMode::Demo ? "demo" : "offline"; |
| 415 | } |
| 416 | |
| 417 | m_launcher->prependStep(makeShared<TextPrint>(m_launcher, "Launched instance in " + online_mode + " mode\n", MessageLevel::Launcher)); |
| 418 | |
| 419 | // Prepend Version |
| 420 | { |
| 421 | auto versionString = QString("%1 version: %2 (%3)") |
| 422 | .arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString(), BuildConfig.BUILD_PLATFORM); |
| 423 | m_launcher->prependStep(makeShared<TextPrint>(m_launcher, versionString + "\n", MessageLevel::Launcher)); |
| 424 | } |
nothing calls this directly
no test coverage detected