diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-06-08 21:26:48 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-09 01:38:31 +0200 |
commit | be73eb3322b6bb5ab1144f9942ef9bd188c704a1 (patch) | |
tree | 8df6bfa84a62fc17d9842d30134c6a71fd4cb3f1 /logic/minecraft/InstanceVersion.cpp | |
parent | bf7b07050873770bd0b2ed5d73965b5a88d7a351 (diff) | |
download | MultiMC-be73eb3322b6bb5ab1144f9942ef9bd188c704a1.tar MultiMC-be73eb3322b6bb5ab1144f9942ef9bd188c704a1.tar.gz MultiMC-be73eb3322b6bb5ab1144f9942ef9bd188c704a1.tar.lz MultiMC-be73eb3322b6bb5ab1144f9942ef9bd188c704a1.tar.xz MultiMC-be73eb3322b6bb5ab1144f9942ef9bd188c704a1.zip |
Version revert logic improvements, colorful icons for mod lists and resource pack list.
Icons are from Oxygen.
Diffstat (limited to 'logic/minecraft/InstanceVersion.cpp')
-rw-r--r-- | logic/minecraft/InstanceVersion.cpp | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/logic/minecraft/InstanceVersion.cpp b/logic/minecraft/InstanceVersion.cpp index 73beceb3..baf34404 100644 --- a/logic/minecraft/InstanceVersion.cpp +++ b/logic/minecraft/InstanceVersion.cpp @@ -161,12 +161,35 @@ bool InstanceVersion::isVanilla() return false; if(QFile::exists(PathCombine(m_instance->instanceRoot(), "custom.json"))) return false; + if(QFile::exists(PathCombine(m_instance->instanceRoot(), "version.json"))) + return false; return true; } bool InstanceVersion::revertToVanilla() { beginResetModel(); + // remove custom.json, if present + QString customPath = PathCombine(m_instance->instanceRoot(), "custom.json"); + if(QFile::exists(customPath)) + { + if(!QFile::remove(customPath)) + { + endResetModel(); + return false; + } + } + // remove version.json, if present + QString versionPath = PathCombine(m_instance->instanceRoot(), "version.json"); + if(QFile::exists(versionPath)) + { + if(!QFile::remove(versionPath)) + { + endResetModel(); + return false; + } + } + // remove patches, if present auto it = VersionPatches.begin(); while (it != VersionPatches.end()) { @@ -195,9 +218,40 @@ bool InstanceVersion::revertToVanilla() return true; } -bool InstanceVersion::usesLegacyCustomJson() +bool InstanceVersion::hasDeprecatedVersionFiles() { - return QFile::exists(PathCombine(m_instance->instanceRoot(), "custom.json")); + if(QFile::exists(PathCombine(m_instance->instanceRoot(), "custom.json"))) + return true; + if(QFile::exists(PathCombine(m_instance->instanceRoot(), "version.json"))) + return true; + return false; +} + +bool InstanceVersion::removeDeprecatedVersionFiles() +{ + beginResetModel(); + // remove custom.json, if present + QString customPath = PathCombine(m_instance->instanceRoot(), "custom.json"); + if(QFile::exists(customPath)) + { + if(!QFile::remove(customPath)) + { + endResetModel(); + return false; + } + } + // remove version.json, if present + QString versionPath = PathCombine(m_instance->instanceRoot(), "version.json"); + if(QFile::exists(versionPath)) + { + if(!QFile::remove(versionPath)) + { + endResetModel(); + return false; + } + } + endResetModel(); + return true; } QList<std::shared_ptr<OneSixLibrary> > InstanceVersion::getActiveNormalLibs() |