diff options
| author | Mikaƫl Capelle <capelle.mikael@gmail.com> | 2024-06-09 12:18:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-09 12:18:17 +0200 |
| commit | 88c386d74d7d94ec16d4d84ed674eb51e31647ac (patch) | |
| tree | adf0b2537f12d11d8df77f68a84926d15b063554 /src/organizercore.cpp | |
| parent | c43535f5bcf1043c3b9c00c77967267cf1acf60f (diff) | |
Refactoring of game features for better management. (#2043)
Diffstat (limited to 'src/organizercore.cpp')
| -rw-r--r-- | src/organizercore.cpp | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 2f45116c..df098205 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -89,10 +89,11 @@ QStringList toStringList(InputIterator current, InputIterator end) } OrganizerCore::OrganizerCore(Settings& settings) - : m_UserInterface(nullptr), m_PluginContainer(nullptr), m_CurrentProfile(nullptr), - m_Settings(settings), m_Updater(&NexusInterface::instance()), - m_ModList(m_PluginContainer, this), m_PluginList(*this), - m_DirectoryRefresher(new DirectoryRefresher(settings.refreshThreadCount())), + : m_UserInterface(nullptr), m_PluginContainer(nullptr), m_GamePlugin(nullptr), + m_CurrentProfile(nullptr), m_Settings(settings), + m_Updater(&NexusInterface::instance()), m_ModList(m_PluginContainer, this), + m_PluginList(*this), + m_DirectoryRefresher(new DirectoryRefresher(this, settings.refreshThreadCount())), m_DirectoryStructure(new DirectoryEntry(L"data", nullptr, 0)), m_VirtualFileTree([this]() { return VirtualFileTree::makeTree(m_DirectoryStructure); @@ -135,16 +136,6 @@ OrganizerCore::OrganizerCore(Settings& settings) connect(this, SIGNAL(managedGameChanged(MOBase::IPluginGame const*)), &m_PluginList, SLOT(managedGameChanged(MOBase::IPluginGame const*))); - connect(this, &OrganizerCore::managedGameChanged, - [this](IPluginGame const* gamePlugin) { - ModDataContent* contentFeature = gamePlugin->feature<ModDataContent>(); - if (contentFeature) { - m_Contents = ModDataContentHolder(contentFeature->getAllContents()); - } else { - m_Contents = ModDataContentHolder(); - } - }); - connect(&m_PluginList, &PluginList::writePluginsList, &m_PluginListsWriter, &DelayedFileWriterBase::write); @@ -273,6 +264,15 @@ void OrganizerCore::connectPlugins(PluginContainer* container) connect(m_PluginContainer, &PluginContainer::pluginDisabled, [&](IPlugin* plugin) { m_PluginDisabled(plugin); }); + + connect(&m_PluginContainer->gameFeatures(), &GameFeatures::modDataContentUpdated, + [this](ModDataContent const* contentFeature) { + if (contentFeature) { + m_Contents = ModDataContentHolder(contentFeature->getAllContents()); + } else { + m_Contents = ModDataContentHolder(); + } + }); } void OrganizerCore::setManagedGame(MOBase::IPluginGame* game) @@ -454,7 +454,7 @@ void OrganizerCore::createDefaultProfile() QString profilesPath = settings().paths().profiles(); if (QDir(profilesPath).entryList(QDir::AllDirs | QDir::NoDotAndDotDot).size() == 0) { Profile newProf(QString::fromStdWString(AppConfig::defaultProfileName()), - managedGame(), false); + managedGame(), gameFeatures(), false); m_ProfileCreated(&newProf); } @@ -569,7 +569,8 @@ void OrganizerCore::setCurrentProfile(const QString& profileName) // Keep the old profile to emit signal-changed: auto oldProfile = std::move(m_CurrentProfile); - m_CurrentProfile = std::make_unique<Profile>(QDir(profileDir), managedGame()); + m_CurrentProfile = + std::make_unique<Profile>(QDir(profileDir), managedGame(), gameFeatures()); m_ModList.setProfile(m_CurrentProfile.get()); @@ -1249,7 +1250,7 @@ void OrganizerCore::refreshBSAList() { TimeThis tt("OrganizerCore::refreshBSAList()"); - DataArchives* archives = m_GamePlugin->feature<DataArchives>(); + auto archives = gameFeatures().gameFeature<DataArchives>(); if (archives != nullptr) { m_ArchivesInit = false; @@ -1482,6 +1483,11 @@ PluginContainer& OrganizerCore::pluginContainer() const return *m_PluginContainer; } +GameFeatures& OrganizerCore::gameFeatures() const +{ + return pluginContainer().gameFeatures(); +} + IPluginGame const* OrganizerCore::managedGame() const { return m_GamePlugin; @@ -1806,7 +1812,7 @@ void OrganizerCore::syncOverwrite() QString OrganizerCore::oldMO1HookDll() const { - if (auto extender = managedGame()->feature<ScriptExtender>()) { + if (auto extender = gameFeatures().gameFeature<ScriptExtender>()) { QString hookdll = QDir::toNativeSeparators(managedGame()->dataDirectory().absoluteFilePath( extender->PluginPath() + "/hook.dll")); @@ -1999,7 +2005,8 @@ std::vector<Mapping> OrganizerCore::fileMapping(const QString& profileName, } IPluginGame* game = qApp->property("managed_game").value<IPluginGame*>(); - Profile profile(QDir(m_Settings.paths().profiles() + "/" + profileName), game); + Profile profile(QDir(m_Settings.paths().profiles() + "/" + profileName), game, + gameFeatures()); MappingType result; @@ -2038,7 +2045,7 @@ std::vector<Mapping> OrganizerCore::fileMapping(const QString& profileName, } if (m_CurrentProfile->localSavesEnabled()) { - LocalSavegames* localSaves = game->feature<LocalSavegames>(); + auto localSaves = gameFeatures().gameFeature<LocalSavegames>(); if (localSaves != nullptr) { MappingType saveMap = localSaves->mappings(currentProfile()->absolutePath() + "/saves"); |
