FullscreenUI: Add 'Pause on Menu' option

This commit is contained in:
Connor McLaughlin 2021-02-24 18:56:43 +10:00
parent b56b438f1f
commit f023c1bcde
4 changed files with 22 additions and 13 deletions

View File

@ -494,6 +494,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetBoolValue("Main", "StartPaused", false);
si.SetBoolValue("Main", "StartFullscreen", false);
si.SetBoolValue("Main", "PauseOnFocusLoss", false);
si.SetBoolValue("Main", "PauseOnMenu", true);
si.SetBoolValue("Main", "SaveStateOnExit", true);
si.SetBoolValue("Main", "ConfirmPowerOff", true);
si.SetBoolValue("Main", "LoadDevicesFromSaveStates", false);

View File

@ -117,6 +117,7 @@ void Settings::Load(SettingsInterface& si)
start_paused = si.GetBoolValue("Main", "StartPaused", false);
start_fullscreen = si.GetBoolValue("Main", "StartFullscreen", false);
pause_on_focus_loss = si.GetBoolValue("Main", "PauseOnFocusLoss", false);
pause_on_menu = si.GetBoolValue("Main", "PauseOnMenu", true);
save_state_on_exit = si.GetBoolValue("Main", "SaveStateOnExit", true);
confim_power_off = si.GetBoolValue("Main", "ConfirmPowerOff", true);
load_devices_from_save_states = si.GetBoolValue("Main", "LoadDevicesFromSaveStates", false);
@ -294,6 +295,7 @@ void Settings::Save(SettingsInterface& si) const
si.SetBoolValue("Main", "StartPaused", start_paused);
si.SetBoolValue("Main", "StartFullscreen", start_fullscreen);
si.SetBoolValue("Main", "PauseOnFocusLoss", pause_on_focus_loss);
si.SetBoolValue("Main", "PauseOnMenu", pause_on_menu);
si.SetBoolValue("Main", "SaveStateOnExit", save_state_on_exit);
si.SetBoolValue("Main", "ConfirmPowerOff", confim_power_off);
si.SetBoolValue("Main", "LoadDevicesFromSaveStates", load_devices_from_save_states);

View File

@ -88,6 +88,7 @@ struct Settings
bool start_paused = false;
bool start_fullscreen = false;
bool pause_on_focus_loss = false;
bool pause_on_menu = true;
bool save_state_on_exit = true;
bool confim_power_off = true;
bool load_devices_from_save_states = false;

View File

@ -242,7 +242,7 @@ void OpenQuickMenu()
return;
s_was_paused_on_quick_menu_open = System::IsPaused();
if (s_settings_copy.pause_on_focus_loss && !s_was_paused_on_quick_menu_open)
if (s_settings_copy.pause_on_menu && !s_was_paused_on_quick_menu_open)
s_host_interface->RunLater([]() { s_host_interface->PauseSystem(true); });
s_current_main_window = MainWindowType::QuickMenu;
@ -343,10 +343,10 @@ void ClearImGuiFocus()
void ReturnToMainWindow()
{
if (System::IsValid())
s_current_main_window = s_quick_menu_was_open ? MainWindowType::QuickMenu : MainWindowType::None;
else
s_current_main_window = MainWindowType::Landing;
if (s_quick_menu_was_open)
CloseQuickMenu();
s_current_main_window = System::IsValid() ? MainWindowType::None : MainWindowType::Landing;
}
bool LoadResources()
@ -592,7 +592,10 @@ static void DoCheatsMenu()
auto callback = [](s32 index, const std::string& title, bool checked) {
if (index < 0)
{
ReturnToMainWindow();
return;
}
CheatList* cl = System::GetCheatList();
if (!cl)
@ -633,6 +636,7 @@ static void DoChangeDiscFromFile()
ClearImGuiFocus();
CloseFileSelector();
ReturnToMainWindow();
};
OpenFileSelector(ICON_FA_COMPACT_DISC " Select Disc Image", false, std::move(callback), GetDiscImageFilters(),
@ -1100,6 +1104,9 @@ void DrawSettingsWindow()
"Pauses the emulator when you minimize the window or switch to another "
"application, and unpauses when you switch back.",
&s_settings_copy.pause_on_focus_loss);
settings_changed |= ToggleButton(
"Pause On Menu", "Pauses the emulator when you open the quick menu, and unpauses when you close it.",
&s_settings_copy.pause_on_menu);
settings_changed |=
ToggleButton("Confirm Power Off",
"Determines whether a prompt will be displayed to confirm shutting down the emulator/game "
@ -1888,7 +1895,7 @@ void DrawSettingsWindow()
&s_settings_copy.audio_output_volume, 0, 100, 1, "%d%%");
settings_changed |= RangeButton("Fast Forward Volume",
"Controls the volume of the audio played on the host when fast forwarding.",
&s_settings_copy.audio_output_volume, 0, 100, 1, "%d%%");
&s_settings_copy.audio_fast_forward_volume, 0, 100, 1, "%d%%");
settings_changed |= ToggleButton("Mute All Sound", "Prevents the emulator from producing any audible sound.",
&s_settings_copy.audio_output_muted);
settings_changed |= ToggleButton("Mute CD Audio",
@ -2082,19 +2089,19 @@ void DrawQuickMenu(MainWindowType type)
if (ActiveButton(ICON_FA_UNDO " Load State", false))
{
s_current_main_window = MainWindowType::None;
OpenSaveStateSelector(true);
CloseQuickMenu();
}
if (ActiveButton(ICON_FA_SAVE " Save State", false))
{
s_current_main_window = MainWindowType::None;
OpenSaveStateSelector(false);
CloseQuickMenu();
}
if (ActiveButton(ICON_FA_FROWN_OPEN " Cheat List", false))
{
CloseQuickMenu();
s_current_main_window = MainWindowType::None;
DoCheatsMenu();
}
@ -2106,15 +2113,12 @@ void DrawQuickMenu(MainWindowType type)
if (ActiveButton(ICON_FA_COMPACT_DISC " Change Disc", false))
{
CloseQuickMenu();
s_current_main_window = MainWindowType::None;
DoChangeDisc();
}
if (ActiveButton(ICON_FA_SLIDERS_H " Settings", false))
{
CloseQuickMenu();
s_current_main_window = MainWindowType::Settings;
}
if (ActiveButton(ICON_FA_SYNC " Reset System", false))
{
@ -2290,6 +2294,7 @@ void CloseSaveStateSelector()
{
s_save_state_selector_slots.clear();
s_save_state_selector_open = false;
ReturnToMainWindow();
}
void DrawSaveStateSelector(bool is_loading, bool fullscreen)