summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MultiMC.cpp1
-rw-r--r--gui/dialogs/VersionSelectDialog.cpp4
-rw-r--r--logic/LegacyInstance.cpp5
-rw-r--r--logic/LegacyInstance.h1
-rw-r--r--logic/LegacyUpdate.cpp169
-rw-r--r--logic/LegacyUpdate.h13
-rw-r--r--logic/net/URLConstants.cpp2
-rw-r--r--logic/net/URLConstants.h2
8 files changed, 195 insertions, 2 deletions
diff --git a/MultiMC.cpp b/MultiMC.cpp
index ddc1fca7..c4968b4c 100644
--- a/MultiMC.cpp
+++ b/MultiMC.cpp
@@ -470,6 +470,7 @@ void MultiMC::initHttpMetaCache()
m_metacache->addBase("versions", QDir("versions").absolutePath());
m_metacache->addBase("libraries", QDir("libraries").absolutePath());
m_metacache->addBase("minecraftforge", QDir("mods/minecraftforge").absolutePath());
+ m_metacache->addBase("fmllibs", QDir("mods/minecraftforge/libs").absolutePath());
m_metacache->addBase("liteloader", QDir("mods/liteloader").absolutePath());
m_metacache->addBase("skins", QDir("accounts/skins").absolutePath());
m_metacache->addBase("root", QDir(root()).absolutePath());
diff --git a/gui/dialogs/VersionSelectDialog.cpp b/gui/dialogs/VersionSelectDialog.cpp
index 3277fd2f..f4d314b6 100644
--- a/gui/dialogs/VersionSelectDialog.cpp
+++ b/gui/dialogs/VersionSelectDialog.cpp
@@ -100,7 +100,9 @@ void VersionSelectDialog::on_refreshButton_clicked()
void VersionSelectDialog::setFilter(int column, QString filter)
{
m_proxyModel->setFilterKeyColumn(column);
- m_proxyModel->setFilterFixedString(filter);
+ // m_proxyModel->setFilterFixedString(filter);
+ m_proxyModel->setFilterRegExp(QRegExp(QString("^%1$").arg(filter.replace(".", "\\.")),
+ Qt::CaseInsensitive, QRegExp::RegExp));
/*
QStringList filteredTypes;
if (!ui->filterSnapshotsCheckbox->isChecked())
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index 4f2dfd9b..d06b8827 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -159,6 +159,11 @@ QString LegacyInstance::binDir() const
return PathCombine(minecraftRoot(), "bin");
}
+QString LegacyInstance::libDir() const
+{
+ return PathCombine(minecraftRoot(), "lib");
+}
+
QString LegacyInstance::savesDir() const
{
return PathCombine(minecraftRoot(), "saves");
diff --git a/logic/LegacyInstance.h b/logic/LegacyInstance.h
index 636addeb..badaf7e3 100644
--- a/logic/LegacyInstance.h
+++ b/logic/LegacyInstance.h
@@ -41,6 +41,7 @@ public:
std::shared_ptr<ModList> texturePackList();
////// Directories //////
+ QString libDir() const;
QString savesDir() const;
QString texturePacksDir() const;
QString jarModsDir() const;
diff --git a/logic/LegacyUpdate.cpp b/logic/LegacyUpdate.cpp
index 5d82a76b..15c99234 100644
--- a/logic/LegacyUpdate.cpp
+++ b/logic/LegacyUpdate.cpp
@@ -26,9 +26,56 @@
#include <JlCompress.h>
#include "logger/QsLog.h"
#include "logic/net/URLConstants.h"
+#include <QStringList>
LegacyUpdate::LegacyUpdate(BaseInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
{
+ // 1.3 - 1.3.2
+ auto libs13 = QList<FMLlib>{
+ {"argo-2.25.jar", "bb672829fde76cb163004752b86b0484bd0a7f4b", false},
+ {"guava-12.0.1.jar", "b8e78b9af7bf45900e14c6f958486b6ca682195f", false},
+ {"asm-all-4.0.jar", "98308890597acb64047f7e896638e0d98753ae82", false}};
+
+ fmlLibsMapping["1.3.2"] = libs13;
+
+ auto libs14 = QList<FMLlib>{
+ {"argo-2.25.jar", "bb672829fde76cb163004752b86b0484bd0a7f4b", false},
+ {"guava-12.0.1.jar", "b8e78b9af7bf45900e14c6f958486b6ca682195f", false},
+ {"asm-all-4.0.jar", "98308890597acb64047f7e896638e0d98753ae82", false},
+ {"bcprov-jdk15on-147.jar", "b6f5d9926b0afbde9f4dbe3db88c5247be7794bb", false}};
+
+ fmlLibsMapping["1.4"] = libs14;
+ fmlLibsMapping["1.4.1"] = libs14;
+ fmlLibsMapping["1.4.2"] = libs14;
+ fmlLibsMapping["1.4.3"] = libs14;
+ fmlLibsMapping["1.4.4"] = libs14;
+ fmlLibsMapping["1.4.5"] = libs14;
+ fmlLibsMapping["1.4.6"] = libs14;
+ fmlLibsMapping["1.4.7"] = libs14;
+
+ fmlLibsMapping["1.5"] = QList<FMLlib>{
+ {"argo-small-3.2.jar", "58912ea2858d168c50781f956fa5b59f0f7c6b51", false},
+ {"guava-14.0-rc3.jar", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", false},
+ {"asm-all-4.1.jar", "054986e962b88d8660ae4566475658469595ef58", false},
+ {"bcprov-jdk15on-148.jar", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65", true},
+ {"deobfuscation_data_1.5.zip", "5f7c142d53776f16304c0bbe10542014abad6af8", false},
+ {"scala-library.jar", "458d046151ad179c85429ed7420ffb1eaf6ddf85", true}};
+
+ fmlLibsMapping["1.5.1"] = QList<FMLlib>{
+ {"argo-small-3.2.jar", "58912ea2858d168c50781f956fa5b59f0f7c6b51", false},
+ {"guava-14.0-rc3.jar", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", false},
+ {"asm-all-4.1.jar", "054986e962b88d8660ae4566475658469595ef58", false},
+ {"bcprov-jdk15on-148.jar", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65", true},
+ {"deobfuscation_data_1.5.1.zip", "22e221a0d89516c1f721d6cab056a7e37471d0a6", false},
+ {"scala-library.jar", "458d046151ad179c85429ed7420ffb1eaf6ddf85", true}};
+
+ fmlLibsMapping["1.5.2"] = QList<FMLlib>{
+ {"argo-small-3.2.jar", "58912ea2858d168c50781f956fa5b59f0f7c6b51", false},
+ {"guava-14.0-rc3.jar", "931ae21fa8014c3ce686aaa621eae565fefb1a6a", false},
+ {"asm-all-4.1.jar", "054986e962b88d8660ae4566475658469595ef58", false},
+ {"bcprov-jdk15on-148.jar", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65", true},
+ {"deobfuscation_data_1.5.2.zip", "446e55cd986582c70fcf12cb27bc00114c5adfd9", false},
+ {"scala-library.jar", "458d046151ad179c85429ed7420ffb1eaf6ddf85", true}};
}
void LegacyUpdate::executeTask()
@@ -50,10 +97,130 @@ void LegacyUpdate::executeTask()
else
{
*/
- lwjglStart();
+ fmllibsStart();
//}
}
+void LegacyUpdate::fmllibsStart()
+{
+ // Get the mod list
+ LegacyInstance *inst = (LegacyInstance *)m_inst;
+ auto modList = inst->jarModList();
+
+ bool forge_present = false;
+
+ QString version = inst->intendedVersionId();
+ if (!fmlLibsMapping.contains(version))
+ {
+ lwjglStart();
+ return;
+ }
+
+ auto &libList = fmlLibsMapping[version];
+
+ // determine if we need some libs for FML or forge
+ setStatus(tr("Checking for FML libraries..."));
+ for (unsigned i = 0; i < modList->size(); i++)
+ {
+ auto &mod = modList->operator[](i);
+
+ // do not use disabled mods.
+ if (!mod.enabled())
+ continue;
+
+ if (mod.type() != Mod::MOD_ZIPFILE)
+ continue;
+
+ if (mod.mmc_id().contains("forge", Qt::CaseInsensitive))
+ {
+ forge_present = true;
+ break;
+ }
+ if (mod.mmc_id().contains("fml", Qt::CaseInsensitive))
+ {
+ forge_present = true;
+ break;
+ }
+ }
+ // we don't...
+ if (!forge_present)
+ {
+ lwjglStart();
+ return;
+ }
+
+ // now check the lib folder inside the instance for files.
+ for (auto &lib : libList)
+ {
+ QFileInfo libInfo(PathCombine(inst->libDir(), lib.name));
+ if (libInfo.exists())
+ continue;
+ fmlLibsToProcess.append(lib);
+ }
+
+ // if everything is in place, there's nothing to do here...
+ if (fmlLibsToProcess.isEmpty())
+ {
+ lwjglStart();
+ return;
+ }
+
+ // download missing libs to our place
+ setStatus(tr("Dowloading FML libraries..."));
+ auto dljob = new NetJob("FML libraries");
+ auto metacache = MMC->metacache();
+ for (auto &lib : fmlLibsToProcess)
+ {
+ auto entry = metacache->resolveEntry("fmllibs", lib.name);
+ QString urlString = lib.ours ? URLConstants::FMLLIBS_OUR_BASE_URL + lib.name
+ : URLConstants::FMLLIBS_FORGE_BASE_URL + lib.name;
+ dljob->addNetAction(CacheDownload::make(QUrl(urlString), entry));
+ }
+
+ connect(dljob, SIGNAL(succeeded()), SLOT(fmllibsFinished()));
+ connect(dljob, SIGNAL(failed()), SLOT(fmllibsFailed()));
+ connect(dljob, SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
+ legacyDownloadJob.reset(dljob);
+ legacyDownloadJob->start();
+}
+
+void LegacyUpdate::fmllibsFinished()
+{
+ legacyDownloadJob.reset();
+ if(!fmlLibsToProcess.isEmpty())
+ {
+ setStatus(tr("Copying FML libraries into the instance..."));
+ LegacyInstance *inst = (LegacyInstance *)m_inst;
+ auto metacache = MMC->metacache();
+ int index = 0;
+ for (auto &lib : fmlLibsToProcess)
+ {
+ progress(index, fmlLibsToProcess.size());
+ auto entry = metacache->resolveEntry("fmllibs", lib.name);
+ auto path = PathCombine(inst->libDir(), lib.name);
+ if(!ensureFilePathExists(path))
+ {
+ emitFailed(tr("Failed creating FML library folder inside the instance."));
+ return;
+ }
+ if (!QFile::copy(entry->getFullPath(), PathCombine(inst->libDir(), lib.name)))
+ {
+ emitFailed(tr("Failed copying Forge/FML library: %1.").arg(lib.name));
+ return;
+ }
+ index++;
+ }
+ progress(index, fmlLibsToProcess.size());
+ }
+ lwjglStart();
+}
+
+void LegacyUpdate::fmllibsFailed()
+{
+ emitFailed("Game update failed: it was impossible to fetch the required FML libraries.");
+ return;
+}
+
void LegacyUpdate::lwjglStart()
{
LegacyInstance *inst = (LegacyInstance *)m_inst;
diff --git a/logic/LegacyUpdate.h b/logic/LegacyUpdate.h
index 613eb1f9..5b073cb7 100644
--- a/logic/LegacyUpdate.h
+++ b/logic/LegacyUpdate.h
@@ -27,6 +27,13 @@ class BaseInstance;
class QuaZip;
class Mod;
+struct FMLlib
+{
+ QString name;
+ QString checksum;
+ bool ours;
+};
+
class LegacyUpdate : public Task
{
Q_OBJECT
@@ -44,6 +51,10 @@ slots:
void jarFinished();
void jarFailed();
+ void fmllibsStart();
+ void fmllibsFinished();
+ void fmllibsFailed();
+
void extractLwjgl();
void ModTheJar();
@@ -72,4 +83,6 @@ private:
private:
NetJobPtr legacyDownloadJob;
BaseInstance *m_inst = nullptr;
+ QList<FMLlib> fmlLibsToProcess;
+ QMap<QString, QList<FMLlib>> fmlLibsMapping;
};
diff --git a/logic/net/URLConstants.cpp b/logic/net/URLConstants.cpp
index 14b28085..6cd0c4fd 100644
--- a/logic/net/URLConstants.cpp
+++ b/logic/net/URLConstants.cpp
@@ -16,4 +16,6 @@ const QString MOJANG_STATUS_URL("http://status.mojang.com/check");
const QString MOJANG_STATUS_NEWS_URL("http://status.mojang.com/news");
const QString LITELOADER_URL("http://dl.liteloader.com/versions/versions.json");
const QString IMGUR_BASE_URL("https://api.imgur.com/3/");
+const QString FMLLIBS_OUR_BASE_URL("http://dethware.org/dl/fmllibs/");
+const QString FMLLIBS_FORGE_BASE_URL("http://files.minecraftforge.net/fmllibs/");
} \ No newline at end of file
diff --git a/logic/net/URLConstants.h b/logic/net/URLConstants.h
index c1064115..392d7362 100644
--- a/logic/net/URLConstants.h
+++ b/logic/net/URLConstants.h
@@ -34,4 +34,6 @@ extern const QString MOJANG_STATUS_URL;
extern const QString MOJANG_STATUS_NEWS_URL;
extern const QString LITELOADER_URL;
extern const QString IMGUR_BASE_URL;
+extern const QString FMLLIBS_OUR_BASE_URL;
+extern const QString FMLLIBS_FORGE_BASE_URL;
}