summaryrefslogtreecommitdiffstats
path: root/logic/LiteLoaderInstaller.cpp
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-03-14 20:48:57 +0100
committerJan Dalheimer <jan@dalheimer.de>2014-03-14 20:48:57 +0100
commite95619fa67239b709522a66b8bb7403bb7b84098 (patch)
treeedee0bdc771e1a958c239abfc8d112c38539aa42 /logic/LiteLoaderInstaller.cpp
parente5b4dee1c05d0d6ebc0d7b2dd802b93cb8765e63 (diff)
downloadMultiMC-e95619fa67239b709522a66b8bb7403bb7b84098.tar
MultiMC-e95619fa67239b709522a66b8bb7403bb7b84098.tar.gz
MultiMC-e95619fa67239b709522a66b8bb7403bb7b84098.tar.lz
MultiMC-e95619fa67239b709522a66b8bb7403bb7b84098.tar.xz
MultiMC-e95619fa67239b709522a66b8bb7403bb7b84098.zip
Pull in BaseInstaller related changes from quickmod
Diffstat (limited to 'logic/LiteLoaderInstaller.cpp')
-rw-r--r--logic/LiteLoaderInstaller.cpp68
1 files changed, 66 insertions, 2 deletions
diff --git a/logic/LiteLoaderInstaller.cpp b/logic/LiteLoaderInstaller.cpp
index bb4b07ca..99cc5643 100644
--- a/logic/LiteLoaderInstaller.cpp
+++ b/logic/LiteLoaderInstaller.cpp
@@ -23,12 +23,17 @@
#include "VersionFinal.h"
#include "OneSixLibrary.h"
#include "OneSixInstance.h"
+#include "MultiMC.h"
+#include "lists/LiteLoaderVersionList.h"
-LiteLoaderInstaller::LiteLoaderInstaller(LiteLoaderVersionPtr version)
- : BaseInstaller(), m_version(version)
+LiteLoaderInstaller::LiteLoaderInstaller() : BaseInstaller()
{
}
+void LiteLoaderInstaller::prepare(LiteLoaderVersionPtr version)
+{
+ m_version = version;
+}
bool LiteLoaderInstaller::add(OneSixInstance *to)
{
if (!BaseInstaller::add(to))
@@ -84,3 +89,62 @@ bool LiteLoaderInstaller::add(OneSixInstance *to)
return true;
}
+
+class LiteLoaderInstallTask : public Task
+{
+ Q_OBJECT
+public:
+ LiteLoaderInstallTask(LiteLoaderInstaller *installer, OneSixInstance *instance,
+ BaseVersionPtr version, QObject *parent)
+ : Task(parent), m_installer(installer), m_instance(instance), m_version(version)
+ {
+ }
+
+protected:
+ void executeTask() override
+ {
+ LiteLoaderVersionPtr liteloaderVersion =
+ std::dynamic_pointer_cast<LiteLoaderVersion>(m_version);
+ if (!liteloaderVersion)
+ {
+ return;
+ }
+ m_installer->prepare(liteloaderVersion);
+ if (!m_installer->add(m_instance))
+ {
+ emitFailed(tr("For reasons unknown, the LiteLoader installation failed. Check your "
+ "MultiMC log files for details."));
+ }
+ else
+ {
+ try
+ {
+ m_instance->reloadVersion();
+ emitSucceeded();
+ }
+ catch (MMCError &e)
+ {
+ emitFailed(e.cause());
+ }
+ catch (...)
+ {
+ emitFailed(
+ tr("Failed to load the version description file for reasons unknown."));
+ }
+ }
+ }
+
+private:
+ LiteLoaderInstaller *m_installer;
+ OneSixInstance *m_instance;
+ BaseVersionPtr m_version;
+};
+
+ProgressProvider *LiteLoaderInstaller::createInstallTask(OneSixInstance *instance,
+ BaseVersionPtr version,
+ QObject *parent)
+{
+ return new LiteLoaderInstallTask(this, instance, version, parent);
+}
+
+#include "LiteLoaderInstaller.moc"