From dda9e1197670cddb69789cc9a179d09cd8e560a6 Mon Sep 17 00:00:00 2001 From: Tannin Date: Mon, 23 Nov 2015 21:43:37 +0100 Subject: [PATCH] added interface for file mapping plugins --- src/organizercore.cpp | 10 +++++++++- src/plugincontainer.cpp | 8 +++++++- src/plugincontainer.h | 4 +++- src/usvfsconnector.h | 10 +--------- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/organizercore.cpp b/src/organizercore.cpp index a5dc393d..83d468ef 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1563,10 +1563,18 @@ void OrganizerCore::prepareStart() { std::vector OrganizerCore::fileMapping() { IPluginGame *game = qApp->property("managed_game").value(); - return fileMapping( + MappingType result = fileMapping( QDir::toNativeSeparators(game->dataDirectory().absolutePath()), "\\", directoryStructure(), directoryStructure()); + + for (MOBase::IPluginFileMapper *mapper : m_PluginContainer->plugins()) { + MappingType pluginMap = mapper->mappings(); + result.reserve(result.size() + pluginMap.size()); + result.insert(result.end(), pluginMap.begin(), pluginMap.end()); + } + + return result; } std::vector OrganizerCore::fileMapping( diff --git a/src/plugincontainer.cpp b/src/plugincontainer.cpp index 7a059cd1..a594f703 100644 --- a/src/plugincontainer.cpp +++ b/src/plugincontainer.cpp @@ -87,7 +87,7 @@ bool PluginContainer::registerPlugin(QObject *plugin, const QString &fileName) m_Organizer->settings().registerPlugin(pluginObj); } - { // diagnosis plugins + { // diagnosis plugin IPluginDiagnose *diagnose = qobject_cast(plugin); if (diagnose != nullptr) { bf::at_key(m_Plugins).push_back(diagnose); @@ -96,6 +96,12 @@ bool PluginContainer::registerPlugin(QObject *plugin, const QString &fileName) ); } } + { // file mapper plugin + IPluginFileMapper *mapper = qobject_cast(plugin); + if (mapper != nullptr) { + bf::at_key(m_Plugins).push_back(mapper); + } + } { // mod page plugin IPluginModPage *modPage = qobject_cast(plugin); if (verifyPlugin(modPage)) { diff --git a/src/plugincontainer.h b/src/plugincontainer.h index 02978e3e..70392d0b 100644 --- a/src/plugincontainer.h +++ b/src/plugincontainer.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,8 @@ class PluginContainer : public QObject, public MOBase::IPluginDiagnose boost::fusion::pair>, boost::fusion::pair>, boost::fusion::pair>, - boost::fusion::pair> + boost::fusion::pair>, + boost::fusion::pair> > PluginMap; static const unsigned int PROBLEM_PLUGINSNOTLOADED = 1; diff --git a/src/usvfsconnector.h b/src/usvfsconnector.h index beec5acc..78bb7a49 100644 --- a/src/usvfsconnector.h +++ b/src/usvfsconnector.h @@ -23,21 +23,13 @@ along with Mod Organizer. If not, see . #include +#include #include #include #include #include -struct Mapping { - QString source; - QString destination; - bool isDirectory; -}; - -typedef std::vector MappingType; - - class LogWorker : public QThread { Q_OBJECT