mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-20 15:25:38 +00:00
System: Prevent save states while memory cards are being saved
This commit is contained in:
parent
8e5781266a
commit
328a3cd7af
|
@ -110,8 +110,8 @@ static void HotkeySaveStateSlot(bool global, s32 slot)
|
||||||
Error error;
|
Error error;
|
||||||
if (!System::SaveState(path.c_str(), &error, g_settings.create_save_state_backups))
|
if (!System::SaveState(path.c_str(), &error, g_settings.create_save_state_backups))
|
||||||
{
|
{
|
||||||
Host::AddKeyedOSDMessage(
|
Host::AddIconOSDMessage(
|
||||||
"SaveState",
|
"SaveState", ICON_FA_EXCLAMATION_TRIANGLE,
|
||||||
fmt::format(TRANSLATE_FS("OSDMessage", "Failed to save state to slot {0}:\n{1}"), slot, error.GetDescription()),
|
fmt::format(TRANSLATE_FS("OSDMessage", "Failed to save state to slot {0}:\n{1}"), slot, error.GetDescription()),
|
||||||
Host::OSD_ERROR_DURATION);
|
Host::OSD_ERROR_DURATION);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1143,7 +1143,7 @@ void SaveStateSelectorUI::SaveCurrentSlot()
|
||||||
Error error;
|
Error error;
|
||||||
if (!System::SaveState(path.c_str(), &error, g_settings.create_save_state_backups))
|
if (!System::SaveState(path.c_str(), &error, g_settings.create_save_state_backups))
|
||||||
{
|
{
|
||||||
Host::AddKeyedOSDMessage("SaveState",
|
Host::AddIconOSDMessage("SaveState", ICON_FA_EXCLAMATION_TRIANGLE,
|
||||||
fmt::format(TRANSLATE_FS("OSDMessage", "Failed to save state to slot {0}:\n{1}"),
|
fmt::format(TRANSLATE_FS("OSDMessage", "Failed to save state to slot {0}:\n{1}"),
|
||||||
GetCurrentSlot(), error.GetDescription()),
|
GetCurrentSlot(), error.GetDescription()),
|
||||||
Host::OSD_ERROR_DURATION);
|
Host::OSD_ERROR_DURATION);
|
||||||
|
|
|
@ -1345,6 +1345,12 @@ bool System::LoadState(const char* filename, Error* error)
|
||||||
|
|
||||||
bool System::SaveState(const char* filename, Error* error, bool backup_existing_save)
|
bool System::SaveState(const char* filename, Error* error, bool backup_existing_save)
|
||||||
{
|
{
|
||||||
|
if (IsSavingMemoryCards())
|
||||||
|
{
|
||||||
|
Error::SetStringView(error, TRANSLATE_SV("System", "Cannot save state while memory card is being saved."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (backup_existing_save && FileSystem::FileExists(filename))
|
if (backup_existing_save && FileSystem::FileExists(filename))
|
||||||
{
|
{
|
||||||
Error backup_error;
|
Error backup_error;
|
||||||
|
@ -1365,7 +1371,7 @@ bool System::SaveState(const char* filename, Error* error, bool backup_existing_
|
||||||
error);
|
error);
|
||||||
if (!stream)
|
if (!stream)
|
||||||
{
|
{
|
||||||
Error::AddPrefixFmt(error, "Failed to save state to '{}': ", Path::GetFileName(filename));
|
Error::AddPrefixFmt(error, "Cannot open '{}': ", Path::GetFileName(filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue