System: Avoid load state message on HC disable confirm

It wasn't actually loading, so no issue, but could be confusing to a
user.
This commit is contained in:
Stenzek
2025-11-27 17:21:22 +10:00
parent 93f3be46f2
commit 08f357f0d7
3 changed files with 22 additions and 17 deletions

View File

@@ -1883,7 +1883,8 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
const bool start_paused = (ShouldStartPaused() || parameters.override_start_paused.value_or(false));
// try to load the state, if it fails, bail out
if (!parameters.save_state.empty() && !LoadState(parameters.save_state.c_str(), error, false, start_paused))
if (!parameters.save_state.empty() &&
!LoadState(parameters.save_state.c_str(), error, false, start_paused).value_or(false))
{
Error::AddPrefixFmt(error, "Failed to load save state file '{}' for booting:\n",
Path::GetFileName(parameters.save_state));
@@ -2910,7 +2911,7 @@ std::string System::GetMediaPathFromSaveState(const char* path)
return std::move(buffer.media_path);
}
bool System::LoadState(const char* path, Error* error, bool save_undo_state, bool force_update_display)
std::optional<bool> System::LoadState(const char* path, Error* error, bool save_undo_state, bool force_update_display)
{
if (!IsValid() || IsReplayingGPUDump())
{
@@ -2926,7 +2927,7 @@ bool System::LoadState(const char* path, Error* error, bool save_undo_state, boo
if (approved)
LoadState(path.c_str(), nullptr, save_undo_state, force_update_display);
});
return true;
return std::nullopt;
}
FlushSaveStates();
@@ -3310,18 +3311,23 @@ void System::LoadStateFromSlot(bool global, s32 slot)
}
Error error;
if (System::LoadState(path.c_str(), &error, true, false))
const std::optional<bool> result = System::LoadState(path.c_str(), &error, true, false);
if (result.has_value())
{
Host::AddIconOSDMessage(OSDMessageType::Quick, GetSaveStateOSDKey(global, slot), ICON_EMOJI_FILE_FOLDER_OPEN,
GetSaveStateOSDTitle(global, slot),
fmt::format(TRANSLATE_FS("System", "Loaded save state from {}."), Path::GetFileName(path)));
}
else
{
Host::AddIconOSDMessage(OSDMessageType::Error, GetSaveStateOSDKey(global, slot), ICON_EMOJI_WARNING,
GetSaveStateOSDTitle(global, slot),
fmt::format(TRANSLATE_FS("System", "Failed to load state from {0}:\n{1}"),
Path::GetFileName(path), error.GetDescription()));
if (result.value())
{
Host::AddIconOSDMessage(
OSDMessageType::Quick, GetSaveStateOSDKey(global, slot), ICON_EMOJI_FILE_FOLDER_OPEN,
GetSaveStateOSDTitle(global, slot),
fmt::format(TRANSLATE_FS("System", "Loaded save state from {}."), Path::GetFileName(path)));
}
else
{
Host::AddIconOSDMessage(OSDMessageType::Error, GetSaveStateOSDKey(global, slot), ICON_EMOJI_WARNING,
GetSaveStateOSDTitle(global, slot),
fmt::format(TRANSLATE_FS("System", "Failed to load state from {0}:\n{1}"),
Path::GetFileName(path), error.GetDescription()));
}
}
}

View File

@@ -273,7 +273,7 @@ size_t GetMaxSaveStateSize(bool enable_8mb_ram);
size_t GetMaxMemorySaveStateSize(bool enable_8mb_ram, bool pgxp);
/// Loads state from the specified path.
bool LoadState(const char* path, Error* error, bool save_undo_state, bool force_update_display);
std::optional<bool> LoadState(const char* path, Error* error, bool save_undo_state, bool force_update_display);
bool SaveState(std::string path, Error* error, bool backup_existing_save, bool ignore_memcard_busy,
std::function<void(bool, const Error& error)> completion_callback = {});
bool SaveResumeState(Error* error);

View File

@@ -860,7 +860,7 @@ void EmuThread::bootOrLoadState(std::string path)
if (System::IsValid())
{
Error error;
if (!System::LoadState(path.c_str(), &error, true, false))
if (!System::LoadState(path.c_str(), &error, true, false).value_or(true))
{
emit errorReported(tr("Error"),
tr("Failed to load state: %1").arg(QString::fromStdString(error.GetDescription())));
@@ -1503,7 +1503,6 @@ void EmuThread::loadState(bool global, qint32 slot)
return;
}
// shouldn't even get here if we don't have a running game
if (System::IsValid())
{
System::LoadStateFromSlot(global, slot);