| 315 | } |
| 316 | |
| 317 | void LaunchController::launchInstance() |
| 318 | { |
| 319 | Q_ASSERT_X(m_instance != NULL, "launchInstance", "instance is NULL"); |
| 320 | Q_ASSERT_X(m_session.get() != nullptr, "launchInstance", "session is NULL"); |
| 321 | |
| 322 | if (!m_instance->reloadSettings()) { |
| 323 | QMessageBox::critical(m_parentWidget, tr("Error!"), tr("Couldn't load the instance profile.")); |
| 324 | emitFailed(tr("Couldn't load the instance profile.")); |
| 325 | return; |
| 326 | } |
| 327 | |
| 328 | m_launcher = m_instance->createLaunchTask(m_session, m_targetToJoin); |
| 329 | if (!m_launcher) { |
| 330 | emitFailed(tr("Couldn't instantiate a launcher.")); |
| 331 | return; |
| 332 | } |
| 333 | |
| 334 | auto console = qobject_cast<InstanceWindow*>(m_parentWidget); |
| 335 | auto showConsole = m_instance->settings()->get("ShowConsole").toBool(); |
| 336 | if (!console && showConsole) { |
| 337 | APPLICATION->showInstanceWindow(m_instance); |
| 338 | } |
| 339 | connect(m_launcher.get(), &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch); |
| 340 | connect(m_launcher.get(), &LaunchTask::succeeded, this, &LaunchController::onSucceeded); |
| 341 | connect(m_launcher.get(), &LaunchTask::failed, this, &LaunchController::onFailed); |
| 342 | connect(m_launcher.get(), &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested); |
| 343 | |
| 344 | // Prepend Online and Auth Status |
| 345 | QString online_mode; |
| 346 | if (m_session->wants_online) { |
| 347 | online_mode = "online"; |
| 348 | |
| 349 | // Prepend Server Status |
| 350 | QStringList servers = { "login.microsoftonline.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com" }; |
| 351 | |
| 352 | m_launcher->prependStep(makeShared<PrintServers>(m_launcher.get(), servers)); |
| 353 | } else { |
| 354 | online_mode = m_demo ? "demo" : "offline"; |
| 355 | } |
| 356 | |
| 357 | m_launcher->prependStep( |
| 358 | makeShared<TextPrint>(m_launcher.get(), "Launched instance in " + online_mode + " mode\n", MessageLevel::Launcher)); |
| 359 | |
| 360 | // Prepend Version |
| 361 | { |
| 362 | auto versionString = QString("%1 version: %2 (%3)") |
| 363 | .arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString(), BuildConfig.BUILD_PLATFORM); |
| 364 | m_launcher->prependStep(makeShared<TextPrint>(m_launcher.get(), versionString + "\n\n", MessageLevel::Launcher)); |
| 365 | } |
| 366 | m_launcher->start(); |
| 367 | } |
| 368 | |
| 369 | void LaunchController::readyForLaunch() |
| 370 | { |
nothing calls this directly
no test coverage detected