System: Add file title memory card type

This commit is contained in:
Connor McLaughlin
2021-05-21 13:18:32 +10:00
parent 6aa78b11fe
commit ff0bd7abc4
4 changed files with 35 additions and 3 deletions

View File

@ -1821,6 +1821,28 @@ void UpdateMemoryCards()
}
break;
case MemoryCardType::PerGameFileTitle:
{
const std::string display_name(FileSystem::GetDisplayNameFromPath(s_running_game_path));
const std::string_view file_title(FileSystem::GetFileTitleFromPath(display_name));
if (file_title.empty())
{
g_host_interface->AddFormattedOSDMessage(
5.0f,
g_host_interface->TranslateString("System",
"Per-game memory card cannot be used for slot %u as the running "
"game has no path. Using shared card instead."),
i + 1u);
card = MemoryCard::Open(g_host_interface->GetSharedMemoryCardPath(i));
}
else
{
card = MemoryCard::Open(
g_host_interface->GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName(file_title).c_str(), i));
}
}
break;
case MemoryCardType::Shared:
{
if (g_settings.memory_card_paths[i].empty())