summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-04-04 02:01:52 +0200
committerPetr Mrázek <peterix@gmail.com>2015-04-04 02:01:52 +0200
commitc7b39fe1165956d07055e7917b22d5604fb5f768 (patch)
treeb1a51bd74228bc1c708780031a4a685e1f2c0105 /logic
parent865b20057120a61cfd26f5eea9aa68243efc3319 (diff)
downloadMultiMC-c7b39fe1165956d07055e7917b22d5604fb5f768.tar
MultiMC-c7b39fe1165956d07055e7917b22d5604fb5f768.tar.gz
MultiMC-c7b39fe1165956d07055e7917b22d5604fb5f768.tar.lz
MultiMC-c7b39fe1165956d07055e7917b22d5604fb5f768.tar.xz
MultiMC-c7b39fe1165956d07055e7917b22d5604fb5f768.zip
NOISSUE Remove special FTB logic from generic version patch code
Diffstat (limited to 'logic')
-rw-r--r--logic/ftb/FTBProfileStrategy.cpp29
-rw-r--r--logic/minecraft/OneSixProfileStrategy.cpp2
-rw-r--r--logic/minecraft/ProfileUtils.cpp6
-rw-r--r--logic/minecraft/ProfileUtils.h2
-rw-r--r--logic/minecraft/VersionFile.cpp23
-rw-r--r--logic/minecraft/VersionFile.h2
6 files changed, 35 insertions, 29 deletions
diff --git a/logic/ftb/FTBProfileStrategy.cpp b/logic/ftb/FTBProfileStrategy.cpp
index 0a4984f7..20feba61 100644
--- a/logic/ftb/FTBProfileStrategy.cpp
+++ b/logic/ftb/FTBProfileStrategy.cpp
@@ -27,7 +27,7 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
{
auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false);
file->fileId = "net.minecraft";
- file->name = "Minecraft (FTB tracked)";
+ file->name = QObject::tr("Minecraft (tracked)");
if(file->version.isEmpty())
{
file->version = mcVersion;
@@ -48,12 +48,33 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
// load up the base minecraft patch
if(QFile::exists(mcJson))
{
- auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false, true);
+ auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false);
+
+ // adapt the loaded file - the FTB patch file format is different than ours.
+ file->addLibs = file->overwriteLibs;
+ file->overwriteLibs.clear();
+ file->shouldOverwriteLibs = false;
+ file->id.clear();
+ for(auto addLib: file->addLibs)
+ {
+ addLib->m_hint = "local";
+ addLib->insertType = RawLibrary::Prepend;
+ }
file->fileId = "org.multimc.ftb.pack";
- file->name = QString("%1 (FTB tracked)").arg(m_instance->name());
+ file->name = QObject::tr("%1 (FTB pack)").arg(m_instance->name());
if(file->version.isEmpty())
{
- file->version = mcVersion;
+ file->version = QObject::tr("Unknown");
+ QFile versionFile (PathCombine(m_instance->instanceRoot(), "version"));
+ if(versionFile.exists())
+ {
+ if(versionFile.open(QIODevice::ReadOnly))
+ {
+ // FIXME: just guessing the encoding/charset here.
+ auto version = QString::fromUtf8(versionFile.readAll());
+ file->version = version;
+ }
+ }
}
minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(file);
}
diff --git a/logic/minecraft/OneSixProfileStrategy.cpp b/logic/minecraft/OneSixProfileStrategy.cpp
index bdb2f8ee..285e983c 100644
--- a/logic/minecraft/OneSixProfileStrategy.cpp
+++ b/logic/minecraft/OneSixProfileStrategy.cpp
@@ -87,7 +87,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
// TODO: this is obviously fake.
QResource LWJGL(":/versions/LWJGL/2.9.1.json");
- auto lwjgl = ProfileUtils::parseJsonFile(LWJGL.absoluteFilePath(), false, false);
+ auto lwjgl = ProfileUtils::parseJsonFile(LWJGL.absoluteFilePath(), false);
auto lwjglPatch = std::dynamic_pointer_cast<ProfilePatch>(lwjgl);
if (!lwjglPatch)
{
diff --git a/logic/minecraft/ProfileUtils.cpp b/logic/minecraft/ProfileUtils.cpp
index bae34dbf..db05b0a6 100644
--- a/logic/minecraft/ProfileUtils.cpp
+++ b/logic/minecraft/ProfileUtils.cpp
@@ -98,7 +98,7 @@ bool readOverrideOrders(QString path, PatchOrder &order)
return true;
}
-VersionFilePtr parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, bool isFTB)
+VersionFilePtr parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder)
{
QFile file(fileInfo.absoluteFilePath());
if (!file.open(QFile::ReadOnly))
@@ -115,7 +115,7 @@ VersionFilePtr parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder,
.arg(fileInfo.fileName(), error.errorString())
.arg(error.offset));
}
- return VersionFile::fromJson(doc, file.fileName(), requireOrder, isFTB);
+ return VersionFile::fromJson(doc, file.fileName(), requireOrder);
}
VersionFilePtr parseBinaryJsonFile(const QFileInfo &fileInfo)
@@ -134,7 +134,7 @@ VersionFilePtr parseBinaryJsonFile(const QFileInfo &fileInfo)
throw JSONValidationError(
QObject::tr("Unable to process the version file %1.").arg(fileInfo.fileName()));
}
- return VersionFile::fromJson(doc, file.fileName(), false, false);
+ return VersionFile::fromJson(doc, file.fileName(), false);
}
void removeLwjglFromPatch(VersionFilePtr patch)
diff --git a/logic/minecraft/ProfileUtils.h b/logic/minecraft/ProfileUtils.h
index 88027374..1e6d6a8f 100644
--- a/logic/minecraft/ProfileUtils.h
+++ b/logic/minecraft/ProfileUtils.h
@@ -14,7 +14,7 @@ bool writeOverrideOrders(QString path, const PatchOrder &order);
/// Parse a version file in JSON format
-VersionFilePtr parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, bool isFTB = false);
+VersionFilePtr parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder);
/// Parse a version file in binary JSON format
VersionFilePtr parseBinaryJsonFile(const QFileInfo &fileInfo);
diff --git a/logic/minecraft/VersionFile.cpp b/logic/minecraft/VersionFile.cpp
index 97ce6535..f5856936 100644
--- a/logic/minecraft/VersionFile.cpp
+++ b/logic/minecraft/VersionFile.cpp
@@ -34,7 +34,7 @@ int findLibraryByName(QList<OneSixLibraryPtr> haystack, const GradleSpecifier &n
}
VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &filename,
- const bool requireOrder, const bool isFTB)
+ const bool requireOrder)
{
VersionFilePtr out(new VersionFile());
if (doc.isEmpty() || doc.isNull())
@@ -84,11 +84,7 @@ VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &fi
return QString();
};
- // FIXME: This should be ignored when applying.
- if (!isFTB)
- {
- readString("id", out->id);
- }
+ readString("id", out->id);
readString("mainClass", out->mainClass);
readString("appletClass", out->appletClass);
@@ -143,24 +139,13 @@ VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &fi
if (root.contains("libraries"))
{
- // FIXME: This should be done when applying.
- out->shouldOverwriteLibs = !isFTB;
+ out->shouldOverwriteLibs = true;
for (auto libVal : ensureArray(root.value("libraries")))
{
auto libObj = ensureObject(libVal);
auto lib = RawLibrary::fromJson(libObj, filename);
- // FIXME: This should be done when applying.
- if (isFTB)
- {
- lib->m_hint = "local";
- lib->insertType = RawLibrary::Prepend;
- out->addLibs.prepend(lib);
- }
- else
- {
- out->overwriteLibs.append(lib);
- }
+ out->overwriteLibs.append(lib);
}
}
diff --git a/logic/minecraft/VersionFile.h b/logic/minecraft/VersionFile.h
index ddc3f849..1e8772af 100644
--- a/logic/minecraft/VersionFile.h
+++ b/logic/minecraft/VersionFile.h
@@ -19,7 +19,7 @@ class VersionFile : public ProfilePatch
{
public: /* methods */
static VersionFilePtr fromJson(const QJsonDocument &doc, const QString &filename,
- const bool requireOrder, const bool isFTB = false);
+ const bool requireOrder);
QJsonDocument toJson(bool saveOrder);
virtual void applyTo(MinecraftProfile *version) override;