From e20fd61f0b40104a0d124f4b5e7bad9059f43c68 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 28 Apr 2020 01:04:10 +1000 Subject: [PATCH] System: Add option to use per-game memory cards with game title as filename --- src/core/settings.cpp | 7 ++++--- src/core/system.cpp | 17 +++++++++++++++++ src/core/types.h | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 30a8c42cd..a77da5dd5 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -383,9 +383,10 @@ const char* Settings::GetControllerTypeDisplayName(ControllerType type) return s_controller_display_names[static_cast(type)]; } -static std::array s_memory_card_type_names = {{"None", "Shared", "PerGame"}}; -static std::array s_memory_card_type_display_names = { - {"No Memory Card", "Shared Between All Games", "Separate Card Per Game"}}; +static std::array s_memory_card_type_names = {{"None", "Shared", "PerGame", "PerGameTitle"}}; +static std::array s_memory_card_type_display_names = {{"No Memory Card", "Shared Between All Games", + "Separate Card Per Game (Game Code)", + "Seperate Card Per Game (Game Title)"}}; std::optional Settings::ParseMemoryCardTypeName(const char* str) { diff --git a/src/core/system.cpp b/src/core/system.cpp index 13faf430f..0c1b6f67d 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -823,6 +823,23 @@ void System::UpdateMemoryCards() } break; + case MemoryCardType::PerGameTitle: + { + if (m_running_game_title.empty()) + { + m_host_interface->AddFormattedOSDMessage(5.0f, + "Per-game memory card cannot be used for slot %u as the running " + "game has no title. Using shared card instead.", + i + 1u); + card = MemoryCard::Open(this, m_host_interface->GetSharedMemoryCardPath(i)); + } + else + { + card = MemoryCard::Open(this, m_host_interface->GetGameMemoryCardPath(m_running_game_title.c_str(), i)); + } + } + break; + case MemoryCardType::Shared: { if (settings.memory_card_paths[i].empty()) diff --git a/src/core/types.h b/src/core/types.h index b4e3a0753..daf9aba82 100644 --- a/src/core/types.h +++ b/src/core/types.h @@ -96,6 +96,7 @@ enum class MemoryCardType None, Shared, PerGame, + PerGameTitle, Count };