mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Add Get/SetAdditionalDataPaths to GameInterface
This commit is contained in:
@@ -39,6 +39,25 @@ public:
|
||||
*/
|
||||
virtual GameType GetType() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Gets the currently-set additional data paths.
|
||||
* @details Only Fallout 4 installed from the Microsoft Store is configured
|
||||
* with any additional data paths by default, as its DLC directories
|
||||
* are installed outside of the Fallout 4 install path.
|
||||
*/
|
||||
virtual std::vector<std::filesystem::path> GetAdditionalDataPaths() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Set additional data paths.
|
||||
* @details The additional data paths are used when interacting with the load
|
||||
* order, evaluating conditions and scanning for archives (BSA/BA2
|
||||
* depending on the game). Additional data paths are used in the
|
||||
* order they are given, and take precedence over the game's main
|
||||
* data path.
|
||||
*/
|
||||
virtual void SetAdditionalDataPaths(
|
||||
const std::vector<std::filesystem::path>& additionalDataPaths) = 0;
|
||||
|
||||
/**
|
||||
* @name Metadata Access
|
||||
* @{
|
||||
|
||||
@@ -154,7 +154,7 @@ Game::Game(const GameType gameType,
|
||||
conditionEvaluator_(
|
||||
std::make_shared<ConditionEvaluator>(GetType(), DataPath())),
|
||||
database_(ApiDatabase(conditionEvaluator_)),
|
||||
additionalDataPaths_(GetAdditionalDataPaths(GetType(), DataPath())) {
|
||||
additionalDataPaths_(::GetAdditionalDataPaths(GetType(), DataPath())) {
|
||||
conditionEvaluator_->SetAdditionalDataPaths(additionalDataPaths_);
|
||||
}
|
||||
|
||||
@@ -182,6 +182,10 @@ const DatabaseInterface& Game::GetDatabase() const { return database_; }
|
||||
|
||||
DatabaseInterface& Game::GetDatabase() { return database_; }
|
||||
|
||||
std::vector<std::filesystem::path> Game::GetAdditionalDataPaths() const {
|
||||
return additionalDataPaths_;
|
||||
}
|
||||
|
||||
void Game::SetAdditionalDataPaths(
|
||||
const std::vector<std::filesystem::path>& additionalDataPaths) {
|
||||
additionalDataPaths_ = additionalDataPaths;
|
||||
|
||||
+5
-3
@@ -52,14 +52,16 @@ public:
|
||||
LoadOrderHandler& GetLoadOrderHandler();
|
||||
const LoadOrderHandler& GetLoadOrderHandler() const;
|
||||
|
||||
void SetAdditionalDataPaths(
|
||||
const std::vector<std::filesystem::path>& additionalDataPaths);
|
||||
|
||||
// Game Interface Methods //
|
||||
////////////////////////////
|
||||
|
||||
GameType GetType() const override;
|
||||
|
||||
std::vector<std::filesystem::path> GetAdditionalDataPaths() const;
|
||||
|
||||
void SetAdditionalDataPaths(
|
||||
const std::vector<std::filesystem::path>& additionalDataPaths) override;
|
||||
|
||||
DatabaseInterface& GetDatabase() override;
|
||||
const DatabaseInterface& GetDatabase() const override;
|
||||
|
||||
|
||||
@@ -70,6 +70,15 @@ INSTANTIATE_TEST_SUITE_P(,
|
||||
GameType::fo4,
|
||||
GameType::tes5se));
|
||||
|
||||
TEST_P(GameInterfaceTest, setAdditionalDataPathsShouldDoThat) {
|
||||
const auto paths = std::vector<std::filesystem::path>{
|
||||
localPath, localPath.parent_path() / "other"};
|
||||
|
||||
handle_->SetAdditionalDataPaths(paths);
|
||||
|
||||
EXPECT_EQ(paths, handle_->GetAdditionalDataPaths());
|
||||
}
|
||||
|
||||
TEST_P(GameInterfaceTest, isValidPluginShouldReturnTrueForAValidPlugin) {
|
||||
EXPECT_TRUE(handle_->IsValidPlugin(blankEsm));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user