diff --git a/CMakeLists.txt b/CMakeLists.txt index 732e6230..2f0d6f79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,8 +162,7 @@ set(CEF_PRECOMPILED_BINARIES_DIR "${SOURCE_DIR}/Release") # General Settings ############################## -set (LOOT_SRC "${CMAKE_SOURCE_DIR}/src/backend/app/loot_paths.cpp" - "${CMAKE_BINARY_DIR}/generated/loot_version.cpp" +set (LOOT_SRC "${CMAKE_BINARY_DIR}/generated/loot_version.cpp" "${CMAKE_SOURCE_DIR}/src/backend/error_categories.cpp" "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_evaluator.cpp" "${CMAKE_SOURCE_DIR}/src/backend/metadata/conditional_metadata.cpp" @@ -188,8 +187,7 @@ set (LOOT_SRC "${CMAKE_SOURCE_DIR}/src/backend/app/loot_paths.cpp" "${CMAKE_SOURCE_DIR}/src/backend/helpers/language.cpp" "${CMAKE_SOURCE_DIR}/src/backend/helpers/version.cpp") -set (LOOT_HEADERS "${CMAKE_SOURCE_DIR}/src/backend/app/loot_paths.h" - "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_evaluator.h" +set (LOOT_HEADERS "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_evaluator.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/condition_grammar.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/conditional_metadata.h" "${CMAKE_SOURCE_DIR}/src/backend/metadata/file.h" @@ -232,6 +230,7 @@ set (LOOT_GUI_SRC "${CMAKE_SOURCE_DIR}/src/gui/main.cpp" "${CMAKE_SOURCE_DIR}/src/gui/loot_app.cpp" "${CMAKE_SOURCE_DIR}/src/gui/loot_scheme_handler_factory.cpp" "${CMAKE_SOURCE_DIR}/src/gui/query_handler.cpp" + "${CMAKE_SOURCE_DIR}/src/gui/state/loot_paths.cpp" "${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.cpp" "${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.cpp" "${CMAKE_SOURCE_DIR}/src/resource.rc") @@ -272,6 +271,7 @@ set (LOOT_GUI_HEADERS "${CMAKE_SOURCE_DIR}/src/gui/editor_message.h" "${CMAKE_SOURCE_DIR}/src/gui/query/sort_plugins_query.h" "${CMAKE_SOURCE_DIR}/src/gui/query/update_masterlist_query.h" "${CMAKE_SOURCE_DIR}/src/gui/query_handler.h" + "${CMAKE_SOURCE_DIR}/src/gui/state/loot_paths.h" "${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.h" "${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.h" "${CMAKE_SOURCE_DIR}/src/gui/resource.h" @@ -302,8 +302,7 @@ set (LOOT_API_HEADERS "${CMAKE_SOURCE_DIR}/include/loot/api.h" set (LOOT_TESTS_SRC "${CMAKE_SOURCE_DIR}/src/tests/backend/main.cpp") -set (LOOT_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/backend/app/loot_paths_test.h" - "${CMAKE_SOURCE_DIR}/src/tests/backend/game/game_test.h" +set (LOOT_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/backend/game/game_test.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/game/game_cache_test.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/game/game_settings_test.h" "${CMAKE_SOURCE_DIR}/src/tests/backend/game/load_order_handler_test.h" @@ -337,12 +336,15 @@ set(LOOT_API_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/tests/api/api_game_operatio "${CMAKE_SOURCE_DIR}/src/tests/api/is_compatible_test.h" "${CMAKE_SOURCE_DIR}/src/tests/common_game_test_fixture.h") -set(LOOT_GUI_TESTS_SRC "${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.cpp" +set(LOOT_GUI_TESTS_SRC "${CMAKE_SOURCE_DIR}/src/gui/state/loot_paths.cpp" + "${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.cpp" "${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.cpp" "${CMAKE_SOURCE_DIR}/src/tests/gui/main.cpp") -set (LOOT_GUI_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.h" +set (LOOT_GUI_TESTS_HEADERS "${CMAKE_SOURCE_DIR}/src/gui/state/loot_paths.h" + "${CMAKE_SOURCE_DIR}/src/gui/state/loot_settings.h" "${CMAKE_SOURCE_DIR}/src/gui/state/loot_state.h" + "${CMAKE_SOURCE_DIR}/src/tests/gui/state/loot_paths_test.h" "${CMAKE_SOURCE_DIR}/src/tests/gui/state/loot_settings_test.h" "${CMAKE_SOURCE_DIR}/src/tests/gui/state/loot_state_test.h") diff --git a/src/api/api.cpp b/src/api/api.cpp index b1b6665a..1b7f5136 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -28,7 +28,6 @@ #include #include "api/api_database.h" -#include "backend/app/loot_paths.h" namespace fs = boost::filesystem; @@ -50,7 +49,9 @@ LOOT_API bool IsCompatible(const unsigned int versionMajor, const unsigned int v LOOT_API std::shared_ptr CreateDatabase(const GameType game, const std::string& gamePath, const std::string& gameLocalPath) { - loot::LootPaths::initialise(""); + // Set the locale to get UTF-8 conversions working correctly. + std::locale::global(boost::locale::generator().generate("")); + boost::filesystem::path::imbue(std::locale()); //Disable logging or else stdout will get overrun. boost::log::core::get()->set_logging_enabled(false); diff --git a/src/gui/loot_app.cpp b/src/gui/loot_app.cpp index 7f6638d0..c41feb3a 100644 --- a/src/gui/loot_app.cpp +++ b/src/gui/loot_app.cpp @@ -28,7 +28,7 @@ #include #include -#include "backend/app/loot_paths.h" +#include "gui/state/loot_paths.h" #include "backend/helpers/helpers.h" #include "backend/helpers/language.h" #include "gui/loot_handler.h" diff --git a/src/gui/loot_handler.cpp b/src/gui/loot_handler.cpp index c7b2b657..bc4d2081 100644 --- a/src/gui/loot_handler.cpp +++ b/src/gui/loot_handler.cpp @@ -36,7 +36,7 @@ #include #include -#include "backend/app/loot_paths.h" +#include "gui/state/loot_paths.h" #include "gui/helpers.h" #include "gui/loot_scheme_handler_factory.h" #include "gui/query_handler.h" diff --git a/src/gui/loot_scheme_handler_factory.cpp b/src/gui/loot_scheme_handler_factory.cpp index 4d4fd055..92ac7450 100644 --- a/src/gui/loot_scheme_handler_factory.cpp +++ b/src/gui/loot_scheme_handler_factory.cpp @@ -24,7 +24,7 @@ along with LOOT. If not, see #include "loot_scheme_handler_factory.h" -#include "backend/app/loot_paths.h" +#include "gui/state/loot_paths.h" #include #include diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 5990c6ae..d8605133 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -31,7 +31,7 @@ #include #include -#include "backend/app/loot_paths.h" +#include "gui/state/loot_paths.h" #include "gui/loot_app.h" #ifdef _WIN32 diff --git a/src/gui/query/open_log_location_query.h b/src/gui/query/open_log_location_query.h index 41948600..37aba823 100644 --- a/src/gui/query/open_log_location_query.h +++ b/src/gui/query/open_log_location_query.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_OPEN_LOG_LOCATION_QUERY #define LOOT_GUI_QUERY_OPEN_LOG_LOCATION_QUERY -#include "backend/app/loot_paths.h" +#include "gui/state/loot_paths.h" #include "gui/helpers.h" #include "gui/query/query.h" diff --git a/src/gui/query/open_readme_query.h b/src/gui/query/open_readme_query.h index 70b1b43a..a7584642 100644 --- a/src/gui/query/open_readme_query.h +++ b/src/gui/query/open_readme_query.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_OPEN_README_QUERY #define LOOT_GUI_QUERY_OPEN_README_QUERY -#include "backend/app/loot_paths.h" +#include "gui/state/loot_paths.h" #include "gui/helpers.h" #include "gui/query/query.h" diff --git a/src/gui/query_handler.cpp b/src/gui/query_handler.cpp index a445a40b..c211f387 100644 --- a/src/gui/query_handler.cpp +++ b/src/gui/query_handler.cpp @@ -70,7 +70,7 @@ #include "gui/resource.h" #include "gui/yaml_simple_message_helpers.h" -#include "backend/app/loot_paths.h" +#include "gui/state/loot_paths.h" #include "backend/plugin/plugin_sorter.h" #include "backend/helpers/helpers.h" #include "gui/query/json.h" diff --git a/src/backend/app/loot_paths.cpp b/src/gui/state/loot_paths.cpp similarity index 100% rename from src/backend/app/loot_paths.cpp rename to src/gui/state/loot_paths.cpp diff --git a/src/backend/app/loot_paths.h b/src/gui/state/loot_paths.h similarity index 100% rename from src/backend/app/loot_paths.h rename to src/gui/state/loot_paths.h diff --git a/src/gui/state/loot_settings.cpp b/src/gui/state/loot_settings.cpp index 76051a2d..453f33c9 100644 --- a/src/gui/state/loot_settings.cpp +++ b/src/gui/state/loot_settings.cpp @@ -28,7 +28,7 @@ #include -#include "backend/app/loot_paths.h" +#include "gui/state/loot_paths.h" #include "loot/loot_version.h" using std::lock_guard; diff --git a/src/gui/state/loot_state.cpp b/src/gui/state/loot_state.cpp index e6f8ed72..b485af8f 100644 --- a/src/gui/state/loot_state.cpp +++ b/src/gui/state/loot_state.cpp @@ -35,9 +35,9 @@ #include #include "loot/exception/game_detection_error.h" -#include "backend/app/loot_paths.h" #include "backend/helpers/helpers.h" #include "backend/helpers/language.h" +#include "gui/state/loot_paths.h" #include "loot/loot_version.h" #ifdef _WIN32 @@ -290,7 +290,7 @@ std::list LootState::toGames(const std::vector& settings) { for (const auto& element : settings) { games.push_back(Game(element, LootPaths::getLootDataPath())); } - + return games; } diff --git a/src/tests/backend/game/game_test.h b/src/tests/backend/game/game_test.h index 4e6e28ce..438344fe 100644 --- a/src/tests/backend/game/game_test.h +++ b/src/tests/backend/game/game_test.h @@ -95,15 +95,6 @@ TEST_P(GameTest, isInstalledShouldBeTrueIfGamePathIsValid) { TEST_P(GameTest, initShouldThrowOnLinuxIfGamePathIsNotGiven) { Game game = Game(GameSettings(GetParam()), ""); EXPECT_THROW(game.Init(), GameDetectionError); - - game = Game(GameSettings(GetParam()), lootDataPath); - EXPECT_THROW(game.Init(), GameDetectionError); - - game = Game(GameSettings(GetParam()), "", localPath); - EXPECT_THROW(game.Init(), GameDetectionError); - - game = Game(GameSettings(GetParam()), lootDataPath, localPath); - EXPECT_THROW(game.Init(), GameDetectionError); } TEST_P(GameTest, initShouldThrowOnLinuxIfLocalPathIsNotGiven) { @@ -113,14 +104,14 @@ TEST_P(GameTest, initShouldThrowOnLinuxIfLocalPathIsNotGiven) { } #else TEST_P(GameTest, initShouldNotThrowOnWindowsIfLocalPathIsNotGiven) { - Game game = Game(GameSettings(GetParam()).SetGamePath(dataPath.parent_path()), ""); + Game game = Game(GameSettings(GetParam()).SetGamePath(dataPath.parent_path()), "", localPath); EXPECT_NO_THROW(game.Init()); } #endif TEST_P(GameTest, initShouldNotCreateAGameFolderIfTheLootDataPathIsEmpty) { - Game game = Game(GameSettings(GetParam()).SetGamePath(dataPath.parent_path()), ""); + Game game = Game(GameSettings(GetParam()).SetGamePath(dataPath.parent_path()), "", localPath); ASSERT_FALSE(boost::filesystem::exists(lootDataPath / game.FolderName())); EXPECT_NO_THROW(game.Init()); diff --git a/src/tests/backend/main.cpp b/src/tests/backend/main.cpp index 24f00445..40a7c8ac 100644 --- a/src/tests/backend/main.cpp +++ b/src/tests/backend/main.cpp @@ -24,7 +24,6 @@ #include -#include "tests/backend/app/loot_paths_test.h" #include "tests/backend/game/game_test.h" #include "tests/backend/game/game_cache_test.h" #include "tests/backend/game/game_settings_test.h" diff --git a/src/tests/gui/main.cpp b/src/tests/gui/main.cpp index fd3221a2..623d230c 100644 --- a/src/tests/gui/main.cpp +++ b/src/tests/gui/main.cpp @@ -24,6 +24,7 @@ #include +#include "tests/gui/state/loot_paths_test.h" #include "tests/gui/state/loot_settings_test.h" #include "tests/gui/state/loot_state_test.h" diff --git a/src/tests/backend/app/loot_paths_test.h b/src/tests/gui/state/loot_paths_test.h similarity index 98% rename from src/tests/backend/app/loot_paths_test.h rename to src/tests/gui/state/loot_paths_test.h index 175ca689..90cea7ba 100644 --- a/src/tests/backend/app/loot_paths_test.h +++ b/src/tests/gui/state/loot_paths_test.h @@ -25,7 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_BACKEND_LOOT_PATHS_TEST #define LOOT_TESTS_BACKEND_LOOT_PATHS_TEST -#include "backend/app/loot_paths.h" +#include "gui/state/loot_paths.h" #include