Compare commits

...
Author SHA1 Message Date
Tannin a5901d7975 extended plugin interface. Plugins can now activate/deactivate mods, install mods
suggesting a name and retrieve a list of all installed mods
2015-05-17 14:30:14 +02:00
Tannin a7b81418a5 fixes to make MO compile with mingw (also fixes some warnings generated by mingw) 2015-05-16 18:44:07 +02:00
Tannin 560e1ce0c7 Merge 2015-05-09 21:46:40 +02:00
Tannin 6edbec745d plugin can now have multiple states 2015-03-31 18:35:12 +02:00
Tom Tanner d6edcf4fa0 Adding an icon to nxmhandler so that it looks pretty in firefox 2015-03-28 10:39:40 +00:00
Tannin 50a725a1b4 Merge in changes by Tom Tanner 2015-03-27 18:24:37 +01:00
Tom Tanner a1fdb54471 Add in all the necessary stuff for scons 2015-03-25 22:35:53 +00:00
Tom Tanner e602014dda Fix a meory leak with modules that error during loading
More Sconscript stuff
2015-03-22 10:49:15 +00:00
Tom Tanner 90df417a8c Fixed Scons build for existing bits.
Changed pynedit.pro to fetch from 'standard' install location
Changed saveas code to use organizer report rather than uibase - this way it's
not dependant on the vagaries of the include path, and works the same as the
rest of the organiser directory
2015-03-20 10:34:30 +00:00
Tom Tanner cb9a7fcd2d Merge with branch1.2 2015-03-18 17:40:29 +00:00
Tom Tanner 9d2264aff8 Refactoring and cleanup. 2015-03-18 14:16:04 +00:00
Tom Tanner 0aeeb9365f Every plugin now built 2015-03-17 16:31:15 +00:00
Tom Tanner 3967d64437 Cleanup 2015-03-16 08:35:14 +00:00
Tom Tanner a7e881869e Yet more scons stuff. Now builds everything but the plugins, and installs all the dlls 2015-03-15 10:58:21 +00:00
Tom Tanner 3f66d206e8 More sconscripts set up 2015-03-14 14:59:52 +00:00
Tannin 9d48b75388 python proxy plugin should no longer throw a fit if another process locks the unpacked pythonrunner 2015-02-25 18:13:17 +01:00
Tannin 841b923751 better error handling in python runner extraction 2015-01-29 19:28:58 +01:00
Tannin 23fd430605 extended the game-plugin interface 2015-01-29 19:26:42 +01:00
Tannin 1a89e42c0f Merge with branch1.2 2015-01-24 19:34:12 +01:00
Tannin 42afc90c8d cleanup (mostly removing unused includes) 2015-01-22 19:44:38 +01:00
Tannin 9b989e9f97 bugfix: translations for some plugins weren't loaded 2015-01-11 11:14:58 +01:00
9 changed files with 145 additions and 14 deletions
+35
View File
@@ -0,0 +1,35 @@
import os
Import('qt_env')
env = qt_env.Clone()
env.AppendUnique(CPPDEFINES = [
'PROXYPYTHON_LIBRARY',
# suppress a few warnings caused by boost vs vc++ paranoia
'_SCL_SECURE_NO_WARNINGS'
])
env.AppendUnique(CPPPATH = [
'${BOOSTPATH}',
'..\\..\\pythonRunner'
])
env.AppendUnique(LIBS = 'shell32')
runner = env.File(os.path.join('..', '..', 'pythonRunner', 'pythonRunner.dll'))
runner_env = env.Clone()
runner_env.AppendUnique(CPPDEFINES = 'SCONS_BUILD')
runner_env.AppendUnique(CPPPATH = runner.dir)
rc = runner_env.RES('embedrunner.rc')
# Make sure we have the proper dependencies so it gets built
runner_env.Depends(rc, runner)
# There's a whole load of unused C++ files in here.
lib = env.SharedLibrary('proxyPython', [ 'proxypython.cpp' ] + rc)
env.InstallModule(lib)
res = env['QT_USED_MODULES']
Return('res')
+4
View File
@@ -1,7 +1,11 @@
#include "resource.h"
#ifdef SCONS_BUILD
IDR_LOADER_DLL BINARY MOVEABLE PURE pythonRunner.dll
#else
#ifdef _DEBUG
IDR_LOADER_DLL BINARY MOVEABLE PURE "..\\..\\pythonRunner\\debug\\pythonRunner.dll"
#else // _DEBUG
IDR_LOADER_DLL BINARY MOVEABLE PURE "..\\..\\pythonRunner\\release\\pythonRunner.dll"
#endif // _DEBUG
#endif
+2 -1
View File
@@ -29,7 +29,8 @@ HEADERS += proxypython.h \
OTHER_FILES += \
proxypython.json \
embedrunner.rc
embedrunner.rc\
SConscript
RC_FILE += \
embedrunner.rc
+18
View File
@@ -60,13 +60,31 @@ QString ExtractResource(WORD resourceID, const QString &szFilename)
}
LPVOID lpFile = LockResource(hFileResource);
if (lpFile == nullptr) {
throw MyException(QString("failed to lock resource: %1").arg(windowsErrorString(::GetLastError())));
}
DWORD dwSize = SizeofResource(mod, hResource);
QString outFile = QDir::tempPath() + "/" + szFilename;
HANDLE hFile = CreateFileW(outFile.toStdWString().c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
if (::GetLastError() == ERROR_SHARING_VIOLATION) {
// dll exists and is opened by another instance of MO, shouldn't be outdated then...
return outFile;
} else {
throw MyException(QString("failed to open python runner: %1").arg(windowsErrorString(::GetLastError())));
}
}
HANDLE hFileMap = CreateFileMapping(hFile, nullptr, PAGE_READWRITE, 0, dwSize, nullptr);
if (hFileMap == NULL) {
throw MyException(QString("failed to map python runner: %1").arg(windowsErrorString(::GetLastError())));
}
LPVOID lpAddress = MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0);
if (lpAddress == nullptr) {
throw MyException(QString("failed to map view of file: %1").arg(windowsErrorString(::GetLastError())));
}
CopyMemory(lpAddress, lpFile, dwSize);
+1 -1
View File
@@ -28,7 +28,7 @@ along with python proxy plugin. If not, see <http://www.gnu.org/licenses/>.
#include <pythonrunner.h>
class ProxyPython : public QObject, MOBase::IPluginProxy, MOBase::IPluginDiagnose
class ProxyPython : public QObject, public MOBase::IPluginProxy, public MOBase::IPluginDiagnose
{
Q_OBJECT
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginProxy MOBase::IPluginDiagnose)
+60
View File
@@ -0,0 +1,60 @@
Import('qt_env')
env = qt_env.Clone()
env.EnableQtModules('Core', 'Gui')
env.AppendUnique(CPPDEFINES = 'PYTHONRUNNER_LIBRARY')
# suppress a few warnings caused by boost vs vc++ paranoia
# NB HAVE_ROUND causes a warning because it's defined in pythonrunner.cpp
env.AppendUnique(CPPDEFINES = [
'_SCL_SECURE_NO_WARNINGS',
'HAVE_ROUND'
])
# QMAKE_CXXFLAGS += /Zi
# QMAKE_LFLAGS += /DEBUG
env.RequireLibraries('uibase')
# AppendUnique appears not to work with QT4
env['CPPPATH'] += [
'${BOOSTPATH}',
'${PYTHONPATH}\\include',
]
env.AppendUnique(LIBS = [
'python27', # Could be done better
])
env.AppendUnique(LIBPATH = [
'${PYTHONPATH}/libs', # Could be done better
])
# We have to 'persuade' moc to generate certain other targets and inject them
# into the list of cpps
targets = env.AddExtraMoc(env.Glob('*.h'))
# pythontoolwrapper doesnt compile and isn't in the project file
cpp_files = [
x for x in Glob('*.cpp') if x.name != 'pythontoolwrapper.cpp'
]
lib = env.SharedLibrary('pythonRunner', cpp_files + targets)
#This is referred to from inside a resource file. We don't install it.
#env.InstallModule(lib)
# However...
# we do need boost-python and pythonvv.dll and pythonvv.zip (though the last
# isn't needed to just bring up the module)
#env.Pseudo('install')
#env.Depends('install',
# (env.Install('${INSTALL_PATH}', 'pyCfg.py'),
# env.Install(os.path.join('${INSTALL_PATH}', 'data'),
# ( ui, rc, 'settings.json' )),
# ))
res = env['QT_USED_MODULES']
Return('res')
+6 -3
View File
@@ -13,7 +13,7 @@ CONFIG += warn_on
DEFINES += PYTHONRUNNER_LIBRARY
# suppress a few warnings caused by boost vs vc++ paranoia
DEFINES += _SCL_SECURE_NO_WARNINGS HAVE_ROUND
DEFINES += _SCL_SECURE_NO_WARNINGS HAVE_ROUND NOMINMAX
!include(../LocalPaths.pri) {
@@ -37,8 +37,8 @@ CONFIG(debug, debug|release) {
LIBS += -L$$OUT_PWD/../uibase/debug
} else {
LIBS += -L$$OUT_PWD/../uibase/release
QMAKE_CXXFLAGS += /Zi
QMAKE_LFLAGS += /DEBUG
msvc:QMAKE_CXXFLAGS += /Zi
msvc:QMAKE_LFLAGS += /DEBUG
}
INCLUDEPATH += "$${BOOSTPATH}" "$${PYTHONPATH}/include" "$${PYTHONPATH}/Lib/site-packages/PyQt5/include" ../uibase
@@ -58,3 +58,6 @@ SRCDIR ~= s,/,$$QMAKE_DIR_SEP,g
DSTDIR ~= s,/,$$QMAKE_DIR_SEP,g
QMAKE_POST_LINK += xcopy /y /I $$quote($$SRCDIR\\$${TARGET}*.pdb) $$quote($$DSTDIR)\\plugins $$escape_expand(\\n)
OTHER_FILES += \
SConscript
+5 -1
View File
@@ -385,6 +385,7 @@ template <> struct MetaData<IDownloadManager> { static const char *className() {
template <> struct MetaData<QObject> { static const char *className() { return "QObject"; } };
template <> struct MetaData<QWidget> { static const char *className() { return "QWidget"; } };
template <> struct MetaData<QIcon> { static const char *className() { return "QIcon"; } };
template <> struct MetaData<QStringList> { static const char *className() { return "QStringList"; } };
template <> struct MetaData<QVariant> { static const char *className() { return "QVariant"; } };
@@ -648,6 +649,7 @@ BOOST_PYTHON_MODULE(mobase)
//QClass_converters<QObject>();
QClass_converters<QWidget>();
QClass_converters<QIcon>();
QClass_converters<QStringList>();
QInterface_converters<IDownloadManager>();
@@ -718,7 +720,7 @@ BOOST_PYTHON_MODULE(mobase)
.def("persistent", bpy::pure_virtual(&IOrganizer::persistent))
.def("setPersistent", bpy::pure_virtual(&IOrganizer::setPersistent))
.def("pluginDataPath", bpy::pure_virtual(&IOrganizer::pluginDataPath))
.def("installMod", bpy::pure_virtual(&IOrganizer::installMod), bpy::return_value_policy<bpy::reference_existing_object>())
.def("installMod", bpy::pure_virtual(&IOrganizer::installMod),(bpy::arg("nameSuggestion")=""), bpy::return_value_policy<bpy::reference_existing_object>())
.def("downloadManager", bpy::pure_virtual(&IOrganizer::downloadManager), bpy::return_value_policy<bpy::reference_existing_object>())
.def("pluginList", bpy::pure_virtual(&IOrganizer::pluginList), bpy::return_value_policy<bpy::reference_existing_object>())
.def("modList", bpy::pure_virtual(&IOrganizer::modList), bpy::return_value_policy<bpy::reference_existing_object>())
@@ -814,7 +816,9 @@ BOOST_PYTHON_MODULE(mobase)
Functor2_converter<const QString&, IModList::ModStates>(); // converter for the onModStateChanged-callback
bpy::class_<IModListWrapper, boost::noncopyable>("IModList")
.def("displayName", bpy::pure_virtual(&MOBase::IModList::displayName))
.def("allMods", bpy::pure_virtual(&MOBase::IModList::allMods))
.def("state", bpy::pure_virtual(&MOBase::IModList::state))
.def("setActive", bpy::pure_virtual(&MOBase::IModList::setActive))
.def("priority", bpy::pure_virtual(&MOBase::IModList::priority))
.def("setPriority", bpy::pure_virtual(&MOBase::IModList::setPriority))
.def("onModStateChanged", bpy::pure_virtual(&MOBase::IModList::onModStateChanged))
+14 -8
View File
@@ -15,6 +15,9 @@
#include <imodrepositorybridge.h>
#include <imodinterface.h>
#include <iinstallationmanager.h>
#include <idownloadmanager.h>
#include <ipluginlist.h>
#include <imodlist.h>
#include "error.h"
#include "gilock.h"
@@ -214,7 +217,7 @@ struct IOrganizerWrapper: MOBase::IOrganizer, boost::python::wrapper<MOBase::IOr
virtual QVariant persistent(const QString &pluginName, const QString &key, const QVariant &def = QVariant()) const { return this->get_override("persistent")(pluginName, key, def); }
virtual void setPersistent(const QString &pluginName, const QString &key, const QVariant &value, bool sync = true) { this->get_override("setPersistent")(pluginName, key, value, sync); }
virtual QString pluginDataPath() const { return this->get_override("pluginDataPath")(); }
virtual MOBase::IModInterface *installMod(const QString &fileName) { return this->get_override("installMod")(fileName); }
virtual MOBase::IModInterface *installMod(const QString &fileName, const QString &nameSuggestion = QString()) { return this->get_override("installMod")(fileName, nameSuggestion); }
virtual MOBase::IDownloadManager *downloadManager() { return this->get_override("downloadManager")(); }
virtual MOBase::IPluginList *pluginList() { return this->get_override("pluginList")(); }
virtual MOBase::IModList *modList() { return this->get_override("modList")(); }
@@ -277,7 +280,7 @@ struct IModInterfaceWrapper: MOBase::IModInterface, boost::python::wrapper<MOBas
struct IPluginListWrapper: MOBase::IPluginList, boost::python::wrapper<MOBase::IPluginList> {
virtual PluginState state(const QString &name) const { return this->get_override("state")(name); }
virtual PluginStates state(const QString &name) const { return this->get_override("state")(name); }
virtual int priority(const QString &name) const { return this->get_override("priority")(name); }
virtual int loadOrder(const QString &name) const { return this->get_override("loadOrder")(name); }
virtual bool isMaster(const QString &name) const { return this->get_override("isMaster")(name); }
@@ -285,16 +288,19 @@ struct IPluginListWrapper: MOBase::IPluginList, boost::python::wrapper<MOBase::I
virtual QString origin(const QString &name) const { return this->get_override("origin")(name); }
virtual bool onRefreshed(const std::function<void ()> &callback) { return this->get_override("onRefreshed")(callback); }
virtual bool onPluginMoved(const std::function<void (const QString &, int, int)> &callback) { return this->get_override("onPluginMoved")(callback); }
virtual bool onPluginStateChanged(const std::function<void (const QString &, PluginStates)> &callback) override { return this->get_override("onPluginStateChanged")(callback); }
};
struct IModListWrapper: MOBase::IModList, boost::python::wrapper<MOBase::IModList> {
virtual QString displayName(const QString &internalName) const { return this->get_override("displayName")(internalName); }
virtual ModStates state(const QString &name) const { return this->get_override("state")(name); }
virtual int priority(const QString &name) const { return this->get_override("priority")(name); }
virtual bool setPriority(const QString &name, int newPriority) { return this->get_override("setPriority")(name, newPriority); }
virtual bool onModStateChanged(const std::function<void (const QString &, ModStates)> &func) { return this->get_override("onModStateChanged")(func); }
virtual bool onModMoved(const std::function<void (const QString &, int, int)> &func) { return this->get_override("onModMoved")(func); }
virtual QString displayName(const QString &internalName) const override { return this->get_override("displayName")(internalName); }
virtual QStringList allMods() const override { return this->get_override("allMods")(); }
virtual ModStates state(const QString &name) const override { return this->get_override("state")(name); }
virtual int priority(const QString &name) const override { return this->get_override("priority")(name); }
virtual bool setActive(const QString &name, bool active) override { return this->get_override("setActive")(name, active); }
virtual bool setPriority(const QString &name, int newPriority) override { return this->get_override("setPriority")(name, newPriority); }
virtual bool onModStateChanged(const std::function<void (const QString &, ModStates)> &func) override { return this->get_override("onModStateChanged")(func); }
virtual bool onModMoved(const std::function<void (const QString &, int, int)> &func) override { return this->get_override("onModMoved")(func); }
};
#endif // UIBASEWRAPPERS_H