diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index d28c8df4f..94bbc6f2c 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -322,6 +322,7 @@ static float GetEffectiveFloatSetting(SettingsInterface* bsi, const char* sectio float default_value); static TinyString GetEffectiveTinyStringSetting(SettingsInterface* bsi, const char* section, const char* key, const char* default_value); +static void BeginResetSettings(); static void DoCopyGameSettings(); static void DoClearGameSettings(); static void CopyGlobalControllerSettingsToGame(); @@ -3465,6 +3466,20 @@ void FullscreenUI::PopulatePatchesAndCheatsList() s_state.game_settings_interface->GetStringList(Cheats::CHEATS_CONFIG_SECTION, Cheats::PATCH_ENABLE_CONFIG_KEY); } +void FullscreenUI::BeginResetSettings() +{ + OpenConfirmMessageDialog(FSUI_STR("Restore Defaults"), + FSUI_STR("Are you sure you want to restore the default settings? Any preferences will be " + "lost.\n\nYou cannot undo this action."), + [](bool result) { + if (!result) + return; + + Host::RequestResetSettings(true, false); + ShowToast(std::string(), FSUI_STR("Settings reset to default.")); + }); +} + void FullscreenUI::DoCopyGameSettings() { if (!s_state.game_settings_interface) @@ -3966,6 +3981,15 @@ void FullscreenUI::DrawInterfaceSettingsPage() FSUI_CSTR("Shows enhancement settings in the bottom-right corner of the screen."), "Display", "ShowEnhancements", false); + MenuHeading(FSUI_CSTR("Operations")); + { + if (MenuButton(FSUI_ICONSTR(ICON_FA_DUMPSTER_FIRE, "Restore Defaults"), + FSUI_CSTR("Resets all settings to the defaults."))) + { + BeginResetSettings(); + } + } + EndMenuButtons(); } @@ -4413,9 +4437,7 @@ void FullscreenUI::BeginResetControllerSettings() if (!result) return; - SettingsInterface* dsi = GetEditingSettingsInterface(); - - Settings::SetDefaultControllerConfig(*dsi); + Host::RequestResetSettings(false, true); ShowToast(std::string(), FSUI_STR("Controller settings reset to default.")); }); } @@ -8824,6 +8846,7 @@ TRANSLATE_NOOP("FullscreenUI", "Apply Image Patches"); TRANSLATE_NOOP("FullscreenUI", "Are you sure you want to clear all mappings for this controller?\n\nYou cannot undo this action."); TRANSLATE_NOOP("FullscreenUI", "Are you sure you want to clear the current post-processing chain? All configuration will be lost."); TRANSLATE_NOOP("FullscreenUI", "Are you sure you want to restore the default controller configuration?\n\nAll bindings and configuration will be lost. You cannot undo this action."); +TRANSLATE_NOOP("FullscreenUI", "Are you sure you want to restore the default settings? Any preferences will be lost.\n\nYou cannot undo this action."); TRANSLATE_NOOP("FullscreenUI", "Aspect Ratio"); TRANSLATE_NOOP("FullscreenUI", "Attempts to detect one pixel high/wide lines that rely on non-upscaled rasterization behavior, filling in gaps introduced by upscaling."); TRANSLATE_NOOP("FullscreenUI", "Attempts to map the selected port to a chosen controller."); @@ -8916,6 +8939,7 @@ TRANSLATE_NOOP("FullscreenUI", "Culling Correction"); TRANSLATE_NOOP("FullscreenUI", "Current Game"); TRANSLATE_NOOP("FullscreenUI", "Custom"); TRANSLATE_NOOP("FullscreenUI", "Dark"); +TRANSLATE_NOOP("FullscreenUI", "Dark Ruby"); TRANSLATE_NOOP("FullscreenUI", "Deadzone"); TRANSLATE_NOOP("FullscreenUI", "Debugging Settings"); TRANSLATE_NOOP("FullscreenUI", "Default"); @@ -9256,8 +9280,10 @@ TRANSLATE_NOOP("FullscreenUI", "Reset Play Time"); TRANSLATE_NOOP("FullscreenUI", "Reset Settings"); TRANSLATE_NOOP("FullscreenUI", "Reset System"); TRANSLATE_NOOP("FullscreenUI", "Resets all configuration to defaults (including bindings)."); +TRANSLATE_NOOP("FullscreenUI", "Resets all settings to the defaults."); TRANSLATE_NOOP("FullscreenUI", "Resets memory card directory to default (user directory)."); TRANSLATE_NOOP("FullscreenUI", "Resolution change will be applied after restarting."); +TRANSLATE_NOOP("FullscreenUI", "Restore Defaults"); TRANSLATE_NOOP("FullscreenUI", "Restores the state of the system prior to the last state loaded."); TRANSLATE_NOOP("FullscreenUI", "Resume Game"); TRANSLATE_NOOP("FullscreenUI", "Resume Last Session"); @@ -9334,6 +9360,7 @@ TRANSLATE_NOOP("FullscreenUI", "Sets which sort of memory card image will be use TRANSLATE_NOOP("FullscreenUI", "Setting {} binding {}."); TRANSLATE_NOOP("FullscreenUI", "Settings"); TRANSLATE_NOOP("FullscreenUI", "Settings and Operations"); +TRANSLATE_NOOP("FullscreenUI", "Settings reset to default."); TRANSLATE_NOOP("FullscreenUI", "Shader {} added as stage {}."); TRANSLATE_NOOP("FullscreenUI", "Shared Card Name"); TRANSLATE_NOOP("FullscreenUI", "Show Achievement Trophy Icons"); diff --git a/src/core/fullscreen_ui.h b/src/core/fullscreen_ui.h index 7eda96e1c..8fd01833e 100644 --- a/src/core/fullscreen_ui.h +++ b/src/core/fullscreen_ui.h @@ -121,6 +121,9 @@ namespace Host { #ifndef __ANDROID__ +/// Requests settings reset. +void RequestResetSettings(bool system, bool controller); + /// Requests shut down and exit of the hosting application. This may not actually exit, /// if the user cancels the shutdown confirmation. void RequestExitApplication(bool allow_confirm); diff --git a/src/duckstation-mini/mini_host.cpp b/src/duckstation-mini/mini_host.cpp index ca610afdc..d5e448897 100644 --- a/src/duckstation-mini/mini_host.cpp +++ b/src/duckstation-mini/mini_host.cpp @@ -1251,6 +1251,32 @@ std::optional Host::GetTopLevelWindowInfo() return MiniHost::TranslateSDLWindowInfo(MiniHost::s_state.sdl_window, nullptr); } +void Host::RequestResetSettings(bool system, bool controller) +{ + using namespace MiniHost; + + auto lock = Host::GetSettingsLock(); + { + SettingsInterface& si = *s_state.base_settings_interface.get(); + + if (system) + { + System::SetDefaultSettings(si); + EmuFolders::SetDefaults(); + EmuFolders::Save(si); + } + + if (controller) + { + InputManager::SetDefaultSourceConfig(si); + Settings::SetDefaultControllerConfig(si); + Settings::SetDefaultHotkeyConfig(si); + } + } + + System::ApplySettings(false); +} + void Host::RequestExitApplication(bool allow_confirm) { Host::RunOnCPUThread([]() { diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index b4a13bc86..b258c0e48 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -646,15 +646,18 @@ void Host::CheckForSettingsChanges(const Settings& old_settings) void EmuThread::setDefaultSettings(bool system /* = true */, bool controller /* = true */) { - if (isCurrentThread()) + if (!isCurrentThread()) { - QMetaObject::invokeMethod(this, "setDefaultSettings", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, "setDefaultSettings", Qt::QueuedConnection, Q_ARG(bool, system), + Q_ARG(bool, controller)); return; } - auto lock = Host::GetSettingsLock(); - QtHost::SetDefaultSettings(*s_base_settings_interface, system, controller); - QtHost::QueueSettingsSave(); + { + auto lock = Host::GetSettingsLock(); + QtHost::SetDefaultSettings(*s_base_settings_interface, system, controller); + QtHost::QueueSettingsSave(); + } applySettings(false); @@ -2558,6 +2561,11 @@ void Host::RequestSystemShutdown(bool allow_confirm, bool save_state) Q_ARG(bool, true), Q_ARG(bool, save_state)); } +void Host::RequestResetSettings(bool system, bool controller) +{ + g_emu_thread->setDefaultSettings(system, controller); +} + void Host::RequestExitApplication(bool allow_confirm) { QMetaObject::invokeMethod(g_main_window, "requestExit", Qt::QueuedConnection, Q_ARG(bool, allow_confirm)); diff --git a/src/duckstation-qt/settingswindow.cpp b/src/duckstation-qt/settingswindow.cpp index 944af6235..c4f9fd81b 100644 --- a/src/duckstation-qt/settingswindow.cpp +++ b/src/duckstation-qt/settingswindow.cpp @@ -307,7 +307,8 @@ void SettingsWindow::onCategoryCurrentRowChanged(int row) void SettingsWindow::onRestoreDefaultsClicked() { if (QMessageBox::question(this, tr("Confirm Restore Defaults"), - tr("Are you sure you want to restore the default settings? Any preferences will be lost."), + tr("Are you sure you want to restore the default settings? Any preferences will be " + "lost.\n\nYou cannot undo this action."), QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes) { return; diff --git a/src/duckstation-regtest/regtest_host.cpp b/src/duckstation-regtest/regtest_host.cpp index 17f44dd19..68eb5da5b 100644 --- a/src/duckstation-regtest/regtest_host.cpp +++ b/src/duckstation-regtest/regtest_host.cpp @@ -345,6 +345,11 @@ void Host::RequestResizeHostDisplay(s32 width, s32 height) // } +void Host::RequestResetSettings(bool system, bool controller) +{ + // +} + void Host::RequestExitApplication(bool save_state_if_running) { //