summaryrefslogtreecommitdiffstats
path: root/backend/LegacyUpdate.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-08-12 00:39:19 +0200
committerPetr Mrázek <peterix@gmail.com>2013-08-12 00:39:19 +0200
commitff33d4a1a48abf1442cde77c2253f071d0870d50 (patch)
tree7846f144b2ee2e24574745847c0f921677021d73 /backend/LegacyUpdate.cpp
parent7e78a422e8bb22572706b7fadb58fc45e7b8a7db (diff)
downloadMultiMC-ff33d4a1a48abf1442cde77c2253f071d0870d50.tar
MultiMC-ff33d4a1a48abf1442cde77c2253f071d0870d50.tar.gz
MultiMC-ff33d4a1a48abf1442cde77c2253f071d0870d50.tar.lz
MultiMC-ff33d4a1a48abf1442cde77c2253f071d0870d50.tar.xz
MultiMC-ff33d4a1a48abf1442cde77c2253f071d0870d50.zip
OneSix instances now have a minecraft folder inside.
Also, the main instance view was expanded with helpful key events: F2 for rename, F5 for refresh, Enter for start instance, Delete for...
Diffstat (limited to 'backend/LegacyUpdate.cpp')
-rw-r--r--backend/LegacyUpdate.cpp67
1 files changed, 65 insertions, 2 deletions
diff --git a/backend/LegacyUpdate.cpp b/backend/LegacyUpdate.cpp
index 630f7f29..8580a2f2 100644
--- a/backend/LegacyUpdate.cpp
+++ b/backend/LegacyUpdate.cpp
@@ -1,5 +1,6 @@
#include "LegacyUpdate.h"
#include "lists/LwjglVersionList.h"
+#include "lists/MinecraftVersionList.h"
#include "BaseInstance.h"
#include "LegacyInstance.h"
#include "net/NetWorker.h"
@@ -27,7 +28,7 @@ void LegacyUpdate::lwjglStart()
QFileInfo doneFile(PathCombine(lwjglTargetPath, "done"));
if(doneFile.exists())
{
- emitSucceeded();
+ jarStart();
return;
}
@@ -38,6 +39,7 @@ void LegacyUpdate::lwjglStart()
return;
}
+ setStatus("Downloading new LWJGL.");
auto version = list.getVersion(lwjglVersion);
if(!version)
{
@@ -104,6 +106,7 @@ void LegacyUpdate::lwjglFinished(QNetworkReply* reply)
saveMe.close();
setStatus("Installing new LWJGL...");
extractLwjgl();
+ jarStart();
}
void LegacyUpdate::extractLwjgl()
{
@@ -189,7 +192,6 @@ void LegacyUpdate::extractLwjgl()
doneFile.open(QIODevice::WriteOnly);
doneFile.write("done.");
doneFile.close();
- emitSucceeded();
}
void LegacyUpdate::lwjglFailed()
@@ -197,3 +199,64 @@ void LegacyUpdate::lwjglFailed()
emitFailed("Bad stuff happened while trying to get the lwjgl libs...");
}
+void LegacyUpdate::jarStart()
+{
+ setStatus("Checking ...");
+ LegacyInstance * inst = (LegacyInstance *) m_inst;
+ QString current_version_id = inst->currentVersionId();
+ QString intended_version_id = inst->intendedVersionId();
+ bool shouldUpdate = inst->shouldUpdate();
+ if(!shouldUpdate)
+ {
+ emitSucceeded();
+ return;
+ }
+
+ // Get a pointer to the version object that corresponds to the instance's version.
+ auto targetVersion = MinecraftVersionList::getMainList().findVersion(intended_version_id);
+
+ if(!targetVersion)
+ {
+ emitFailed("Not a valid version:" + intended_version_id);
+ return;
+ }
+
+ // Make directories
+ QDir binDir(inst->binDir());
+ if (!binDir.exists() && !binDir.mkpath("."))
+ {
+ emitFailed("Failed to create bin folder.");
+ return;
+ }
+
+ // Build a list of URLs that will need to be downloaded.
+ setStatus("Downloading new minecraft.jar");
+
+ // This will be either 'minecraft' or the version number, depending on where
+ // we're downloading from.
+ QString jarFilename = "minecraft";
+ QString download_path = PathCombine(inst->minecraftRoot(), "bin/minecraft.jar");
+
+ QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
+ urlstr += targetVersion->descriptor + "/" + targetVersion->descriptor + ".jar";
+ auto dljob = DownloadJob::create(QUrl(urlstr), download_path);
+
+ legacyDownloadJob.reset(new JobList());
+ legacyDownloadJob->add(dljob);
+ connect(legacyDownloadJob.data(), SIGNAL(finished()), SLOT(jarFinished()));
+ connect(legacyDownloadJob.data(), SIGNAL(failed()), SLOT(jarFailed()));
+ connect(legacyDownloadJob.data(), SIGNAL(progress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64)));
+ download_queue.enqueue(legacyDownloadJob);
+}
+
+void LegacyUpdate::jarFinished()
+{
+ // process the jar
+ emitSucceeded();
+}
+
+void LegacyUpdate::jarFailed()
+{
+ // bad, bad
+ emitFailed("Failed to download the minecraft jar. Try again later.");
+}