From 0a51fdf08e54218057a57e58439e2fd62cb1875e Mon Sep 17 00:00:00 2001 From: Tannin Date: Thu, 3 Sep 2015 19:33:33 +0200 Subject: DLC bsas are now auto-enabled for pre-skyrim games --- src/mainwindow.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f265d74a..41ca1589 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1333,10 +1333,26 @@ void MainWindow::updateBSAList(const QStringList &defaultArchives, const QString std::vector> items; IPluginGame *gamePlugin = qApp->property("managed_game").value(); - BSAInvalidation *invalidation = gamePlugin->feature(); + std::vector files = m_OrganizerCore.directoryStructure()->getFiles(); + + QStringList plugins = m_OrganizerCore.findFiles("", [] (const QString &fileName) -> bool { + return fileName.endsWith(".esp", Qt::CaseInsensitive) + || fileName.endsWith(".esm", Qt::CaseInsensitive); + }); - for (FileEntry::Ptr current : m_OrganizerCore.directoryStructure()->getFiles()) { + auto hasAssociatedPlugin = [&](const QString &bsaName) -> bool { + for (const QString &pluginName : plugins) { + QFileInfo pluginInfo(pluginName); + if (bsaName.startsWith(QFileInfo(pluginName).baseName(), Qt::CaseInsensitive) + && (m_OrganizerCore.pluginList()->state(pluginInfo.fileName()) == IPluginList::STATE_ACTIVE)) { + return true; + } + } + return false; + }; + + for (FileEntry::Ptr current : files) { QFileInfo fileInfo(ToQString(current->getName().c_str())); if (fileInfo.suffix().toLower() == "bsa") { @@ -1351,7 +1367,6 @@ void MainWindow::updateBSAList(const QStringList &defaultArchives, const QString index = 1; } - QString basename = fileInfo.baseName(); int originId = current->getOrigin(); FilesOrigin &origin = m_OrganizerCore.directoryStructure()->getOriginByID(originId); @@ -1368,8 +1383,10 @@ void MainWindow::updateBSAList(const QStringList &defaultArchives, const QString newItem->setCheckState(0, Qt::Checked); newItem->setDisabled(true); newItem->setData(0, Qt::UserRole, true); - } else if ((m_OrganizerCore.pluginList()->state(basename + ".esp") == IPluginList::STATE_ACTIVE) - || (m_OrganizerCore.pluginList()->state(basename + ".esm") == IPluginList::STATE_ACTIVE)) { + } else if (fileInfo.fileName().compare("update.bsa", Qt::CaseInsensitive) == 0) { + newItem->setCheckState(0, Qt::Checked); + newItem->setDisabled(true); + } else if (hasAssociatedPlugin(fileInfo.fileName())) { newItem->setCheckState(0, Qt::Checked); newItem->setDisabled(true); } else { -- cgit v1.3.1