| 583 | } |
| 584 | |
| 585 | QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) |
| 586 | { |
| 587 | QString launchScript; |
| 588 | |
| 589 | if (!m_components) |
| 590 | return QString(); |
| 591 | auto profile = m_components->getProfile(); |
| 592 | if(!profile) |
| 593 | return QString(); |
| 594 | |
| 595 | auto mainClass = getMainClass(); |
| 596 | if (!mainClass.isEmpty()) |
| 597 | { |
| 598 | launchScript += "mainClass " + mainClass + "\n"; |
| 599 | } |
| 600 | auto appletClass = profile->getAppletClass(); |
| 601 | if (!appletClass.isEmpty()) |
| 602 | { |
| 603 | launchScript += "appletClass " + appletClass + "\n"; |
| 604 | } |
| 605 | |
| 606 | if (serverToJoin && !serverToJoin->address.isEmpty()) |
| 607 | { |
| 608 | launchScript += "serverAddress " + serverToJoin->address + "\n"; |
| 609 | launchScript += "serverPort " + QString::number(serverToJoin->port) + "\n"; |
| 610 | } |
| 611 | |
| 612 | // generic minecraft params |
| 613 | for (auto param : processMinecraftArgs( |
| 614 | session, |
| 615 | nullptr /* When using a launch script, the server parameters are handled by it*/ |
| 616 | )) |
| 617 | { |
| 618 | launchScript += "param " + param + "\n"; |
| 619 | } |
| 620 | |
| 621 | // window size, title and state, legacy |
| 622 | { |
| 623 | QString windowParams; |
| 624 | if (settings()->get("LaunchMaximized").toBool()) |
| 625 | windowParams = "max"; |
| 626 | else |
| 627 | windowParams = QString("%1x%2") |
| 628 | .arg(settings()->get("MinecraftWinWidth").toInt()) |
| 629 | .arg(settings()->get("MinecraftWinHeight").toInt()); |
| 630 | launchScript += "windowTitle " + windowTitle() + "\n"; |
| 631 | launchScript += "windowParams " + windowParams + "\n"; |
| 632 | } |
| 633 | |
| 634 | // legacy auth |
| 635 | if(session) |
| 636 | { |
| 637 | launchScript += "userName " + session->player_name + "\n"; |
| 638 | launchScript += "sessionId " + session->session + "\n"; |
| 639 | } |
| 640 | |
| 641 | // libraries and class path. |
| 642 | { |
no test coverage detected