Expose load_current_load_order_state() via GameInterface

This commit is contained in:
Oliver Hamlet
2017-11-04 17:27:15 +00:00
parent 5357858069
commit 1275a11be7
5 changed files with 30 additions and 15 deletions
+15 -2
View File
@@ -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`.
-5
View File
@@ -27,11 +27,6 @@ along with LOOT. If not, see
#include <loot/api.h>
namespace loot {
std::shared_ptr<DatabaseInterface> 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<DatabaseInterface> db, const std::string& plugin, bool evaluateConditions) {
PluginTags tags;
-4
View File
@@ -34,10 +34,6 @@ along with LOOT. If not, see
#include "plugin_tags.h"
namespace loot {
std::shared_ptr<DatabaseInterface> CreateDatabase(const GameType game,
const std::string& game_path = "",
const std::string& game_local_path = "");
PluginTags GetPluginTags(const std::shared_ptr<DatabaseInterface> db,
const std::string& plugin,
bool evaluateConditions = false);
+8 -1
View File
@@ -103,6 +103,10 @@ void bindVersionClasses(pybind11::module& module) {
}
void bindInterfaceClasses(pybind11::module& module) {
class_<GameInterface, std::shared_ptr<GameInterface>>(module, "GameInterface")
.def("load_current_load_order_state", &GameInterface::LoadCurrentLoadOrderState)
.def("get_database", &GameInterface::GetDatabase);
class_<DatabaseInterface, std::shared_ptr<DatabaseInterface>>(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") = "");
}
}
+7 -3
View File
@@ -9,7 +9,7 @@ from loot_api import WrapperVersion
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 @@ class TestLootApi(GameFixture):
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'')