diff --git a/include/loot/game_interface.h b/include/loot/game_interface.h index 3a292a75..88ebfb96 100644 --- a/include/loot/game_interface.h +++ b/include/loot/game_interface.h @@ -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 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& additionalDataPaths) = 0; + /** * @name Metadata Access * @{ diff --git a/src/api/game/game.cpp b/src/api/game/game.cpp index 2ba6d12f..eacde10e 100644 --- a/src/api/game/game.cpp +++ b/src/api/game/game.cpp @@ -154,7 +154,7 @@ Game::Game(const GameType gameType, conditionEvaluator_( std::make_shared(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 Game::GetAdditionalDataPaths() const { + return additionalDataPaths_; +} + void Game::SetAdditionalDataPaths( const std::vector& additionalDataPaths) { additionalDataPaths_ = additionalDataPaths; diff --git a/src/api/game/game.h b/src/api/game/game.h index e68a2e14..0a00ff1f 100644 --- a/src/api/game/game.h +++ b/src/api/game/game.h @@ -52,14 +52,16 @@ public: LoadOrderHandler& GetLoadOrderHandler(); const LoadOrderHandler& GetLoadOrderHandler() const; - void SetAdditionalDataPaths( - const std::vector& additionalDataPaths); - // Game Interface Methods // //////////////////////////// GameType GetType() const override; + std::vector GetAdditionalDataPaths() const; + + void SetAdditionalDataPaths( + const std::vector& additionalDataPaths) override; + DatabaseInterface& GetDatabase() override; const DatabaseInterface& GetDatabase() const override; diff --git a/src/tests/api/interface/game_interface_test.h b/src/tests/api/interface/game_interface_test.h index 1211f51b..688b249d 100644 --- a/src/tests/api/interface/game_interface_test.h +++ b/src/tests/api/interface/game_interface_test.h @@ -70,6 +70,15 @@ INSTANTIATE_TEST_SUITE_P(, GameType::fo4, GameType::tes5se)); +TEST_P(GameInterfaceTest, setAdditionalDataPathsShouldDoThat) { + const auto paths = std::vector{ + localPath, localPath.parent_path() / "other"}; + + handle_->SetAdditionalDataPaths(paths); + + EXPECT_EQ(paths, handle_->GetAdditionalDataPaths()); +} + TEST_P(GameInterfaceTest, isValidPluginShouldReturnTrueForAValidPlugin) { EXPECT_TRUE(handle_->IsValidPlugin(blankEsm)); }