diff --git a/include/dusk/settings.h b/include/dusk/settings.h index 131ee5958c..f0d753dd35 100644 --- a/include/dusk/settings.h +++ b/include/dusk/settings.h @@ -2,6 +2,7 @@ #define DUSK_CONFIG_H #include +#include #include "dusk/config_var.hpp" @@ -274,6 +275,7 @@ struct UserSettings { UserSettings& getSettings(); +std::filesystem::path tphd_content_path(); bool tphd_active(); void registerSettings(); diff --git a/src/dusk/settings.cpp b/src/dusk/settings.cpp index b3e97ac000..7b9e594cc9 100644 --- a/src/dusk/settings.cpp +++ b/src/dusk/settings.cpp @@ -1,5 +1,8 @@ #include "dusk/settings.h" #include "dusk/config.hpp" +#include "dusk/main.h" + +#include namespace dusk { @@ -189,9 +192,26 @@ UserSettings& getSettings() { return g_userSettings; } -bool tphd_active() { +std::filesystem::path tphd_content_path() { +#if DUSK_TPHD const std::string& hdPath = g_userSettings.backend.hdContentPath; - return !hdPath.empty(); + if (!hdPath.empty()) { + return hdPath; + } + + if (!ConfigPath.empty()) { + std::error_code ec; + auto localPath = ConfigPath / "tphd" / "content"; + if (std::filesystem::is_directory(localPath, ec)) { + return localPath; + } + } +#endif + return {}; +} + +bool tphd_active() { + return !tphd_content_path().empty(); } void registerSettings() { diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index ef8ba9e314..a8882a2adc 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -740,7 +740,7 @@ int game_main(int argc, char* argv[]) { #if DUSK_TPHD { - const std::string& hdPath = dusk::getSettings().backend.hdContentPath; + const auto hdPath = dusk::tphd_content_path(); if (!hdPath.empty()) { dusk::tphd::set_hd_content_path(hdPath); }