| 717 | } |
| 718 | |
| 719 | QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftTarget::Ptr targetToJoin) |
| 720 | { |
| 721 | QString launchScript; |
| 722 | |
| 723 | if (!m_components) |
| 724 | return QString(); |
| 725 | auto profile = m_components->getProfile(); |
| 726 | if (!profile) |
| 727 | return QString(); |
| 728 | |
| 729 | auto mainClass = getMainClass(); |
| 730 | if (!mainClass.isEmpty()) { |
| 731 | launchScript += "mainClass " + mainClass + "\n"; |
| 732 | } |
| 733 | auto appletClass = profile->getAppletClass(); |
| 734 | if (!appletClass.isEmpty()) { |
| 735 | launchScript += "appletClass " + appletClass + "\n"; |
| 736 | } |
| 737 | |
| 738 | if (targetToJoin) { |
| 739 | if (!targetToJoin->address.isEmpty()) { |
| 740 | launchScript += "serverAddress " + targetToJoin->address + "\n"; |
| 741 | launchScript += "serverPort " + QString::number(targetToJoin->port) + "\n"; |
| 742 | } else if (!targetToJoin->world.isEmpty()) { |
| 743 | launchScript += "worldName " + targetToJoin->world + "\n"; |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | // generic minecraft params |
| 748 | for (auto param : processMinecraftArgs(session, nullptr /* When using a launch script, the server parameters are handled by it*/ |
| 749 | )) { |
| 750 | launchScript += "param " + param + "\n"; |
| 751 | } |
| 752 | |
| 753 | // window size, title and state, legacy |
| 754 | { |
| 755 | QString windowParams; |
| 756 | if (settings()->get("LaunchMaximized").toBool()) |
| 757 | windowParams = "maximized"; |
| 758 | else |
| 759 | windowParams = |
| 760 | QString("%1x%2").arg(settings()->get("MinecraftWinWidth").toInt()).arg(settings()->get("MinecraftWinHeight").toInt()); |
| 761 | launchScript += "windowTitle " + windowTitle() + "\n"; |
| 762 | launchScript += "windowParams " + windowParams + "\n"; |
| 763 | } |
| 764 | |
| 765 | // launcher info |
| 766 | { |
| 767 | launchScript += "launcherBrand " + BuildConfig.LAUNCHER_NAME + "\n"; |
| 768 | launchScript += "launcherVersion " + BuildConfig.printableVersionString() + "\n"; |
| 769 | } |
| 770 | |
| 771 | // instance info |
| 772 | { |
| 773 | launchScript += "instanceName " + name() + "\n"; |
| 774 | launchScript += "instanceIconKey " + name() + "\n"; |
| 775 | launchScript += "instanceIconPath icon.png\n"; // we already save a copy here |
| 776 | } |
no test coverage detected