Skip to content

Commit

Permalink
added interface for file mapping plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
TanninOne committed Nov 23, 2015
1 parent 9945b5e commit dda9e11
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
10 changes: 9 additions & 1 deletion src/organizercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1563,10 +1563,18 @@ void OrganizerCore::prepareStart() {
std::vector<Mapping> OrganizerCore::fileMapping()
{
IPluginGame *game = qApp->property("managed_game").value<IPluginGame *>();
return fileMapping(
MappingType result = fileMapping(
QDir::toNativeSeparators(game->dataDirectory().absolutePath()),
"\\",
directoryStructure(), directoryStructure());

for (MOBase::IPluginFileMapper *mapper : m_PluginContainer->plugins<MOBase::IPluginFileMapper>()) {
MappingType pluginMap = mapper->mappings();
result.reserve(result.size() + pluginMap.size());
result.insert(result.end(), pluginMap.begin(), pluginMap.end());
}

return result;
}

std::vector<Mapping> OrganizerCore::fileMapping(
Expand Down
8 changes: 7 additions & 1 deletion src/plugincontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<IPluginDiagnose*>(plugin);
if (diagnose != nullptr) {
bf::at_key<IPluginDiagnose>(m_Plugins).push_back(diagnose);
Expand All @@ -96,6 +96,12 @@ bool PluginContainer::registerPlugin(QObject *plugin, const QString &fileName)
);
}
}
{ // file mapper plugin
IPluginFileMapper *mapper = qobject_cast<IPluginFileMapper*>(plugin);
if (mapper != nullptr) {
bf::at_key<IPluginFileMapper>(m_Plugins).push_back(mapper);
}
}
{ // mod page plugin
IPluginModPage *modPage = qobject_cast<IPluginModPage*>(plugin);
if (verifyPlugin(modPage)) {
Expand Down
4 changes: 3 additions & 1 deletion src/plugincontainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <iplugintool.h>
#include <ipluginproxy.h>
#include <iplugininstaller.h>
#include <ipluginfilemapper.h>
#include <QtPlugin>
#include <QPluginLoader>
#include <QFile>
Expand All @@ -36,7 +37,8 @@ class PluginContainer : public QObject, public MOBase::IPluginDiagnose
boost::fusion::pair<MOBase::IPluginModPage, std::vector<MOBase::IPluginModPage*>>,
boost::fusion::pair<MOBase::IPluginPreview, std::vector<MOBase::IPluginPreview*>>,
boost::fusion::pair<MOBase::IPluginTool, std::vector<MOBase::IPluginTool*>>,
boost::fusion::pair<MOBase::IPluginProxy, std::vector<MOBase::IPluginProxy*>>
boost::fusion::pair<MOBase::IPluginProxy, std::vector<MOBase::IPluginProxy*>>,
boost::fusion::pair<MOBase::IPluginFileMapper, std::vector<MOBase::IPluginFileMapper*>>
> PluginMap;

static const unsigned int PROBLEM_PLUGINSNOTLOADED = 1;
Expand Down
10 changes: 1 addition & 9 deletions src/usvfsconnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,13 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.


#include <usvfs.h>
#include <filemapping.h>
#include <QString>
#include <QThread>
#include <QFile>
#include <QDebug>


struct Mapping {
QString source;
QString destination;
bool isDirectory;
};

typedef std::vector<Mapping> MappingType;


class LogWorker : public QThread {

Q_OBJECT
Expand Down

0 comments on commit dda9e11

Please sign in to comment.