mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-07 12:05:52 +00:00
FullscreenUI: Add settings reset option to settings
This commit is contained in:
parent
0a470067f5
commit
c82c007a75
@ -322,6 +322,7 @@ static float GetEffectiveFloatSetting(SettingsInterface* bsi, const char* sectio
|
|||||||
float default_value);
|
float default_value);
|
||||||
static TinyString GetEffectiveTinyStringSetting(SettingsInterface* bsi, const char* section, const char* key,
|
static TinyString GetEffectiveTinyStringSetting(SettingsInterface* bsi, const char* section, const char* key,
|
||||||
const char* default_value);
|
const char* default_value);
|
||||||
|
static void BeginResetSettings();
|
||||||
static void DoCopyGameSettings();
|
static void DoCopyGameSettings();
|
||||||
static void DoClearGameSettings();
|
static void DoClearGameSettings();
|
||||||
static void CopyGlobalControllerSettingsToGame();
|
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);
|
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()
|
void FullscreenUI::DoCopyGameSettings()
|
||||||
{
|
{
|
||||||
if (!s_state.game_settings_interface)
|
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",
|
FSUI_CSTR("Shows enhancement settings in the bottom-right corner of the screen."), "Display",
|
||||||
"ShowEnhancements", false);
|
"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();
|
EndMenuButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4413,9 +4437,7 @@ void FullscreenUI::BeginResetControllerSettings()
|
|||||||
if (!result)
|
if (!result)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SettingsInterface* dsi = GetEditingSettingsInterface();
|
Host::RequestResetSettings(false, true);
|
||||||
|
|
||||||
Settings::SetDefaultControllerConfig(*dsi);
|
|
||||||
ShowToast(std::string(), FSUI_STR("Controller settings reset to default."));
|
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 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 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 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", "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 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.");
|
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", "Current Game");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Custom");
|
TRANSLATE_NOOP("FullscreenUI", "Custom");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Dark");
|
TRANSLATE_NOOP("FullscreenUI", "Dark");
|
||||||
|
TRANSLATE_NOOP("FullscreenUI", "Dark Ruby");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Deadzone");
|
TRANSLATE_NOOP("FullscreenUI", "Deadzone");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Debugging Settings");
|
TRANSLATE_NOOP("FullscreenUI", "Debugging Settings");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Default");
|
TRANSLATE_NOOP("FullscreenUI", "Default");
|
||||||
@ -9256,8 +9280,10 @@ TRANSLATE_NOOP("FullscreenUI", "Reset Play Time");
|
|||||||
TRANSLATE_NOOP("FullscreenUI", "Reset Settings");
|
TRANSLATE_NOOP("FullscreenUI", "Reset Settings");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Reset System");
|
TRANSLATE_NOOP("FullscreenUI", "Reset System");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Resets all configuration to defaults (including bindings).");
|
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", "Resets memory card directory to default (user directory).");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Resolution change will be applied after restarting.");
|
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", "Restores the state of the system prior to the last state loaded.");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Resume Game");
|
TRANSLATE_NOOP("FullscreenUI", "Resume Game");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Resume Last Session");
|
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", "Setting {} binding {}.");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Settings");
|
TRANSLATE_NOOP("FullscreenUI", "Settings");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Settings and Operations");
|
TRANSLATE_NOOP("FullscreenUI", "Settings and Operations");
|
||||||
|
TRANSLATE_NOOP("FullscreenUI", "Settings reset to default.");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Shader {} added as stage {}.");
|
TRANSLATE_NOOP("FullscreenUI", "Shader {} added as stage {}.");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Shared Card Name");
|
TRANSLATE_NOOP("FullscreenUI", "Shared Card Name");
|
||||||
TRANSLATE_NOOP("FullscreenUI", "Show Achievement Trophy Icons");
|
TRANSLATE_NOOP("FullscreenUI", "Show Achievement Trophy Icons");
|
||||||
|
@ -121,6 +121,9 @@ namespace Host {
|
|||||||
|
|
||||||
#ifndef __ANDROID__
|
#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,
|
/// Requests shut down and exit of the hosting application. This may not actually exit,
|
||||||
/// if the user cancels the shutdown confirmation.
|
/// if the user cancels the shutdown confirmation.
|
||||||
void RequestExitApplication(bool allow_confirm);
|
void RequestExitApplication(bool allow_confirm);
|
||||||
|
@ -1251,6 +1251,32 @@ std::optional<WindowInfo> Host::GetTopLevelWindowInfo()
|
|||||||
return MiniHost::TranslateSDLWindowInfo(MiniHost::s_state.sdl_window, nullptr);
|
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)
|
void Host::RequestExitApplication(bool allow_confirm)
|
||||||
{
|
{
|
||||||
Host::RunOnCPUThread([]() {
|
Host::RunOnCPUThread([]() {
|
||||||
|
@ -646,15 +646,18 @@ void Host::CheckForSettingsChanges(const Settings& old_settings)
|
|||||||
|
|
||||||
void EmuThread::setDefaultSettings(bool system /* = true */, bool controller /* = true */)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto lock = Host::GetSettingsLock();
|
{
|
||||||
QtHost::SetDefaultSettings(*s_base_settings_interface, system, controller);
|
auto lock = Host::GetSettingsLock();
|
||||||
QtHost::QueueSettingsSave();
|
QtHost::SetDefaultSettings(*s_base_settings_interface, system, controller);
|
||||||
|
QtHost::QueueSettingsSave();
|
||||||
|
}
|
||||||
|
|
||||||
applySettings(false);
|
applySettings(false);
|
||||||
|
|
||||||
@ -2558,6 +2561,11 @@ void Host::RequestSystemShutdown(bool allow_confirm, bool save_state)
|
|||||||
Q_ARG(bool, true), Q_ARG(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)
|
void Host::RequestExitApplication(bool allow_confirm)
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(g_main_window, "requestExit", Qt::QueuedConnection, Q_ARG(bool, allow_confirm));
|
QMetaObject::invokeMethod(g_main_window, "requestExit", Qt::QueuedConnection, Q_ARG(bool, allow_confirm));
|
||||||
|
@ -307,7 +307,8 @@ void SettingsWindow::onCategoryCurrentRowChanged(int row)
|
|||||||
void SettingsWindow::onRestoreDefaultsClicked()
|
void SettingsWindow::onRestoreDefaultsClicked()
|
||||||
{
|
{
|
||||||
if (QMessageBox::question(this, tr("Confirm Restore Defaults"),
|
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)
|
QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -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)
|
void Host::RequestExitApplication(bool save_state_if_running)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user