summaryrefslogtreecommitdiffstats
path: root/logic/LiteLoaderInstaller.cpp
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2013-12-28 23:34:18 +0100
committerJan Dalheimer <jan@dalheimer.de>2013-12-28 23:34:18 +0100
commit5b54a4ca8c4849a4476bb9a5e1c2414463949621 (patch)
tree80705f47867cad113f0b3d83442ab1434b6ea091 /logic/LiteLoaderInstaller.cpp
parent55e62a81b69663041cb2402f779d0d957c499cb1 (diff)
downloadMultiMC-5b54a4ca8c4849a4476bb9a5e1c2414463949621.tar
MultiMC-5b54a4ca8c4849a4476bb9a5e1c2414463949621.tar.gz
MultiMC-5b54a4ca8c4849a4476bb9a5e1c2414463949621.tar.lz
MultiMC-5b54a4ca8c4849a4476bb9a5e1c2414463949621.tar.xz
MultiMC-5b54a4ca8c4849a4476bb9a5e1c2414463949621.zip
Don't hardcode stuff!!!
Diffstat (limited to 'logic/LiteLoaderInstaller.cpp')
-rw-r--r--logic/LiteLoaderInstaller.cpp88
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);
}