diff --git a/plugins/script/interfaces/GameInterface.cpp b/plugins/script/interfaces/GameInterface.cpp index f029ce797c..62944fd567 100644 --- a/plugins/script/interfaces/GameInterface.cpp +++ b/plugins/script/interfaces/GameInterface.cpp @@ -1,8 +1,9 @@ #include "GameInterface.h" -#include +#include -namespace script { +namespace script +{ ScriptGame::ScriptGame(const game::IGamePtr& game) : _game(game) @@ -13,7 +14,6 @@ std::string ScriptGame::getKeyValue(const std::string& key) const return (_game != NULL) ? _game->getKeyValue(key) : ""; } - // ----------------------------------------------- std::string GameInterface::getUserEnginePath() @@ -41,11 +41,13 @@ std::string GameInterface::getFSGameBase() return GlobalGameManager().getFSGameBase(); } -ScriptGame GameInterface::currentGame() { +ScriptGame GameInterface::currentGame() +{ return ScriptGame(GlobalGameManager().currentGame()); } -GameInterface::PathList GameInterface::getVFSSearchPaths() { +GameInterface::PathList GameInterface::getVFSSearchPaths() +{ game::IGameManager::PathList paths = GlobalGameManager().getVFSSearchPaths(); PathList pathVector; @@ -55,26 +57,26 @@ GameInterface::PathList GameInterface::getVFSSearchPaths() { } // IScriptInterface implementation -void GameInterface::registerInterface(boost::python::object& nspace) +void GameInterface::registerInterface(py::module& scope, py::dict& globals) { // Add the Game object declaration - nspace["Game"] = boost::python::class_("Game", boost::python::init()) - .def("getKeyValue", &ScriptGame::getKeyValue) - ; + py::class_ game(scope, "Game"); + game.def(py::init()); + game.def("getKeyValue", &ScriptGame::getKeyValue); // Add the module declaration to the given python namespace - nspace["GlobalGameManager"] = boost::python::class_("GlobalGameManager") - .def("getUserEnginePath", &GameInterface::getUserEnginePath) - .def("getModPath", &GameInterface::getModPath) - .def("getModBasePath", &GameInterface::getModBasePath) - .def("getFSGame", &GameInterface::getFSGame) - .def("getFSGameBase", &GameInterface::getFSGameBase) - .def("currentGame", &GameInterface::currentGame) - .def("getVFSSearchPaths", &GameInterface::getVFSSearchPaths) - ; + py::class_ gameManager(scope, "GameManager"); + + gameManager.def("getUserEnginePath", &GameInterface::getUserEnginePath); + gameManager.def("getModPath", &GameInterface::getModPath); + gameManager.def("getModBasePath", &GameInterface::getModBasePath); + gameManager.def("getFSGame", &GameInterface::getFSGame); + gameManager.def("getFSGameBase", &GameInterface::getFSGameBase); + gameManager.def("currentGame", &GameInterface::currentGame); + gameManager.def("getVFSSearchPaths", &GameInterface::getVFSSearchPaths); // Now point the Python variable "GlobalGameManager" to this instance - nspace["GlobalGameManager"] = boost::python::ptr(this); + globals["GlobalGameManager"] = this; } } // namespace script diff --git a/plugins/script/interfaces/GameInterface.h b/plugins/script/interfaces/GameInterface.h index 5520f3429c..af51b83346 100644 --- a/plugins/script/interfaces/GameInterface.h +++ b/plugins/script/interfaces/GameInterface.h @@ -1,13 +1,12 @@ -#ifndef _GAME_INTERFACE_H_ -#define _GAME_INTERFACE_H_ +#pragma once -#include #include "iscript.h" #include "igame.h" #include -namespace script { +namespace script +{ class ScriptGame { @@ -34,10 +33,7 @@ class GameInterface : PathList getVFSSearchPaths(); // IScriptInterface implementation - void registerInterface(boost::python::object& nspace); + void registerInterface(py::module& scope, py::dict& globals) override; }; -typedef std::shared_ptr GameInterfacePtr; } // namespace script - -#endif /* _GAME_INTERFACE_H_ */