diff --git a/docs/reference.rst b/docs/reference.rst index f51e771..5517c9a 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -141,13 +141,26 @@ Functions Initialise the current global locale using the given ID. Wraps :cpp:func:`loot::InitialiseLocale`. -.. py:function:: loot_api.create_database(game : loot_api.GameType, [game_path : unicode = u'', [game_local_path : unicode = u'']]) -> loot_api.DatabaseInterface +.. py:function:: loot_api.create_game_handle(game : loot_api.GameType, [game_path : unicode = u'', [game_local_path : unicode = u'']]) -> loot_api.GameInterface - Initialise a new database handle. Wraps :cpp:func:`loot::CreateDatabase`. + Initialise a new game handle. Wraps :cpp:func:`loot::CreateGameHandle`. Classes ======= +.. py:class:: loot_api.GameInterface + + Wraps :cpp:class:`loot::GameInterface`. + + .. py:function:: loot_api.get_database() -> loot_api.DatabaseInterface + + Get a database handle. Wraps :cpp:func:`loot::GetDatabase`. + + .. py:function:: loot_api.load_current_load_order_state() -> NoneType + + Load the current load order state, discarding any previously held state. + Wraps :cpp:func:`loot::LoadCurrentLoadOrderState`. + .. py:class:: loot_api.DatabaseInterface Wraps :cpp:class:`loot::DatabaseInterface`. diff --git a/src/convenience.cpp b/src/convenience.cpp index a7cc184..6aa5c4f 100644 --- a/src/convenience.cpp +++ b/src/convenience.cpp @@ -27,11 +27,6 @@ along with LOOT. If not, see #include namespace loot { -std::shared_ptr CreateDatabase(const GameType game, const std::string & game_path, const std::string & game_local_path) { - auto gameHandle = CreateGameHandle(game, game_path, game_local_path); - - return gameHandle->GetDatabase(); -} PluginTags GetPluginTags(const std::shared_ptr db, const std::string& plugin, bool evaluateConditions) { PluginTags tags; diff --git a/src/convenience.h b/src/convenience.h index 08d2a60..b606620 100644 --- a/src/convenience.h +++ b/src/convenience.h @@ -34,10 +34,6 @@ along with LOOT. If not, see #include "plugin_tags.h" namespace loot { -std::shared_ptr CreateDatabase(const GameType game, - const std::string& game_path = "", - const std::string& game_local_path = ""); - PluginTags GetPluginTags(const std::shared_ptr db, const std::string& plugin, bool evaluateConditions = false); diff --git a/src/main.cpp b/src/main.cpp index 0237df7..1f90eb1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -103,6 +103,10 @@ void bindVersionClasses(pybind11::module& module) { } void bindInterfaceClasses(pybind11::module& module) { + class_>(module, "GameInterface") + .def("load_current_load_order_state", &GameInterface::LoadCurrentLoadOrderState) + .def("get_database", &GameInterface::GetDatabase); + class_>(module, "DatabaseInterface") .def("load_lists", &DatabaseInterface::LoadLists, arg("masterlist_path"), arg("userlist_path") = "") .def("update_masterlist", &DatabaseInterface::UpdateMasterlist) @@ -133,7 +137,10 @@ void bindFunctions(pybind11::module& module) { module.def("initialise_locale", &InitialiseLocale); - module.def("create_database", &CreateDatabase, arg("game"), arg("game_path") = "", arg("game_local_path") = ""); + module.def("create_game_handle", &CreateGameHandle, + arg("game"), + arg("game_path") = "", + arg("game_local_path") = ""); } } diff --git a/src/test.py b/src/test.py index 4a7d7b2..1d383bf 100644 --- a/src/test.py +++ b/src/test.py @@ -9,7 +9,7 @@ from loot_api import GameType from loot_api import SimpleMessage from loot_api import MessageType -from loot_api import create_database +from loot_api import create_game_handle from loot_api import is_compatible from loot_api import set_logging_callback from loot_api import initialise_locale @@ -58,7 +58,8 @@ def test_wrapper_version(self): self.assertEqual(WrapperVersion.string(), "3.0.0") def test_create_db(self): - db = create_database(GameType.tes4, self.game_path, self.local_path) + game = create_game_handle(GameType.tes4, self.game_path, self.local_path) + db = game.get_database() self.assertNotEqual(db, None) class TestDatabaseInterface(GameFixture): @@ -67,7 +68,10 @@ class TestDatabaseInterface(GameFixture): def setUp(self): super(TestDatabaseInterface, self).setUp() - self.db = create_database(GameType.tes4, self.game_path, self.local_path) + game = create_game_handle(GameType.tes4, self.game_path, self.local_path) + game.load_current_load_order_state() + + self.db = game.get_database() def test_load_lists(self): self.db.load_lists(self.masterlist_path, u'')