Files
modorganizer-plugin_python/src/runner/proxypluginwrappers.cpp
T

550 lines
12 KiB
C++
Raw Normal View History

#include "proxypluginwrappers.h"
#include <utility.h>
#include "error.h"
#include "gilock.h"
#include <QWidget>
2016-11-27 16:54:19 +02:00
namespace boost
{
// See bug https://connect.microsoft.com/VisualStudio/Feedback/Details/2852624
#if (_MSC_VER == 1900)
2016-11-27 16:54:19 +02:00
template<> const volatile MOBase::IOrganizer* get_pointer(const volatile MOBase::IOrganizer* p) { return p; }
template<> const volatile MOBase::IModInterface* get_pointer(const volatile MOBase::IModInterface* p) { return p; }
template<> const volatile MOBase::IPluginGame* get_pointer(const volatile MOBase::IPluginGame* p) { return p; }
template<> const volatile MOBase::IProfile* get_pointer(const volatile MOBase::IProfile* p) { return p; }
template<> const volatile MOBase::IModList* get_pointer(const volatile MOBase::IModList* p) { return p; }
template<> const volatile MOBase::IPluginList* get_pointer(const volatile MOBase::IPluginList* p) { return p; }
template<> const volatile MOBase::IDownloadManager* get_pointer(const volatile MOBase::IDownloadManager* p) { return p; }
template<> const volatile MOBase::IModRepositoryBridge* get_pointer(const volatile MOBase::IModRepositoryBridge* p) { return p; }
#endif
2016-11-27 16:54:19 +02:00
}
using namespace MOBase;
2016-11-27 16:54:19 +02:00
#define PYCATCH catch (const boost::python::error_already_set &) { reportPythonError(); throw MyException("unhandled exception"); }\
catch (...) { throw MyException("An unknown exception was thrown in python code"); }
/////////////////////////////
/// IPlugin Wrapper
2018-04-17 21:07:42 +01:00
bool IPluginWrapper::init(MOBase::IOrganizer *moInfo)
{
try {
2016-11-27 16:54:19 +02:00
return this->get_override("init")(boost::python::ptr(moInfo));
} PYCATCH;
}
QString IPluginWrapper::name() const
{
try {
return this->get_override("name")().as<QString>();
} PYCATCH;
}
QString IPluginWrapper::author() const
{
try {
return this->get_override("author")().as<QString>();
} PYCATCH;
}
QString IPluginWrapper::description() const
{
try {
return this->get_override("description")().as<QString>();
} PYCATCH;
}
MOBase::VersionInfo IPluginWrapper::version() const
{
try {
return this->get_override("version")().as<MOBase::VersionInfo>();
} PYCATCH;
}
bool IPluginWrapper::isActive() const
{
try {
return this->get_override("isActive")().as<bool>();
} PYCATCH;
}
QList<MOBase::PluginSetting> IPluginWrapper::settings() const
{
try {
return this->get_override("settings")().as<QList<MOBase::PluginSetting>>();
} PYCATCH;
}
/// end IPlugin Wrapper
/////////////////////////////////////
/// IPluginGame Wrapper
QString IPluginGameWrapper::gameName() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("gameName")();
} PYCATCH;
}
void IPluginGameWrapper::initializeProfile(const QDir & directory, ProfileSettings settings) const
{
2018-04-17 23:08:16 +01:00
try {
this->get_override("initializeProfile")(directory, settings);
} PYCATCH;
}
QString IPluginGameWrapper::savegameExtension() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("savegameExtension")();
} PYCATCH;
}
QString IPluginGameWrapper::savegameSEExtension() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("savegameSEExtension")();
} PYCATCH;
}
bool IPluginGameWrapper::isInstalled() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("isInstalled")();
} PYCATCH;
}
QIcon IPluginGameWrapper::gameIcon() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("gameIcon")();
} PYCATCH;
}
QDir IPluginGameWrapper::gameDirectory() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("gameDirectory")();
} PYCATCH;
}
QDir IPluginGameWrapper::dataDirectory() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("dataDirectory")();
} PYCATCH;
}
void IPluginGameWrapper::setGamePath(const QString & path)
{
2018-04-17 23:08:16 +01:00
try {
this->get_override("setGamePath")(path);
} PYCATCH;
}
QDir IPluginGameWrapper::documentsDirectory() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("documentsDirectory")();
} PYCATCH;
}
QDir IPluginGameWrapper::savesDirectory() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("savesDirectory")();
} PYCATCH;
}
QList<MOBase::ExecutableInfo> IPluginGameWrapper::executables() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("executables")();
} PYCATCH;
}
QString IPluginGameWrapper::steamAPPId() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("steamAPPId")();
} PYCATCH;
}
QStringList IPluginGameWrapper::primaryPlugins() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("primaryPlugins")();
} PYCATCH;
}
QStringList IPluginGameWrapper::gameVariants() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("gameVariants")();
} PYCATCH;
}
void IPluginGameWrapper::setGameVariant(const QString & variant)
{
2018-04-17 23:08:16 +01:00
try {
this->get_override("setGameVariant")(variant);
} PYCATCH;
}
QString IPluginGameWrapper::binaryName() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("binaryName")();
} PYCATCH;
}
QString IPluginGameWrapper::gameShortName() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("gameShortName")();
} PYCATCH;
}
QStringList IPluginGameWrapper::validShortNames() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("validShortNames")();
} PYCATCH;
}
QString IPluginGameWrapper::gameNexusName() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("gameNexusName")();
} PYCATCH;
}
QStringList IPluginGameWrapper::iniFiles() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("iniFiles")();
} PYCATCH;
}
QStringList IPluginGameWrapper::DLCPlugins() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("DLCPlugins")();
} PYCATCH;
}
QStringList IPluginGameWrapper::CCPlugins() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("CCPlugins")();
} PYCATCH;
}
IPluginGame::LoadOrderMechanism IPluginGameWrapper::loadOrderMechanism() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("loadorderMechanism")();
} PYCATCH;
}
IPluginGame::SortMechanism IPluginGameWrapper::sortMechanism() const
{
2018-04-18 12:31:16 +01:00
try {
return this->get_override("sortMechanism")();
} PYCATCH;
}
int IPluginGameWrapper::nexusModOrganizerID() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("nexusModOrganizerID")();
} PYCATCH;
}
int IPluginGameWrapper::nexusGameID() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("nexusGameID")();
} PYCATCH;
}
bool IPluginGameWrapper::looksValid(QDir const & dir) const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("looksValid")(dir);
} PYCATCH;
}
QString IPluginGameWrapper::gameVersion() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("gameVersion")();
} PYCATCH;
}
QString IPluginGameWrapper::getLauncherName() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("getLauncherName")();
} PYCATCH;
}
bool IPluginGameWrapper::init(MOBase::IOrganizer * moInfo)
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("init")(boost::python::ptr(moInfo));
2018-04-17 23:08:16 +01:00
} PYCATCH;
}
QString IPluginGameWrapper::name() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("name")();
} PYCATCH;
}
QString IPluginGameWrapper::author() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("author")();
} PYCATCH;
}
QString IPluginGameWrapper::description() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("description")();
} PYCATCH;
}
MOBase::VersionInfo IPluginGameWrapper::version() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("version")();
} PYCATCH;
}
bool IPluginGameWrapper::isActive() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("isActive")();
} PYCATCH;
}
QList<MOBase::PluginSetting> IPluginGameWrapper::settings() const
{
2018-04-17 23:08:16 +01:00
try {
return this->get_override("settings")();
} PYCATCH;
}
std::map<std::type_index, boost::any> IPluginGameWrapper::featureList() const
{
qCritical("Calling unproxied method IPluginGameWrapper::featureList()");
2018-04-17 23:08:16 +01:00
try {
return this->get_override("_featureList")();
} PYCATCH;
}
/// end IPluginGame Wrapper
/////////////////////////////////////
/// IPluginInstallerCustom Wrapper
bool IPluginInstallerCustomWrapper::init(MOBase::IOrganizer *moInfo)
{
try {
2016-11-27 16:54:19 +02:00
return this->get_override("init")(boost::python::ptr(moInfo));
} PYCATCH;
}
QString IPluginInstallerCustomWrapper::name() const
{
try {
return this->get_override("name")().as<QString>();
} PYCATCH;
}
QString IPluginInstallerCustomWrapper::author() const
{
try {
return this->get_override("author")().as<QString>();
} PYCATCH;
}
QString IPluginInstallerCustomWrapper::description() const
{
try {
return this->get_override("description")().as<QString>();
} PYCATCH;
}
MOBase::VersionInfo IPluginInstallerCustomWrapper::version() const
{
try {
return this->get_override("version")();
} PYCATCH;
}
bool IPluginInstallerCustomWrapper::isActive() const
{
try {
return this->get_override("isActive")();
} PYCATCH;
}
QList<MOBase::PluginSetting> IPluginInstallerCustomWrapper::settings() const
{
try {
return this->get_override("settings")().as<QList<MOBase::PluginSetting>>();
} PYCATCH;
}
unsigned int IPluginInstallerCustomWrapper::priority() const
{
try {
return this->get_override("priority")();
} PYCATCH;
}
bool IPluginInstallerCustomWrapper::isManualInstaller() const
{
try {
return this->get_override("isManualInstaller")();
} PYCATCH;
}
bool IPluginInstallerCustomWrapper::isArchiveSupported(const DirectoryTree &) const
{
try {
//return this->get_override("isArchiveSupported")(tree);
return false;
} PYCATCH;
}
bool IPluginInstallerCustomWrapper::isArchiveSupported(const QString &archiveName) const
{
try {
return this->get_override("isArchiveSupported")(archiveName);
} PYCATCH;
}
std::set<QString> IPluginInstallerCustomWrapper::supportedExtensions() const
{
try {
return this->get_override("supportedExtensions")().as<std::set<QString>>();
} PYCATCH;
}
IPluginInstaller::EInstallResult IPluginInstallerCustomWrapper::install(GuessedValue<QString> &modName, const QString &archiveName,
const QString &version, int modID)
{
try {
return this->get_override("install")(modName, archiveName, version, modID);
} PYCATCH;
}
void IPluginInstallerCustomWrapper::setParentWidget(QWidget *parent)
{
try {
this->get_override("setParentWidget")(parent);
} PYCATCH;
}
2018-04-17 21:07:42 +01:00
/// end IPluginInstallerCustom Wrapper
/////////////////////////////
/// IPluginTool Wrapper
2018-04-17 21:07:42 +01:00
bool IPluginToolWrapper::init(MOBase::IOrganizer *moInfo)
{
try {
return this->get_override("init")(boost::python::ptr(moInfo));
} PYCATCH;
}
QString IPluginToolWrapper::name() const
{
try {
return this->get_override("name")().as<QString>();
} PYCATCH;
}
QString IPluginToolWrapper::author() const
{
try {
return this->get_override("author")().as<QString>();
} PYCATCH;
}
QString IPluginToolWrapper::description() const
{
try {
return this->get_override("description")().as<QString>();
} PYCATCH;
}
MOBase::VersionInfo IPluginToolWrapper::version() const
{
try {
return this->get_override("version")().as<MOBase::VersionInfo>();
} PYCATCH;
}
bool IPluginToolWrapper::isActive() const
{
try {
return this->get_override("isActive")().as<bool>();
} PYCATCH;
}
QList<MOBase::PluginSetting> IPluginToolWrapper::settings() const
{
try {
return this->get_override("settings")().as<QList<MOBase::PluginSetting>>();
} PYCATCH;
}
QString IPluginToolWrapper::displayName() const
{
try {
return this->get_override("displayName")().as<QString>();
} PYCATCH;
}
QString IPluginToolWrapper::tooltip() const
{
try {
return this->get_override("tooltip")().as<QString>();
} PYCATCH;
}
QIcon IPluginToolWrapper::icon() const
{
try {
return this->get_override("icon")().as<QIcon>();
} PYCATCH;
}
void IPluginToolWrapper::setParentWidget(QWidget *parent)
{
try {
this->get_override("setParentWidget")(parent);
} PYCATCH;
}
void IPluginToolWrapper::display() const
{
try {
GILock lock;
this->get_override("display")();
} PYCATCH;
}
/// end IPluginTool Wrapper