From 1f2bed2ef119094bdc156aa3a206b93dea5081d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 16 Jun 2016 02:20:23 +0200 Subject: NOISSUE implement direct java launch Just running the Java process and giving it params on the command line --- api/logic/minecraft/legacy/LegacyInstance.cpp | 198 ++++++++++++++++++-------- 1 file changed, 136 insertions(+), 62 deletions(-) (limited to 'api/logic/minecraft/legacy/LegacyInstance.cpp') diff --git a/api/logic/minecraft/legacy/LegacyInstance.cpp b/api/logic/minecraft/legacy/LegacyInstance.cpp index 28fd8872..7c552369 100644 --- a/api/logic/minecraft/legacy/LegacyInstance.cpp +++ b/api/logic/minecraft/legacy/LegacyInstance.cpp @@ -14,6 +14,7 @@ */ #include +#include #include #include @@ -21,14 +22,6 @@ #include "minecraft/legacy/LegacyUpdate.h" #include "minecraft/legacy/LegacyModList.h" -#include "launch/LaunchTask.h" -#include -#include -#include -#include -#include "minecraft/launch/LaunchMinecraft.h" -#include "minecraft/launch/ModMinecraftJar.h" -#include "java/launch/CheckJava.h" #include "minecraft/ModList.h" #include "minecraft/WorldList.h" #include @@ -102,58 +95,6 @@ std::shared_ptr LegacyInstance::createUpdateTask() return std::shared_ptr(new LegacyUpdate(this, this)); } -std::shared_ptr LegacyInstance::createLaunchTask(AuthSessionPtr session) -{ - auto process = LaunchTask::create(std::dynamic_pointer_cast(getSharedPtr())); - auto pptr = process.get(); - - // print a header - { - process->appendStep(std::make_shared(pptr, "Minecraft folder is:\n" + minecraftRoot() + "\n\n", MessageLevel::MultiMC)); - } - { - auto step = std::make_shared(pptr); - process->appendStep(step); - } - // run pre-launch command if that's needed - if(getPreLaunchCommand().size()) - { - auto step = std::make_shared(pptr); - step->setWorkingDirectory(minecraftRoot()); - process->appendStep(step); - } - // if we aren't in offline mode,. - if(session->status != AuthSession::PlayableOffline) - { - process->appendStep(std::make_shared(pptr)); - } - // if there are any jar mods - if(getJarMods().size()) - { - auto step = std::make_shared(pptr); - process->appendStep(step); - } - // actually launch the game - { - auto step = std::make_shared(pptr); - step->setWorkingDirectory(minecraftRoot()); - step->setAuthSession(session); - process->appendStep(step); - } - // run post-exit command if that's needed - if(getPostExitCommand().size()) - { - auto step = std::make_shared(pptr); - step->setWorkingDirectory(minecraftRoot()); - process->appendStep(step); - } - if (session) - { - process->setCensorFilter(createCensorFilterFromSession(session)); - } - return process; -} - std::shared_ptr LegacyInstance::createJarModdingTask() { class JarModTask : public Task @@ -255,11 +196,35 @@ QString LegacyInstance::createLaunchScript(AuthSessionPtr session) launchScript += "sessionId " + session->session + "\n"; launchScript += "windowTitle " + windowTitle() + "\n"; launchScript += "windowParams " + windowParams + "\n"; - launchScript += "lwjgl " + lwjgl + "\n"; - launchScript += "launcher legacy\n"; + launchScript += "cp bin/minecraft.jar\n"; + launchScript += "cp " + lwjgl + "/lwjgl.jar\n"; + launchScript += "cp " + lwjgl + "/lwjgl_util.jar\n"; + launchScript += "cp " + lwjgl + "/jinput.jar\n"; + launchScript += "natives " + lwjgl + "/natives\n"; + launchScript += "traits legacyLaunch\n"; + launchScript += "launcher onesix\n"; return launchScript; } +std::shared_ptr LegacyInstance::createMainLaunchStep(LaunchTask * parent, AuthSessionPtr session) +{ + auto step = std::make_shared(parent); + step->setWorkingDirectory(minecraftRoot()); + step->setAuthSession(session); + return step; +} + +QString LegacyInstance::launchMethod() +{ + return "Legacy"; +} + +QStringList LegacyInstance::validLaunchMethods() +{ + return {"Legacy"}; +} + + void LegacyInstance::cleanupAfterRun() { // FIXME: delete the launcher and icons and whatnot. @@ -452,3 +417,112 @@ QString LegacyInstance::typeName() const { return tr("Legacy"); } + +QStringList LegacyInstance::verboseDescription(AuthSessionPtr session) +{ + QStringList out; + + auto alltraits = traits(); + if(alltraits.size()) + { + out << "Traits:"; + for (auto trait : alltraits) + { + out << " " + trait; + } + out << ""; + } + + if(loaderModList()->size()) + { + out << "Mods:"; + for(auto & mod: loaderModList()->allMods()) + { + if(!mod.enabled()) + continue; + if(mod.type() == Mod::MOD_FOLDER) + continue; + // TODO: proper implementation would need to descend into folders. + + out << " " + mod.filename().completeBaseName(); + } + out << ""; + } + + if(coreModList()->size()) + { + out << "Core Mods:"; + for(auto & coremod: coreModList()->allMods()) + { + if(!coremod.enabled()) + continue; + if(coremod.type() == Mod::MOD_FOLDER) + continue; + // TODO: proper implementation would need to descend into folders. + + out << " " + coremod.filename().completeBaseName(); + } + out << ""; + } + + if(jarModList()->size()) + { + out << "Jar Mods:"; + for(auto & jarmod: jarModList()->allMods()) + { + out << " " + jarmod.name() + " (" + jarmod.filename().filePath() + ")"; + } + out << ""; + } + + QString windowParams; + if (settings()->get("LaunchMaximized").toBool()) + { + out << "Window size: max (if available)"; + } + else + { + auto width = settings()->get("MinecraftWinWidth").toInt(); + auto height = settings()->get("MinecraftWinHeight").toInt(); + out << "Window size: " + QString::number(width) + " x " + QString::number(height); + } + out << ""; + return out; +} + +QStringList LegacyInstance::getClassPath() const +{ + QString launchScript; + QString lwjgl = getNativePath(); + QStringList out = + { + "bin/minecraft.jar", + lwjgl + "/lwjgl.jar", + lwjgl + "/lwjgl_util.jar", + lwjgl + "/jinput.jar" + }; + return out; +} + +QString LegacyInstance::getMainClass() const +{ + return "net.minecraft.client.Minecraft"; +} + +QString LegacyInstance::getNativePath() const +{ + return QDir(m_lwjglFolderSetting->get().toString() + "/" + lwjglVersion()).absolutePath(); +} + +QStringList LegacyInstance::getNativeJars() const +{ + return {}; +} + +QStringList LegacyInstance::processMinecraftArgs(AuthSessionPtr account) const +{ + QStringList out; + out.append(account->player_name); + out.append(account->session); + return out; +} -- cgit v1.2.3