From 352975e757f5e68e1e1d2738ab0cb2e9ac5b31dc Mon Sep 17 00:00:00 2001 From: Tannin Date: Sun, 19 Jun 2016 16:01:51 +0200 Subject: [PATCH] updated to use the unmanaged-mod game plugin feature --- src/modinfo.cpp | 39 ++++++++++++++------------------------- src/modinfo.h | 2 +- src/modinfoforeign.cpp | 12 ++++++------ src/modinfoforeign.h | 6 +++--- 4 files changed, 24 insertions(+), 35 deletions(-) diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 53b74244..7cb4b4ba 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -35,6 +35,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include #include @@ -75,11 +76,13 @@ ModInfo::Ptr ModInfo::createFrom(const QDir &dir, DirectoryEntry **directoryStru return result; } -ModInfo::Ptr ModInfo::createFromPlugin(const QString &espName, const QStringList &bsaNames - , DirectoryEntry ** directoryStructure) -{ +ModInfo::Ptr ModInfo::createFromPlugin(const QString &modName, + const QString &espName, + const QStringList &bsaNames, + DirectoryEntry **directoryStructure) { QMutexLocker locker(&s_Mutex); - ModInfo::Ptr result = ModInfo::Ptr(new ModInfoForeign(espName, bsaNames, directoryStructure)); + ModInfo::Ptr result = ModInfo::Ptr( + new ModInfoForeign(modName, espName, bsaNames, directoryStructure)); s_Collection.push_back(result); return result; } @@ -217,27 +220,13 @@ void ModInfo::updateFromDisc(const QString &modDirectory, } } - { // list plugins in the data directory and make a foreign-managed mod out of each - QStringList dlcPlugins = game->DLCPlugins(); - QStringList mainPlugins = game->primaryPlugins(); - QDir dataDir(game->dataDirectory()); - for (const QString &file : dataDir.entryList({ "*.esp", "*.esm" })) { - if (std::find_if(mainPlugins.begin(), mainPlugins.end(), - [&file](QString const &p) { - return p.compare(file, Qt::CaseInsensitive) == 0; }) == mainPlugins.end() - && (displayForeign // show non-dlc bundles only if the user wants them - || std::find_if(dlcPlugins.begin(), dlcPlugins.end(), - [&file](QString const &p) { - return p.compare(file, Qt::CaseInsensitive) == 0; }) != dlcPlugins.end())) { - - QFileInfo f(file); //Just so I can get a basename... - QStringList archives; - for (const QString &archiveName : dataDir.entryList({ f.baseName() + "*.bsa" })) { - archives.append(dataDir.absoluteFilePath(archiveName)); - } - - createFromPlugin(file, archives, directoryStructure); - } + UnmanagedMods *unmanaged = game->feature(); + if (unmanaged != nullptr) { + for (const QString &modName : unmanaged->mods(!displayForeign)) { + createFromPlugin(unmanaged->displayName(modName), + unmanaged->referenceFile(modName).absoluteFilePath(), + unmanaged->secondaryFiles(modName), + directoryStructure); } } diff --git a/src/modinfo.h b/src/modinfo.h index 69a3434a..501588ec 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -186,7 +186,7 @@ class ModInfo : public QObject, public MOBase::IModInterface * @param bsaNames names of archives * @return a new mod */ - static ModInfo::Ptr createFromPlugin(const QString &espName, const QStringList &bsaNames, MOShared::DirectoryEntry **directoryStructure); + static ModInfo::Ptr createFromPlugin(const QString &modName, const QString &espName, const QStringList &bsaNames, MOShared::DirectoryEntry **directoryStructure); /** * @brief retieve a name for one of the CONTENT_ enums diff --git a/src/modinfoforeign.cpp b/src/modinfoforeign.cpp index bf222166..4ba16bb1 100644 --- a/src/modinfoforeign.cpp +++ b/src/modinfoforeign.cpp @@ -43,12 +43,12 @@ QString ModInfoForeign::getDescription() const return tr("This pseudo mod represents content managed outside MO. It isn't modified by MO."); } -ModInfoForeign::ModInfoForeign(const QString &referenceFile, const QStringList &archives, +ModInfoForeign::ModInfoForeign(const QString &modName, + const QString &referenceFile, + const QStringList &archives, DirectoryEntry **directoryStructure) - : ModInfoWithConflictInfo(directoryStructure) - , m_ReferenceFile(referenceFile) - , m_Archives(archives) -{ + : ModInfoWithConflictInfo(directoryStructure), + m_ReferenceFile(referenceFile), m_Archives(archives) { m_CreationTime = QFileInfo(referenceFile).created(); - m_Name = "Unmanaged: " + QFileInfo(m_ReferenceFile).baseName(); + m_Name = "Unmanaged: " + modName; } diff --git a/src/modinfoforeign.h b/src/modinfoforeign.h index b35c099b..839bcdce 100644 --- a/src/modinfoforeign.h +++ b/src/modinfoforeign.h @@ -51,9 +51,9 @@ class ModInfoForeign : public ModInfoWithConflictInfo virtual void addInstalledFile(int, int) {} protected: - - ModInfoForeign(const QString &referenceFile, const QStringList &archives, MOShared::DirectoryEntry **directoryStructure); - + ModInfoForeign(const QString &modName, const QString &referenceFile, + const QStringList &archives, + MOShared::DirectoryEntry **directoryStructure); private: QString m_Name;