From 3659284ab6bdbf0845cf846600a26db688584d6f Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Mon, 23 Nov 2015 18:32:30 +0000 Subject: Remove most instances of GameInfo::getname, and transfer getDLCPlugins to the plugingame interface Also commented out startDownloadNexusFile as it doesn't appear to be used anywhere --- src/downloadmanager.cpp | 3 ++- src/downloadmanager.h | 2 ++ src/mainwindow.cpp | 2 +- src/modinfo.cpp | 24 +++++++++++++++--------- src/modinfo.h | 18 +++++++++++------- src/organizercore.cpp | 8 ++++---- src/shared/fallout3info.cpp | 10 ---------- src/shared/fallout3info.h | 1 - src/shared/falloutnvinfo.cpp | 14 -------------- src/shared/falloutnvinfo.h | 34 ---------------------------------- src/shared/gameinfo.h | 3 --- src/shared/oblivioninfo.cpp | 23 ----------------------- src/shared/oblivioninfo.h | 35 ----------------------------------- src/shared/skyriminfo.cpp | 11 ----------- src/shared/skyriminfo.h | 2 -- 15 files changed, 35 insertions(+), 155 deletions(-) (limited to 'src') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index bc78cdc6..e0d76765 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1235,13 +1235,14 @@ int DownloadManager::startDownloadURLs(const QStringList &urls) return m_ActiveDownloads.size() - 1; } +/* This doesn't appear to be used by anything int DownloadManager::startDownloadNexusFile(int modID, int fileID) { int newID = m_ActiveDownloads.size(); addNXMDownload(QString("nxm://%1/mods/%2/files/%3").arg(ToQString(MOShared::GameInfo::instance().getGameName())).arg(modID).arg(fileID)); return newID; } - +*/ QString DownloadManager::downloadPath(int id) { return getFilePath(id); diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 57bd592d..f13cc65d 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -328,7 +328,9 @@ public: virtual int startDownloadURLs(const QStringList &urls); + /* This doesn't appear to be used anywhere virtual int startDownloadNexusFile(int modID, int fileID); + */ virtual QString downloadPath(int id); /** diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7142bcb1..3c331c65 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -358,7 +358,7 @@ MainWindow::~MainWindow() void MainWindow::updateWindowTitle(const QString &accountName, bool premium) { QString title = QString("%1 Mod Organizer v%2").arg( - ToQString(GameInfo::instance().getGameName()), + m_OrganizerCore.managedGame()->gameName(), m_OrganizerCore.getVersion().displayString()); if (accountName.isEmpty()) { diff --git a/src/modinfo.cpp b/src/modinfo.cpp index e0d888e6..59205b12 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -203,7 +203,7 @@ unsigned int ModInfo::findMod(const boost::function &filter } -void ModInfo::updateFromDisc(const QString &modDirectory, DirectoryEntry **directoryStructure, bool displayForeign) +void ModInfo::updateFromDisc(const QString &modDirectory, DirectoryEntry **directoryStructure, bool displayForeign, MOBase::IPluginGame const *game) { QMutexLocker lock(&s_Mutex); s_Collection.clear(); @@ -219,19 +219,25 @@ void ModInfo::updateFromDisc(const QString &modDirectory, DirectoryEntry **direc } { // list plugins in the data directory and make a foreign-managed mod out of each - std::vector dlcPlugins = GameInfo::instance().getDLCPlugins(); - QDir dataDir(QDir::fromNativeSeparators(ToQString(GameInfo::instance().getGameDirectory())) + "/data"); - foreach (const QFileInfo &file, dataDir.entryInfoList(QStringList() << "*.esp" << "*.esm")) { - if ((file.baseName() != "Update") // hide update - && (file.baseName() != ToQString(GameInfo::instance().getGameName())) // hide the game esp + QStringList dlcPlugins = game->getDLCPlugins(); + QStringList mainPlugins = game->getPrimaryPlugins(); + 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(dlcPlugins.begin(), dlcPlugins.end(), ToWString(file.fileName())) != dlcPlugins.end())) { + || 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; - foreach (const QString archiveName, dataDir.entryList(QStringList() << file.baseName() + "*.bsa")) { + for (const QString &archiveName : dataDir.entryList({ f.baseName() + "*.bsa" })) { archives.append(dataDir.absoluteFilePath(archiveName)); } - createFromPlugin(file.fileName(), archives, directoryStructure); + createFromPlugin(file, archives, directoryStructure); } } } diff --git a/src/modinfo.h b/src/modinfo.h index da97b09b..6de4123b 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -23,19 +23,23 @@ along with Mod Organizer. If not, see . #include "nexusinterface.h" #include #include +//#include -#include +#include +class QDir; #include -#include -#include #include -#include +#include +#include + +#include + #include #include #include -#include -using MOBase::ModRepositoryFileInfo; +namespace MOBase { class IPluginGame; } +namespace MOShared { class DirectoryEntry; } /** * @brief Represents meta information about a single mod. @@ -103,7 +107,7 @@ public: /** * @brief read the mod directory and Mod ModInfo objects for all subdirectories **/ - static void updateFromDisc(const QString &modDirectory, MOShared::DirectoryEntry **directoryStructure, bool displayForeign); + static void updateFromDisc(const QString &modDirectory, MOShared::DirectoryEntry **directoryStructure, bool displayForeign, const MOBase::IPluginGame *game); static void clear() { s_Collection.clear(); s_ModsByName.clear(); s_ModsByModID.clear(); } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index ee69c46b..7a2f95d3 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -320,7 +320,7 @@ void OrganizerCore::updateExecutablesList(QSettings &settings) return; } - m_ExecutablesList.init(m_PluginContainer->managedGame(ToQString(GameInfo::instance().getGameName()))); + m_ExecutablesList.init(managedGame()); qDebug("setting up configured executables"); @@ -348,7 +348,7 @@ void OrganizerCore::updateExecutablesList(QSettings &settings) settings.endArray(); // TODO this has nothing to do with executables list move to an appropriate function! - ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign()); + ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign(), managedGame()); } void OrganizerCore::setUserInterface(IUserInterface *userInterface, QWidget *widget) @@ -1125,7 +1125,7 @@ void OrganizerCore::refreshModList(bool saveChanges) if (saveChanges) { m_CurrentProfile->modlistWriter().writeImmediately(true); } - ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign()); + ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign(), managedGame()); m_CurrentProfile->refreshModStatus(); @@ -1367,7 +1367,7 @@ void OrganizerCore::directory_refreshed() void OrganizerCore::profileRefresh() { // have to refresh mods twice (again in refreshModList), otherwise the refresh isn't complete. Not sure why - ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign()); + ModInfo::updateFromDisc(m_Settings.getModDirectory(), &m_DirectoryStructure, m_Settings.displayForeign(), managedGame()); m_CurrentProfile->refreshModStatus(); refreshModList(); diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp index 9c6ad5b9..95d1d299 100644 --- a/src/shared/fallout3info.cpp +++ b/src/shared/fallout3info.cpp @@ -63,16 +63,6 @@ std::wstring Fallout3Info::getRegPathStatic() } -std::vector Fallout3Info::getDLCPlugins() -{ - return boost::assign::list_of (L"ThePitt.esm") - (L"Anchorage.esm") - (L"BrokenSteel.esm") - (L"PointLookout.esm") - (L"Zeta.esm") - ; -} - std::vector Fallout3Info::getSavegameAttachmentExtensions() { return std::vector(); diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index 90bb6ec0..ae6a27c7 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -43,7 +43,6 @@ public: virtual std::wstring getGameName() const { return L"Fallout 3"; } virtual std::wstring getGameShortName() const { return L"Fallout3"; } - virtual std::vector getDLCPlugins(); virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp index 4601caf5..b5fb4f04 100644 --- a/src/shared/falloutnvinfo.cpp +++ b/src/shared/falloutnvinfo.cpp @@ -63,20 +63,6 @@ std::wstring FalloutNVInfo::getRegPathStatic() } } -std::vector FalloutNVInfo::getDLCPlugins() -{ - return boost::assign::list_of (L"DeadMoney.esm") - (L"HonestHearts.esm") - (L"OldWorldBlues.esm") - (L"LonesomeRoad.esm") - (L"GunRunnersArsenal.esm") - (L"CaravanPack.esm") - (L"ClassicPack.esm") - (L"MercenaryPack.esm") - (L"TribalPack.esm") - ; -} - std::vector FalloutNVInfo::getSavegameAttachmentExtensions() { return std::vector(); diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index 613694b2..2179bf2f 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -43,40 +43,6 @@ public: virtual std::wstring getGameName() const { return L"New Vegas"; } virtual std::wstring getGameShortName() const { return L"FalloutNV"; } -// virtual bool requiresSteam() const { return true; } - -/* virtual std::wstring getInvalidationBSA() - { - return L"Fallout - Invalidation.bsa"; - } - - virtual bool isInvalidationBSA(const std::wstring &bsaName) - { - static LPCWSTR invalidation[] = { L"Fallout - AI!.bsa", L"Fallout - Invalidation.bsa", nullptr }; - - for (int i = 0; invalidation[i] != nullptr; ++i) { - if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) { - return true; - } - } - return false; - } - - virtual std::vector getVanillaBSAs() - { - return boost::assign::list_of (L"Fallout - Textures.bsa") - (L"Fallout - Textures2.bsa") - (L"Fallout - Meshes.bsa") - (L"Fallout - Voices1.bsa") - (L"Fallout - Sound.bsa") - (L"Fallout - Misc.bsa"); - } - - virtual std::vector getPrimaryPlugins() - { - return boost::assign::list_of(L"falloutnv.esm"); - }*/ - virtual std::vector getDLCPlugins(); virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index e1a70597..9ae42159 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -74,9 +74,6 @@ public: // get a list of file extensions for additional files belonging to a save game virtual std::vector getSavegameAttachmentExtensions() = 0; - // get a set of esp/esm files that are part of known dlcs - virtual std::vector getDLCPlugins() = 0; - //**USED IN HOOKDLL // file name of this games ini file(s) virtual std::vector getIniFileNames() = 0; diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp index 4b0a8499..27de1275 100644 --- a/src/shared/oblivioninfo.cpp +++ b/src/shared/oblivioninfo.cpp @@ -66,29 +66,6 @@ std::wstring OblivionInfo::getRegPathStatic() - - - - - - - -std::vector OblivionInfo::getDLCPlugins() -{ - return boost::assign::list_of (L"DLCShiveringIsles.esp") - (L"Knights.esp") - (L"DLCFrostcrag.esp") - (L"DLCSpellTomes.esp") - (L"DLCMehrunesRazor.esp") - (L"DLCOrrery.esp") - (L"DLCSpellTomes.esp") - (L"DLCThievesDen.esp") - (L"DLCVileLair.esp") - (L"DLCHorseArmor.esp") - ; -} - - std::vector OblivionInfo::getSavegameAttachmentExtensions() { return boost::assign::list_of(L"obse"); diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index fcdac6bd..2a550e0e 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -40,41 +40,6 @@ public: virtual std::wstring getGameName() const { return L"Oblivion"; } virtual std::wstring getGameShortName() const { return L"Oblivion"; } -/* - virtual std::wstring getInvalidationBSA() - { - return L"Oblivion - Invalidation.bsa"; - } - - virtual bool isInvalidationBSA(const std::wstring &bsaName) - { - static LPCWSTR invalidation[] = { L"Oblivion - Invalidation.bsa", L"ArchiveInvalidationInvalidated!.bsa", - L"BSARedirection.bsa", nullptr }; - - for (int i = 0; invalidation[i] != nullptr; ++i) { - if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) { - return true; - } - } - return false; - } - - virtual std::vector getVanillaBSAs() - { - return boost::assign::list_of(L"Oblivion - Meshes.bsa") - (L"Oblivion - Textures - Compressed.bsa") - (L"Oblivion - Sounds.bsa") - (L"Oblivion - Voices1.bsa") - (L"Oblivion - Voices2.bsa") - (L"Oblivion - Misc.bsa"); - } - - virtual std::vector getPrimaryPlugins() - { - return boost::assign::list_of(L"oblivion.esm"); - }*/ - - virtual std::vector getDLCPlugins(); virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index bd901357..189d2ed0 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -91,17 +91,6 @@ GameInfo::LoadOrderMechanism SkyrimInfo::getLoadOrderMechanism() const } } -std::vector SkyrimInfo::getDLCPlugins() -{ - return boost::assign::list_of (L"Dawnguard.esm") - (L"Dragonborn.esm") - (L"HearthFires.esm") - (L"HighResTexturePack01.esp") - (L"HighResTexturePack02.esp") - (L"HighResTexturePack03.esp") - ; -} - std::vector SkyrimInfo::getSavegameAttachmentExtensions() { return boost::assign::list_of(L"skse"); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index f26cd065..741f76c9 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -45,8 +45,6 @@ public: virtual LoadOrderMechanism getLoadOrderMechanism() const; - virtual std::vector getDLCPlugins(); - virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) -- cgit v1.3.1