summaryrefslogtreecommitdiffstats
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
parent55e62a81b69663041cb2402f779d0d957c499cb1 (diff)
downloadMultiMC-5b54a4ca8c4849a4476bb9a5e1c2414463949621.tar
MultiMC-5b54a4ca8c4849a4476bb9a5e1c2414463949621.tar.gz
MultiMC-5b54a4ca8c4849a4476bb9a5e1c2414463949621.tar.lz
MultiMC-5b54a4ca8c4849a4476bb9a5e1c2414463949621.tar.xz
MultiMC-5b54a4ca8c4849a4476bb9a5e1c2414463949621.zip
Don't hardcode stuff!!!
-rw-r--r--gui/dialogs/OneSixModEditDialog.cpp12
-rw-r--r--logic/LiteLoaderInstaller.cpp88
-rw-r--r--logic/LiteLoaderInstaller.h13
3 files changed, 87 insertions, 26 deletions
diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp
index 0d54328a..fb422941 100644
--- a/gui/dialogs/OneSixModEditDialog.cpp
+++ b/gui/dialogs/OneSixModEditDialog.cpp
@@ -72,6 +72,8 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
auto smodel = ui->loaderModTreeView->selectionModel();
connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
SLOT(loaderCurrent(QModelIndex, QModelIndex)));
+
+ ui->liteloaderBtn->setEnabled(LiteLoaderInstaller(m_inst->intendedVersionId()).canApply());
}
// resource packs
{
@@ -207,7 +209,15 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
void OneSixModEditDialog::on_liteloaderBtn_clicked()
{
- LiteLoaderInstaller liteloader;
+ LiteLoaderInstaller liteloader(m_inst->intendedVersionId());
+ if (!liteloader.canApply())
+ {
+ QMessageBox::critical(
+ this, tr("LiteLoader"),
+ tr("There is no information available on how to install LiteLoader "
+ "into this version of Minecraft"));
+ return;
+ }
if (!liteloader.apply(m_version))
{
// failure notice
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);
}
diff --git a/logic/LiteLoaderInstaller.h b/logic/LiteLoaderInstaller.h
index 6a5ee1f2..44b306d6 100644
--- a/logic/LiteLoaderInstaller.h
+++ b/logic/LiteLoaderInstaller.h
@@ -15,6 +15,7 @@
#pragma once
#include <QString>
+#include <QMap>
#include <memory>
class OneSixVersion;
@@ -22,7 +23,17 @@ class OneSixVersion;
class LiteLoaderInstaller
{
public:
- LiteLoaderInstaller();
+ LiteLoaderInstaller(const QString &mcVersion);
+
+ bool canApply() const;
bool apply(std::shared_ptr<OneSixVersion> to);
+
+private:
+ QString m_mcVersion;
+
+ void applyLaunchwrapper(std::shared_ptr<OneSixVersion> to);
+ void applyLiteLoader(std::shared_ptr<OneSixVersion> to);
+
+ static QMap<QString, QString> m_launcherWrapperVersionMapping;
};