Permalink
Browse files

updated to use the unmanaged-mod game plugin feature

  • Loading branch information...
TanninOne committed Jun 19, 2016
1 parent cd83f4e commit 352975e757f5e68e1e1d2738ab0cb2e9ac5b31dc
Showing with 24 additions and 35 deletions.
  1. +14 −25 src/modinfo.cpp
  2. +1 −1 src/modinfo.h
  3. +6 −6 src/modinfoforeign.cpp
  4. +3 −3 src/modinfoforeign.h
View
@@ -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>
@@ -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<UnmanagedMods>();
if (unmanaged != nullptr) {
for (const QString &modName : unmanaged->mods(!displayForeign)) {
createFromPlugin(unmanaged->displayName(modName),
unmanaged->referenceFile(modName).absoluteFilePath(),
unmanaged->secondaryFiles(modName),
directoryStructure);
}
}
View
@@ -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
View
@@ -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;
}
View
@@ -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;

0 comments on commit 352975e

Please sign in to comment.