Skip to content

Commit

Permalink
updated to use the unmanaged-mod game plugin feature
Browse files Browse the repository at this point in the history
  • Loading branch information
TanninOne committed Jun 19, 2016
1 parent cd83f4e commit 352975e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 35 deletions.
39 changes: 14 additions & 25 deletions src/modinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <versioninfo.h>
#include <appconfig.h>
#include <scriptextender.h>
#include <unmanagedmods.h>

#include <QApplication>
#include <QDirIterator>
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<UnmanagedMods>();
if (unmanaged != nullptr) {
for (const QString &modName : unmanaged->mods(!displayForeign)) {
createFromPlugin(unmanaged->displayName(modName),
unmanaged->referenceFile(modName).absoluteFilePath(),
unmanaged->secondaryFiles(modName),
directoryStructure);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/modinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/modinfoforeign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
6 changes: 3 additions & 3 deletions src/modinfoforeign.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 352975e

Please sign in to comment.