From 724d5e7cf91b39f65d48d54aa09d9eb2e732cd83 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 30 Aug 2023 18:26:12 +1000 Subject: [PATCH] System: Remove memory card warnings on config change --- src/core/system.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/core/system.cpp b/src/core/system.cpp index 6a01d9b2a..997d4da1e 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -2837,14 +2837,16 @@ std::unique_ptr System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp if (is_running_psf) return nullptr; + std::string message_key = fmt::format("MemoryCard{}SharedWarning", slot); + switch (type) { case MemoryCardType::PerGame: { if (s_running_game_serial.empty()) { - Host::AddFormattedOSDMessage( - 5.0f, + Host::AddKeyedFormattedOSDMessage( + std::move(message_key), 5.0f, Host::TranslateString("System", "Per-game memory card cannot be used for slot %u as the running " "game has no code. Using shared card instead."), slot + 1u); @@ -2852,6 +2854,7 @@ std::unique_ptr System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp } else { + Host::RemoveKeyedOSDMessage(std::move(message_key)); return MemoryCard::Open(g_settings.GetGameMemoryCardPath(s_running_game_serial.c_str(), slot)); } } @@ -2860,8 +2863,8 @@ std::unique_ptr System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp { if (s_running_game_title.empty()) { - Host::AddFormattedOSDMessage( - 5.0f, + Host::AddKeyedFormattedOSDMessage( + std::move(message_key), 5.0f, Host::TranslateString("System", "Per-game memory card cannot be used for slot %u as the running " "game has no title. Using shared card instead."), slot + 1u); @@ -2869,6 +2872,7 @@ std::unique_ptr System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp } else { + Host::RemoveKeyedOSDMessage(std::move(message_key)); return MemoryCard::Open(g_settings.GetGameMemoryCardPath( MemoryCard::SanitizeGameTitleForFileName(s_running_game_title).c_str(), slot)); } @@ -2880,8 +2884,8 @@ std::unique_ptr System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp const std::string_view file_title(Path::GetFileTitle(display_name)); if (file_title.empty()) { - Host::AddFormattedOSDMessage( - 5.0f, + Host::AddKeyedFormattedOSDMessage( + std::move(message_key), 5.0f, Host::TranslateString("System", "Per-game memory card cannot be used for slot %u as the running " "game has no path. Using shared card instead."), slot + 1u); @@ -2889,6 +2893,7 @@ std::unique_ptr System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp } else { + Host::RemoveKeyedOSDMessage(std::move(message_key)); return MemoryCard::Open( g_settings.GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName(file_title).c_str(), slot)); } @@ -2896,15 +2901,22 @@ std::unique_ptr System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp case MemoryCardType::Shared: { + Host::RemoveKeyedOSDMessage(std::move(message_key)); return MemoryCard::Open(g_settings.GetSharedMemoryCardPath(slot)); } case MemoryCardType::NonPersistent: + { + Host::RemoveKeyedOSDMessage(std::move(message_key)); return MemoryCard::Create(); + } case MemoryCardType::None: default: + { + Host::RemoveKeyedOSDMessage(std::move(message_key)); return nullptr; + } } }