@@ -35,6 +35,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
3535#include < versioninfo.h>
3636#include < appconfig.h>
3737#include < scriptextender.h>
38+ #include < unmanagedmods.h>
3839
3940#include < QApplication>
4041#include < QDirIterator>
@@ -75,11 +76,13 @@ ModInfo::Ptr ModInfo::createFrom(const QDir &dir, DirectoryEntry **directoryStru
7576 return result;
7677}
7778
78- ModInfo::Ptr ModInfo::createFromPlugin (const QString &espName, const QStringList &bsaNames
79- , DirectoryEntry ** directoryStructure)
80- {
79+ ModInfo::Ptr ModInfo::createFromPlugin (const QString &modName,
80+ const QString &espName,
81+ const QStringList &bsaNames,
82+ DirectoryEntry **directoryStructure) {
8183 QMutexLocker locker (&s_Mutex);
82- ModInfo::Ptr result = ModInfo::Ptr (new ModInfoForeign (espName, bsaNames, directoryStructure));
84+ ModInfo::Ptr result = ModInfo::Ptr (
85+ new ModInfoForeign (modName, espName, bsaNames, directoryStructure));
8386 s_Collection.push_back (result);
8487 return result;
8588}
@@ -217,27 +220,13 @@ void ModInfo::updateFromDisc(const QString &modDirectory,
217220 }
218221 }
219222
220- { // list plugins in the data directory and make a foreign-managed mod out of each
221- QStringList dlcPlugins = game->DLCPlugins ();
222- QStringList mainPlugins = game->primaryPlugins ();
223- QDir dataDir (game->dataDirectory ());
224- for (const QString &file : dataDir.entryList ({ " *.esp" , " *.esm" })) {
225- if (std::find_if (mainPlugins.begin (), mainPlugins.end (),
226- [&file](QString const &p) {
227- return p.compare (file, Qt::CaseInsensitive) == 0 ; }) == mainPlugins.end ()
228- && (displayForeign // show non-dlc bundles only if the user wants them
229- || std::find_if (dlcPlugins.begin (), dlcPlugins.end (),
230- [&file](QString const &p) {
231- return p.compare (file, Qt::CaseInsensitive) == 0 ; }) != dlcPlugins.end ())) {
232-
233- QFileInfo f (file); // Just so I can get a basename...
234- QStringList archives;
235- for (const QString &archiveName : dataDir.entryList ({ f.baseName () + " *.bsa" })) {
236- archives.append (dataDir.absoluteFilePath (archiveName));
237- }
238-
239- createFromPlugin (file, archives, directoryStructure);
240- }
223+ UnmanagedMods *unmanaged = game->feature <UnmanagedMods>();
224+ if (unmanaged != nullptr ) {
225+ for (const QString &modName : unmanaged->mods (!displayForeign)) {
226+ createFromPlugin (unmanaged->displayName (modName),
227+ unmanaged->referenceFile (modName).absoluteFilePath (),
228+ unmanaged->secondaryFiles (modName),
229+ directoryStructure);
241230 }
242231 }
243232
0 commit comments