summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-05-15 01:10:08 +0200
committerPetr Mrázek <peterix@gmail.com>2015-05-15 01:37:15 +0200
commit416e08f7417abd767e250e185a5be8bd1110dae8 (patch)
treeb9c9d580b5367d618758c438d284245243a7492f /logic
parent5bbe1c7132f3fd4c6850519e045f378e114ada50 (diff)
downloadMultiMC-416e08f7417abd767e250e185a5be8bd1110dae8.tar
MultiMC-416e08f7417abd767e250e185a5be8bd1110dae8.tar.gz
MultiMC-416e08f7417abd767e250e185a5be8bd1110dae8.tar.lz
MultiMC-416e08f7417abd767e250e185a5be8bd1110dae8.tar.xz
MultiMC-416e08f7417abd767e250e185a5be8bd1110dae8.zip
GH-952 flesh out {version,custom}.json upgrade step
Diffstat (limited to 'logic')
-rw-r--r--logic/minecraft/MinecraftProfile.cpp12
-rw-r--r--logic/minecraft/OneSixProfileStrategy.cpp56
2 files changed, 50 insertions, 18 deletions
diff --git a/logic/minecraft/MinecraftProfile.cpp b/logic/minecraft/MinecraftProfile.cpp
index e87ece00..acde7dc7 100644
--- a/logic/minecraft/MinecraftProfile.cpp
+++ b/logic/minecraft/MinecraftProfile.cpp
@@ -274,7 +274,17 @@ QVariant MinecraftProfile::data(const QModelIndex &index, int role) const
case 0:
return VersionPatches.at(row)->getPatchName();
case 1:
- return VersionPatches.at(row)->getPatchVersion();
+ {
+ auto patch = VersionPatches.at(row);
+ if(patch->isCustom())
+ {
+ return QString("%1 (Custom)").arg(patch->getPatchVersion());
+ }
+ else
+ {
+ return patch->getPatchVersion();
+ }
+ }
default:
return QVariant();
}
diff --git a/logic/minecraft/OneSixProfileStrategy.cpp b/logic/minecraft/OneSixProfileStrategy.cpp
index 12503a80..389b5f06 100644
--- a/logic/minecraft/OneSixProfileStrategy.cpp
+++ b/logic/minecraft/OneSixProfileStrategy.cpp
@@ -21,34 +21,57 @@ void OneSixProfileStrategy::upgradeDeprecatedFiles()
auto customJsonPath = PathCombine(m_instance->instanceRoot(), "custom.json");
auto mcJson = PathCombine(m_instance->instanceRoot(), "patches" , "net.minecraft.json");
+ QString sourceFile;
+ QString deleteFile;
+
// convert old crap.
if(QFile::exists(customJsonPath))
{
+ sourceFile = customJsonPath;
+ deleteFile = versionJsonPath;
+ }
+ else if(QFile::exists(versionJsonPath))
+ {
+ sourceFile = versionJsonPath;
+ }
+ if(!sourceFile.isEmpty() && !QFile::exists(mcJson))
+ {
if(!ensureFilePathExists(mcJson))
{
- // WHAT DO???
- }
- if(!QFile::rename(customJsonPath, mcJson))
- {
- // WHAT DO???
+ qWarning() << "Couldn't create patches folder for" << m_instance->name();
+ return;
}
- if(QFile::exists(versionJsonPath))
+ if(!deleteFile.isEmpty() && QFile::exists(deleteFile))
{
- if(!QFile::remove(versionJsonPath))
+ if(!QFile::remove(deleteFile))
{
- // WHAT DO???
+ qWarning() << "Couldn't remove" << deleteFile << "from" << m_instance->name();
+ return;
}
}
- }
- else if(QFile::exists(versionJsonPath))
- {
- if(!ensureFilePathExists(mcJson))
+ auto file = ProfileUtils::parseJsonFile(QFileInfo(sourceFile), false);
+ ProfileUtils::removeLwjglFromPatch(file);
+ file->fileId = "net.minecraft";
+ file->version = file->id;
+ file->name = "Minecraft";
+ auto data = file->toJson(false).toJson();
+ QSaveFile newPatchFile(mcJson);
+ if(!newPatchFile.open(QIODevice::WriteOnly))
{
- // WHAT DO???
+ newPatchFile.cancelWriting();
+ qWarning() << "Couldn't open main patch for writing in" << m_instance->name();
+ return;
}
- if(!QFile::rename(versionJsonPath, mcJson))
+ newPatchFile.write(data);
+ if(!newPatchFile.commit())
{
- // WHAT DO???
+ qWarning() << "Couldn't save main patch in" << m_instance->name();
+ return;
+ }
+ if(!QFile::remove(sourceFile))
+ {
+ qWarning() << "Couldn't remove" << sourceFile << "from" << m_instance->name();
+ return;
}
}
}
@@ -62,12 +85,11 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
if(QFile::exists(mcJson))
{
auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false);
- file->fileId = "net.minecraft";
- file->name = "Minecraft";
if(file->version.isEmpty())
{
file->version = m_instance->intendedVersionId();
}
+ file->setVanilla(false);
minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(file);
}
else