diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-05-05 00:10:59 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-09 01:38:29 +0200 |
commit | 4c3bd416c65ec887209fa06b0a5634099b77f322 (patch) | |
tree | f656031d147aba8f8dd621de2bd452ea1bfd86b4 /logic/VersionFinal.cpp | |
parent | aade36860c373268857ca821c14a13f38c880b1a (diff) | |
download | MultiMC-4c3bd416c65ec887209fa06b0a5634099b77f322.tar MultiMC-4c3bd416c65ec887209fa06b0a5634099b77f322.tar.gz MultiMC-4c3bd416c65ec887209fa06b0a5634099b77f322.tar.lz MultiMC-4c3bd416c65ec887209fa06b0a5634099b77f322.tar.xz MultiMC-4c3bd416c65ec887209fa06b0a5634099b77f322.zip |
Much change, very jarmod.
Diffstat (limited to 'logic/VersionFinal.cpp')
-rw-r--r-- | logic/VersionFinal.cpp | 69 |
1 files changed, 52 insertions, 17 deletions
diff --git a/logic/VersionFinal.cpp b/logic/VersionFinal.cpp index 18bd360b..5bac4bcf 100644 --- a/logic/VersionFinal.cpp +++ b/logic/VersionFinal.cpp @@ -21,6 +21,7 @@ #include "OneSixVersionBuilder.h" #include "OneSixInstance.h" +#include "VersionFilterData.h" #include <pathutils.h> VersionFinal::VersionFinal(OneSixInstance *instance, QObject *parent) @@ -63,17 +64,34 @@ bool VersionFinal::canRemove(const int index) const return false; } +bool VersionFinal::preremove(VersionFilePtr versionfile) +{ + bool ok = true; + for(auto & jarmod: versionfile->jarMods) + { + QString fullpath =PathCombine(m_instance->jarModsDir(), jarmod->name); + QFileInfo finfo (fullpath); + if(finfo.exists(fullpath)) + ok &= QFile::remove(fullpath); + } + return ok; +} + bool VersionFinal::remove(const int index) { - if (canRemove(index) && QFile::remove(versionFiles.at(index)->filename)) + if (!canRemove(index)) + return false; + if(!preremove(versionFiles[index])) { - beginResetModel(); - versionFiles.removeAt(index); - reapply(true); - endResetModel(); - return true; + return false; } - return false; + if(!QFile::remove(versionFiles.at(index)->filename)) + return false; + beginResetModel(); + versionFiles.removeAt(index); + reapply(true); + endResetModel(); + return true; } bool VersionFinal::remove(const QString id) @@ -129,7 +147,11 @@ bool VersionFinal::removeFtbPack() bool VersionFinal::isVanilla() { QDir patches(PathCombine(m_instance->instanceRoot(), "patches/")); - return versionFiles.size() > 1 || QFile::exists(PathCombine(m_instance->instanceRoot(), "custom.json")); + if(versionFiles.size() > 1) + return false; + if(QFile::exists(PathCombine(m_instance->instanceRoot(), "custom.json"))) + return false; + return true; } bool VersionFinal::revertToVanilla() @@ -140,7 +162,16 @@ bool VersionFinal::revertToVanilla() { if ((*it)->fileId != "org.multimc.version.json") { - QFile::remove((*it)->filename); + if(!preremove(*it)) + { + endResetModel(); + return false; + } + if(!QFile::remove((*it)->filename)) + { + endResetModel(); + return false; + } it = versionFiles.erase(it); } else @@ -303,16 +334,15 @@ void VersionFinal::move(const int index, const MoveDirection direction) { return; } - - VersionFilePtr we = versionFiles[index]; - VersionFilePtr them = versionFiles[theirIndex]; - if (!we || !them) + if(direction == MoveDown) { - return; + beginMoveRows(QModelIndex(), index, index, QModelIndex(), theirIndex+1); + } + else + { + beginMoveRows(QModelIndex(), index, index, QModelIndex(), theirIndex); } - beginMoveRows(QModelIndex(), index, index, QModelIndex(), theirIndex); - versionFiles.replace(theirIndex, we); - versionFiles.replace(index, them); + versionFiles.swap(index, theirIndex); endMoveRows(); auto order = getExistingOrder(); @@ -396,5 +426,10 @@ void VersionFinal::finalize() }; finalizeArguments(vanillaMinecraftArguments, vanillaProcessArguments); finalizeArguments(minecraftArguments, processArguments); + // use legacy launch for this version if the version id is legacy + if(g_VersionFilterData.legacyLaunchWhitelist.contains(id)) + { + traits.insert("legacyLaunch"); + } } |