Add Get/SetAdditionalDataPaths to GameInterface

This commit is contained in:
Oliver Hamlet
2023-08-23 19:48:20 +01:00
parent 1a8eec19de
commit 46f28eef07
4 changed files with 38 additions and 4 deletions
+19
View File
@@ -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
* @{
+5 -1
View File
@@ -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
View File
@@ -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));
}