diff options
Diffstat (limited to 'api/logic/minecraft/legacy')
-rw-r--r-- | api/logic/minecraft/legacy/LegacyInstance.cpp | 5 | ||||
-rw-r--r-- | api/logic/minecraft/legacy/LegacyInstance.h | 1 | ||||
-rw-r--r-- | api/logic/minecraft/legacy/LegacyModList.cpp | 49 | ||||
-rw-r--r-- | api/logic/minecraft/legacy/LegacyModList.h | 2 | ||||
-rw-r--r-- | api/logic/minecraft/legacy/LegacyUpgradeTask.cpp | 5 |
5 files changed, 12 insertions, 50 deletions
diff --git a/api/logic/minecraft/legacy/LegacyInstance.cpp b/api/logic/minecraft/legacy/LegacyInstance.cpp index ea81f9fb..f00eb23f 100644 --- a/api/logic/minecraft/legacy/LegacyInstance.cpp +++ b/api/logic/minecraft/legacy/LegacyInstance.cpp @@ -107,11 +107,6 @@ std::shared_ptr<LegacyModList> LegacyInstance::jarModList() const return jar_mod_list; } -QList<Mod> LegacyInstance::getJarMods() const -{ - return jarModList()->allMods(); -} - QString LegacyInstance::gameRoot() const { QFileInfo mcDir(FS::PathCombine(instanceRoot(), "minecraft")); diff --git a/api/logic/minecraft/legacy/LegacyInstance.h b/api/logic/minecraft/legacy/LegacyInstance.h index 8bbc2d88..46fca3e4 100644 --- a/api/logic/minecraft/legacy/LegacyInstance.h +++ b/api/logic/minecraft/legacy/LegacyInstance.h @@ -78,7 +78,6 @@ public: QString customBaseJar() const; std::shared_ptr<LegacyModList> jarModList() const; - QList<Mod> getJarMods() const; std::shared_ptr<WorldList> worldList() const; /*! diff --git a/api/logic/minecraft/legacy/LegacyModList.cpp b/api/logic/minecraft/legacy/LegacyModList.cpp index 22511380..23b837c1 100644 --- a/api/logic/minecraft/legacy/LegacyModList.cpp +++ b/api/logic/minecraft/legacy/LegacyModList.cpp @@ -22,8 +22,7 @@ LegacyModList::LegacyModList(const QString &dir, const QString &list_file) : m_dir(dir), m_list_file(list_file) { FS::ensureFolderPathExists(m_dir.absolutePath()); - m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs | - QDir::NoSymLinks); + m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs | QDir::NoSymLinks); m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware); } @@ -34,15 +33,11 @@ LegacyModList::LegacyModList(const QString &dir, const QString &list_file) }; typedef QList<OrderItem> OrderList; -static void internalSort(QList<Mod> &what) +static void internalSort(QList<LegacyModList::Mod> &what) { - auto predicate = [](const Mod &left, const Mod &right) + auto predicate = [](const LegacyModList::Mod &left, const LegacyModList::Mod &right) { - if (left.name() == right.name()) - { - return left.mmc_id().localeAwareCompare(right.mmc_id()) < 0; - } - return left.name().localeAwareCompare(right.name()) < 0; + return left.fileName().localeAwareCompare(right.fileName()) < 0; }; std::sort(what.begin(), what.end(), predicate); } @@ -90,7 +85,6 @@ bool LegacyModList::update() QList<Mod> newMods; m_dir.refresh(); auto folderContents = m_dir.entryInfoList(); - bool orderOrStateChanged = false; // first, process the ordered items (if any) OrderList listOrder = readListFile(m_list_file); @@ -124,48 +118,19 @@ bool LegacyModList::update() // remove from the actual folder contents list folderContents.takeAt(idx); // append the new mod - orderedMods.append(Mod(info)); - if (isEnabled != item.enabled) - orderOrStateChanged = true; - } - else - { - orderOrStateChanged = true; + orderedMods.append(info); } } - // if there are any untracked files... + // if there are any untracked files... append them sorted at the end if (folderContents.size()) { - // the order surely changed! for (auto entry : folderContents) { - newMods.append(Mod(entry)); + newMods.append(entry); } internalSort(newMods); orderedMods.append(newMods); - orderOrStateChanged = true; - } - // otherwise, if we were already tracking some mods - else if (mods.size()) - { - // if the number doesn't match, order changed. - if (mods.size() != orderedMods.size()) - orderOrStateChanged = true; - // if it does match, compare the mods themselves - else - for (int i = 0; i < mods.size(); i++) - { - if (!mods[i].strongCompare(orderedMods[i])) - { - orderOrStateChanged = true; - break; - } - } } mods.swap(orderedMods); - if (orderOrStateChanged && !m_list_file.isEmpty()) - { - qDebug() << "Mod list " << m_list_file << " changed!"; - } return true; } diff --git a/api/logic/minecraft/legacy/LegacyModList.h b/api/logic/minecraft/legacy/LegacyModList.h index 1b5b24c4..4e91958d 100644 --- a/api/logic/minecraft/legacy/LegacyModList.h +++ b/api/logic/minecraft/legacy/LegacyModList.h @@ -34,6 +34,8 @@ class MULTIMC_LOGIC_EXPORT LegacyModList { public: + using Mod = QFileInfo; + LegacyModList(const QString &dir, const QString &list_file = QString()); /// Reloads the mod list and returns true if the list changed. diff --git a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp index 9a832a24..9d86a7b5 100644 --- a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp +++ b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp @@ -7,6 +7,7 @@ #include "LegacyInstance.h" #include "minecraft/MinecraftInstance.h" #include "minecraft/ComponentList.h" +#include "LegacyModList.h" #include "classparser.h" LegacyUpgradeTask::LegacyUpgradeTask(InstancePtr origInstance) @@ -96,10 +97,10 @@ void LegacyUpgradeTask::copyFinished() components->installCustomJar(jarPath); } - auto jarMods = legacyInst->getJarMods(); + auto jarMods = legacyInst->jarModList()->allMods(); for(auto & jarMod: jarMods) { - QString modPath = jarMod.filename().absoluteFilePath(); + QString modPath = jarMod.absoluteFilePath(); qDebug() << "jarMod: " << modPath; components->installJarMods({modPath}); } |