mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Refactor getArchiveFileExtension into GameSettings
This commit is contained in:
@@ -195,11 +195,4 @@ namespace loot {
|
||||
return LoadOrderHandler::IsPluginActive(pluginName);
|
||||
}
|
||||
}
|
||||
|
||||
std::string Game::getArchiveFileExtension() const {
|
||||
if (Id() == Game::fo4)
|
||||
return ".ba2";
|
||||
else
|
||||
return ".bsa";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,6 @@ namespace loot {
|
||||
// Check if the plugin is active by using the cached value if
|
||||
// available, and otherwise asking the load order handler.
|
||||
bool IsPluginActive(const std::string& pluginName) const;
|
||||
|
||||
std::string getArchiveFileExtension() const;
|
||||
private:
|
||||
bool _pluginsFullyLoaded;
|
||||
};
|
||||
|
||||
@@ -191,6 +191,13 @@ namespace loot {
|
||||
return LootPaths::getLootDataPath() / _lootFolderName / "userlist.yaml";
|
||||
}
|
||||
|
||||
std::string GameSettings::GetArchiveFileExtension() const {
|
||||
if (_id == GameSettings::fo4)
|
||||
return ".ba2";
|
||||
else
|
||||
return ".bsa";
|
||||
}
|
||||
|
||||
GameSettings& GameSettings::SetName(const std::string& name) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Setting \"" << _name << "\" name to: " << name;
|
||||
_name = name;
|
||||
|
||||
@@ -59,6 +59,8 @@ namespace loot {
|
||||
boost::filesystem::path MasterlistPath() const;
|
||||
boost::filesystem::path UserlistPath() const;
|
||||
|
||||
std::string GetArchiveFileExtension() const;
|
||||
|
||||
GameSettings& SetName(const std::string& name);
|
||||
GameSettings& SetMaster(const std::string& masterFile);
|
||||
GameSettings& SetRegistryKey(const std::string& registry);
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace loot {
|
||||
_isActive = game.LoadOrderHandler::IsPluginActive(Name());
|
||||
|
||||
// Get whether the plugin loads an archive (BSA/BA2) or not.
|
||||
const string archiveExtension = game.getArchiveFileExtension();
|
||||
const string archiveExtension = game.GetArchiveFileExtension();
|
||||
|
||||
if (game.Id() == Game::tes5) {
|
||||
// Skyrim plugins only load BSAs that exactly match their basename.
|
||||
|
||||
@@ -131,6 +131,16 @@ namespace loot {
|
||||
EXPECT_FALSE(game1 == game2);
|
||||
}
|
||||
|
||||
TEST_P(GameSettingsTest, getArchiveFileExtensionShouldReturnDotBa2IfGameIdIsFallout4) {
|
||||
GameSettings game(GameSettings::fo4);
|
||||
EXPECT_EQ(".ba2", game.GetArchiveFileExtension());
|
||||
}
|
||||
|
||||
TEST_P(GameSettingsTest, getArchiveFileExtensionShouldReturnDotBsaIfGameIdIsNotFallout4) {
|
||||
GameSettings game;
|
||||
EXPECT_EQ(".bsa", game.GetArchiveFileExtension());
|
||||
}
|
||||
|
||||
TEST_P(GameSettingsTest, setNameShouldStoreGivenValue) {
|
||||
GameSettings game;
|
||||
game.SetName("name");
|
||||
|
||||
@@ -100,14 +100,6 @@ namespace loot {
|
||||
EXPECT_THROW(game.Init(true, localPath), Error);
|
||||
}
|
||||
|
||||
TEST_P(GameTest, getArchiveFileExtensionShouldReturnDotBa2ForFallout4AndDotBsaForOtherGames) {
|
||||
Game game(GetParam());
|
||||
if (game.Id() == Game::fo4)
|
||||
EXPECT_EQ(".ba2", game.getArchiveFileExtension());
|
||||
else
|
||||
EXPECT_EQ(".bsa", game.getArchiveFileExtension());
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
// Testing on Windows will find real game installs in the Registry, so cannot
|
||||
// test autodetection fully unless on Linux.
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace loot {
|
||||
PluginTest() :
|
||||
emptyFile("EmptyFile.esm"),
|
||||
nonPluginFile("NotAPlugin.esm"),
|
||||
blankArchive("Blank" + Game(GetParam()).getArchiveFileExtension()),
|
||||
blankSuffixArchive("Blank - Different - suffix" + Game(GetParam()).getArchiveFileExtension()) {}
|
||||
blankArchive("Blank" + Game(GetParam()).GetArchiveFileExtension()),
|
||||
blankSuffixArchive("Blank - Different - suffix" + Game(GetParam()).GetArchiveFileExtension()) {}
|
||||
|
||||
inline void SetUp() {
|
||||
BaseGameTest::SetUp();
|
||||
|
||||
Reference in New Issue
Block a user