diff --git a/src/core/host_settings.h b/src/core/host_settings.h index b35c9c385..13f845407 100644 --- a/src/core/host_settings.h +++ b/src/core/host_settings.h @@ -66,8 +66,5 @@ void SetGameSettingsLayer(SettingsInterface* sif); /// Sets the input profile settings layer. Called by VMManager when the game changes. void SetInputSettingsLayer(SettingsInterface* sif); - -/// Updates the variables in the EmuFolders namespace, reloading subsystems if needed. Must call with the lock held. -void UpdateEmuFolders(); } // namespace Internal } // namespace Host \ No newline at end of file diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 723667b91..1ae6af320 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -9,6 +9,8 @@ #include "controller.h" #include "host.h" #include "host_display.h" +#include "host_settings.h" +#include "system.h" #include #include #include @@ -1230,6 +1232,26 @@ void EmuFolders::Save(SettingsInterface& si) si.SetStringValue("Folders", "Textures", Path::MakeRelative(Textures, DataRoot).c_str()); } +void EmuFolders::Update() +{ + const std::string old_gamesettings(EmuFolders::GameSettings); + const std::string old_inputprofiles(EmuFolders::InputProfiles); + const std::string old_memorycards(EmuFolders::MemoryCards); + + // have to manually grab the lock here, because of the ReloadGameSettings() below. + { + auto lock = Host::GetSettingsLock(); + LoadConfig(*Host::Internal::GetBaseSettingsLayer()); + EnsureFoldersExist(); + } + + if (old_gamesettings != EmuFolders::GameSettings || old_inputprofiles != EmuFolders::InputProfiles) + System::ReloadGameSettings(false); + + if (System::IsValid() && old_memorycards != EmuFolders::MemoryCards) + System::UpdateMemoryCardTypes(); +} + bool EmuFolders::EnsureFoldersExist() { bool result = FileSystem::EnsureDirectoryExists(Bios.c_str(), false); diff --git a/src/core/settings.h b/src/core/settings.h index 244a07d05..d6b11ec84 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -445,4 +445,7 @@ void SetDefaults(); bool EnsureFoldersExist(); void LoadConfig(SettingsInterface& si); void Save(SettingsInterface& si); + +/// Updates the variables in the EmuFolders namespace, reloading subsystems if needed. +void Update(); } // namespace EmuFolders diff --git a/src/duckstation-qt/foldersettingswidget.cpp b/src/duckstation-qt/foldersettingswidget.cpp index 2d6dab880..1ec285453 100644 --- a/src/duckstation-qt/foldersettingswidget.cpp +++ b/src/duckstation-qt/foldersettingswidget.cpp @@ -12,13 +12,15 @@ FolderSettingsWidget::FolderSettingsWidget(SettingsDialog* dialog, QWidget* pare m_ui.setupUi(this); SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.cache, m_ui.cacheBrowse, m_ui.cacheOpen, m_ui.cacheReset, - "Folders", "Cache", "cache"); + "Folders", "Cache", Path::Combine(EmuFolders::DataRoot, "cache")); SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.covers, m_ui.coversBrowse, m_ui.coversOpen, m_ui.coversReset, - "Folders", "Covers", "covers"); + "Folders", "Covers", Path::Combine(EmuFolders::DataRoot, "covers")); SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.screenshots, m_ui.screenshotsBrowse, m_ui.screenshotsOpen, - m_ui.screenshotsReset, "Folders", "Screenshots", "screenshots"); + m_ui.screenshotsReset, "Folders", "Screenshots", + Path::Combine(EmuFolders::DataRoot, "screenshots")); SettingWidgetBinder::BindWidgetToFolderSetting(sif, m_ui.saveStates, m_ui.saveStatesBrowse, m_ui.saveStatesOpen, - m_ui.saveStatesReset, "Folders", "SaveStates", "savestates"); + m_ui.saveStatesReset, "Folders", "SaveStates", + Path::Combine(EmuFolders::DataRoot, "savestates")); } FolderSettingsWidget::~FolderSettingsWidget() = default; diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 208dd8182..294e9e52e 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -529,6 +529,17 @@ void EmuThread::reloadGameSettings(bool display_osd_messages /* = false */) System::ReloadGameSettings(display_osd_messages); } +void EmuThread::updateEmuFolders() +{ + if (!isOnThread()) + { + QMetaObject::invokeMethod(this, &EmuThread::updateEmuFolders, Qt::QueuedConnection); + return; + } + + EmuFolders::Update(); +} + void EmuThread::startFullscreenUI() { if (!isOnThread()) diff --git a/src/duckstation-qt/qthost.h b/src/duckstation-qt/qthost.h index 2913afece..772012ed2 100644 --- a/src/duckstation-qt/qthost.h +++ b/src/duckstation-qt/qthost.h @@ -145,6 +145,7 @@ public Q_SLOTS: void setDefaultSettings(bool system = true, bool controller = true); void applySettings(bool display_osd_messages = false); void reloadGameSettings(bool display_osd_messages = false); + void updateEmuFolders(); void reloadInputSources(); void reloadInputBindings(); void enumerateInputDevices(); diff --git a/src/duckstation-qt/settingwidgetbinder.h b/src/duckstation-qt/settingwidgetbinder.h index 23ffde718..5babc2481 100644 --- a/src/duckstation-qt/settingwidgetbinder.h +++ b/src/duckstation-qt/settingwidgetbinder.h @@ -880,10 +880,7 @@ static void BindWidgetToFolderSetting(SettingsInterface* sif, WidgetType* widget Host::DeleteBaseSettingValue(section.c_str(), key.c_str()); } - Panic("Fixme"); -#if 0 g_emu_thread->updateEmuFolders(); -#endif }); if (browse_button) @@ -910,7 +907,7 @@ static void BindWidgetToFolderSetting(SettingsInterface* sif, WidgetType* widget { QObject::connect( reset_button, &QAbstractButton::clicked, reset_button, [widget, default_value = std::move(default_value)]() { - Accessor::setStringValue(widget, QString::fromStdString(Path::Combine(EmuFolders::AppRoot, default_value))); + Accessor::setStringValue(widget, QString::fromStdString(default_value)); }); } } diff --git a/src/frontend-common/fullscreen_ui.cpp b/src/frontend-common/fullscreen_ui.cpp index 66fdb9921..03268c603 100644 --- a/src/frontend-common/fullscreen_ui.cpp +++ b/src/frontend-common/fullscreen_ui.cpp @@ -1644,7 +1644,7 @@ void FullscreenUI::DrawFolderSetting(const char* title, const char* section, con GetEditingSettingsInterface()->SetStringValue(section.c_str(), key.c_str(), relative_path.c_str()); SetSettingsChanged(); - Host::RunOnCPUThread(&Host::Internal::UpdateEmuFolders); + Host::RunOnCPUThread(EmuFolders::Update); CloseFileSelector(); }); diff --git a/src/frontend-common/host_settings.cpp b/src/frontend-common/host_settings.cpp index a4d01a8e5..4e3c967a3 100644 --- a/src/frontend-common/host_settings.cpp +++ b/src/frontend-common/host_settings.cpp @@ -138,7 +138,3 @@ void Host::Internal::SetInputSettingsLayer(SettingsInterface* sif) std::unique_lock lock(s_settings_mutex); s_layered_settings_interface.SetLayer(LayeredSettingsInterface::LAYER_INPUT, sif); } - -void Host::Internal::UpdateEmuFolders() -{ -}