diff options
Diffstat (limited to 'logic/LiteLoaderInstaller.cpp')
-rw-r--r-- | logic/LiteLoaderInstaller.cpp | 88 |
1 files changed, 64 insertions, 24 deletions
diff --git a/logic/LiteLoaderInstaller.cpp b/logic/LiteLoaderInstaller.cpp index 7588ae6a..07fffff3 100644 --- a/logic/LiteLoaderInstaller.cpp +++ b/logic/LiteLoaderInstaller.cpp @@ -18,45 +18,85 @@ #include "OneSixVersion.h" #include "OneSixLibrary.h" -LiteLoaderInstaller::LiteLoaderInstaller() -{ - -} +QMap<QString, QString> LiteLoaderInstaller::m_launcherWrapperVersionMapping; -bool hasLibrary(const QString &rawName, const QList<std::shared_ptr<OneSixLibrary> > &libs) +LiteLoaderInstaller::LiteLoaderInstaller(const QString &mcVersion) : m_mcVersion(mcVersion) { - for (auto lib : libs) + if (m_launcherWrapperVersionMapping.isEmpty()) { - if (lib->rawName() == rawName) - { - return true; - } + m_launcherWrapperVersionMapping["1.6.2"] = "1.3"; + m_launcherWrapperVersionMapping["1.6.4"] = "1.8"; + //m_launcherWrapperVersionMapping["1.7.2"] = "1.8"; + //m_launcherWrapperVersionMapping["1.7.4"] = "1.8"; } - return false; +} + +bool LiteLoaderInstaller::canApply() const +{ + return m_launcherWrapperVersionMapping.contains(m_mcVersion); } bool LiteLoaderInstaller::apply(std::shared_ptr<OneSixVersion> to) { to->externalUpdateStart(); - if (!hasLibrary("net.minecraft:launchwrapper:1.8", to->libraries)) + applyLaunchwrapper(to); + applyLiteLoader(to); + + to->mainClass = "net.minecraft.launchwrapper.Launch"; + if (!to->minecraftArguments.contains( + " --tweakClass com.mumfrey.liteloader.launch.LiteLoaderTweaker")) { - std::shared_ptr<OneSixLibrary> lib(new OneSixLibrary("net.minecraft:launchwrapper:1.8")); - lib->finalize(); - to->libraries.prepend(lib); + to->minecraftArguments.append( + " --tweakClass com.mumfrey.liteloader.launch.LiteLoaderTweaker"); } - if (!hasLibrary("com.mumfrey:liteloader:1.6.4", to->libraries)) + to->externalUpdateFinish(); + return to->toOriginalFile(); +} + +void LiteLoaderInstaller::applyLaunchwrapper(std::shared_ptr<OneSixVersion> to) +{ + const QString intendedVersion = m_launcherWrapperVersionMapping[m_mcVersion]; + + QMutableListIterator<std::shared_ptr<OneSixLibrary>> it(to->libraries); + while (it.hasNext()) { - std::shared_ptr<OneSixLibrary> lib(new OneSixLibrary("com.mumfrey:liteloader:1.6.4")); - lib->setBaseUrl("http://dl.liteloader.com/versions/"); - lib->finalize(); - to->libraries.prepend(lib); + it.next(); + if (it.value()->rawName().startsWith("net.minecraft:launchwrapper:")) + { + if (it.value()->version() >= intendedVersion) + { + return; + } + else + { + it.remove(); + } + } } - to->mainClass = "net.minecraft.launchwrapper.Launch"; - to->minecraftArguments.append(" --tweakClass com.mumfrey.liteloader.launch.LiteLoaderTweaker"); + std::shared_ptr<OneSixLibrary> lib(new OneSixLibrary( + "net.minecraft:launchwrapper:" + m_launcherWrapperVersionMapping[m_mcVersion])); + lib->finalize(); + to->libraries.prepend(lib); +} - to->externalUpdateFinish(); - return to->toOriginalFile(); +void LiteLoaderInstaller::applyLiteLoader(std::shared_ptr<OneSixVersion> to) +{ + QMutableListIterator<std::shared_ptr<OneSixLibrary>> it(to->libraries); + while (it.hasNext()) + { + it.next(); + if (it.value()->rawName().startsWith("com.mumfrey:liteloader:")) + { + it.remove(); + } + } + + std::shared_ptr<OneSixLibrary> lib( + new OneSixLibrary("com.mumfrey:liteloader:" + m_mcVersion)); + lib->setBaseUrl("http://dl.liteloader.com/versions/"); + lib->finalize(); + to->libraries.prepend(lib); } |