diff --git a/include/dusk/settings.h b/include/dusk/settings.h index 56d2450263..8885c9e3ef 100644 --- a/include/dusk/settings.h +++ b/include/dusk/settings.h @@ -167,6 +167,9 @@ struct UserSettings { struct { ConfigVar isoPath; ConfigVar isoVerification; +#if DUSK_TPHD + ConfigVar hdContentPath; +#endif ConfigVar graphicsBackend; ConfigVar skipPreLaunchUI; ConfigVar showPipelineCompilation; @@ -175,9 +178,6 @@ struct UserSettings { ConfigVar checkForUpdates; ConfigVar cardFileType; ConfigVar enableAdvancedSettings; -#if DUSK_TPHD - ConfigVar hdContentPath; // path to TP-HD decrypted "content" folder -#endif } backend; }; diff --git a/src/dusk/settings.cpp b/src/dusk/settings.cpp index e2bfb01e3c..c01ccf5c7c 100644 --- a/src/dusk/settings.cpp +++ b/src/dusk/settings.cpp @@ -114,6 +114,9 @@ UserSettings g_userSettings = { .backend = { .isoPath {"backend.isoPath", ""}, .isoVerification {"backend.isoVerification", DiscVerificationState::Unknown}, +#if DUSK_TPHD + .hdContentPath {"backend.hdContentPath", ""}, +#endif .graphicsBackend {"backend.graphicsBackend", "auto"}, .skipPreLaunchUI {"backend.skipPreLaunchUI", false}, .showPipelineCompilation {"backend.showPipelineCompilation", false}, @@ -122,9 +125,6 @@ UserSettings g_userSettings = { .checkForUpdates {"backend.checkForUpdates", true}, .cardFileType {"backend.cardFileType", static_cast(CARD_GCIFOLDER)}, .enableAdvancedSettings {"backend.enableAdvancedSettings", false}, -#if DUSK_TPHD - .hdContentPath {"backend.hdContentPath", ""}, -#endif } }; @@ -221,6 +221,9 @@ void registerSettings() { Register(g_userSettings.backend.isoPath); Register(g_userSettings.backend.isoVerification); +#if DUSK_TPHD + Register(g_userSettings.backend.hdContentPath); +#endif Register(g_userSettings.backend.graphicsBackend); Register(g_userSettings.backend.skipPreLaunchUI); Register(g_userSettings.backend.showPipelineCompilation); @@ -229,9 +232,6 @@ void registerSettings() { Register(g_userSettings.backend.checkForUpdates); Register(g_userSettings.backend.cardFileType); Register(g_userSettings.backend.enableAdvancedSettings); -#if DUSK_TPHD - Register(g_userSettings.backend.hdContentPath); -#endif } // Transient settings diff --git a/src/dusk/ui/prelaunch.cpp b/src/dusk/ui/prelaunch.cpp index 31cfde75e2..41db426e6d 100644 --- a/src/dusk/ui/prelaunch.cpp +++ b/src/dusk/ui/prelaunch.cpp @@ -504,9 +504,8 @@ void folder_dialog_callback(void*, const char* path, const char* error) { return; } - state.selectedHdContentPath = path; - state.errorString.clear(); - getSettings().backend.hdContentPath.setValue(state.selectedHdContentPath); + state.configuredHdContentPath = path; + getSettings().backend.hdContentPath.setValue(path); config::Save(); } @@ -645,6 +644,8 @@ void ensure_initialized() noexcept { state.activeDiscPath = state.configuredDiscPath; state.configuredDiscValidation = verification_from_config(getSettings().backend.isoVerification.getValue()); + state.configuredHdContentPath = getSettings().backend.hdContentPath; + state.activeHdContentPath = state.configuredHdContentPath; state.initialLanguage = getSettings().game.language; state.initialGraphicsBackend = getSettings().backend.graphicsBackend; state.initialCardFileType = getSettings().backend.cardFileType; @@ -669,6 +670,9 @@ bool is_restart_pending() noexcept { if (!state.activeDiscPath.empty() && state.configuredDiscPath != state.activeDiscPath) { return true; } + if (state.configuredHdContentPath != state.activeHdContentPath) { + return true; + } if (getSettings().backend.graphicsBackend.getValue() != state.initialGraphicsBackend) { return true; } diff --git a/src/dusk/ui/prelaunch.hpp b/src/dusk/ui/prelaunch.hpp index ba67a03a61..0a3477b27c 100644 --- a/src/dusk/ui/prelaunch.hpp +++ b/src/dusk/ui/prelaunch.hpp @@ -47,8 +47,8 @@ struct PrelaunchState { iso::ValidationError configuredDiscValidation = iso::ValidationError::Unknown; std::string activeDiscPath; iso::DiscInfo activeDiscInfo{}; - std::string initialHdContentPath; - std::string selectedHdContentPath; + std::string configuredHdContentPath; + std::string activeHdContentPath; GameLanguage initialLanguage = GameLanguage::English; std::string initialGraphicsBackend; int initialCardFileType = 0; diff --git a/src/dusk/ui/settings.cpp b/src/dusk/ui/settings.cpp index e41dbbe46a..d381aecd31 100644 --- a/src/dusk/ui/settings.cpp +++ b/src/dusk/ui/settings.cpp @@ -336,6 +336,38 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) { pane.add_rml("Set the disc image that Dusk uses to launch the game.

" "Changes require a restart."); }); +#if DUSK_TPHD + leftPane.register_control( + leftPane + .add_select_button({ + .key = "TPHD Content", + .getValue = + [] { + const auto& path = prelaunch_state().configuredHdContentPath; + std::string display; + if (path.empty()) { + display = "(none)"; + } else { + display = std::filesystem::path(path).string(); + if (display.empty()) { + display = path; + } + } + return display; + }, + .isModified = + [] { + const auto& state = prelaunch_state(); + const auto& active = state.activeHdContentPath; + return !active.empty() && state.configuredHdContentPath != active; + }, + }) + .on_pressed([] { open_folder_picker(); }), + rightPane, [](Pane& pane) { + pane.add_rml("Set the directory that Dusk loads eligible TPHD content from." + "

Changes require a restart."); + }); +#endif leftPane.register_control( leftPane.add_select_button({ .key = "Language",