System: Add option to disable loading memory cards from save states

This commit is contained in:
Connor McLaughlin
2020-05-27 02:06:56 +10:00
parent b17a5832e5
commit 81a7b147fc
7 changed files with 45 additions and 11 deletions

View File

@ -1022,6 +1022,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetStringValue("Controller1", "Type", Settings::GetControllerTypeName(ControllerType::DigitalController));
si.SetStringValue("Controller2", "Type", Settings::GetControllerTypeName(ControllerType::None));
si.SetBoolValue("MemoryCards", "LoadFromSaveStates", false);
si.SetStringValue("MemoryCards", "Card1Type", Settings::GetMemoryCardTypeName(MemoryCardType::PerGameTitle));
si.SetStringValue("MemoryCards", "Card1Path", "memcards/shared_card_1.mcd");
si.SetStringValue("MemoryCards", "Card2Type", "None");

View File

@ -62,16 +62,31 @@ bool Pad::DoState(StateWrapper& sw)
bool card_present = static_cast<bool>(m_memory_cards[i]);
sw.Do(&card_present);
if (sw.IsReading() && card_present && !m_system->GetSettings().load_memory_cards_from_save_states)
{
Log_WarningPrintf("Skipping loading memory card %u from save state.", i + 1u);
MemoryCard dummy_card(m_system);
if (!sw.DoMarker("MemoryCard") || !dummy_card.DoState(sw))
return false;
// we do need to reset the existing card though, in case it was in the middle of a write
if (m_memory_cards[i])
m_memory_cards[i]->Reset();
continue;
}
if (card_present && !m_memory_cards[i])
{
m_system->GetHostInterface()->AddFormattedOSDMessage(
2.0f, "Memory card %c present in save state but not in system. Creating temporary card.", i + 1);
2.0f, "Memory card %u present in save state but not in system. Creating temporary card.", i + 1u);
m_memory_cards[i] = MemoryCard::Create(m_system);
}
else if (!card_present && m_memory_cards[i])
{
m_system->GetHostInterface()->AddFormattedOSDMessage(
2.0f, "Memory card %u present in system but not in save state. Removing card.", i + 1);
2.0f, "Memory card %u present in system but not in save state. Removing card.", i + 1u);
m_memory_cards[i].reset();
}

View File

@ -74,6 +74,7 @@ void Settings::Load(SettingsInterface& si)
// NOTE: The default value here if not present in the config is shared, but SetDefaultSettings() makes per-game.
// This is so we don't break older builds which had the shared card by default.
load_memory_cards_from_save_states = si.GetBoolValue("MemoryCards", "LoadFromSaveStates", false);
memory_card_types[0] =
ParseMemoryCardTypeName(
si.GetStringValue("MemoryCards", "Card1Type", GetMemoryCardTypeName(MemoryCardType::Shared)).c_str())
@ -166,6 +167,7 @@ void Settings::Save(SettingsInterface& si) const
else
si.DeleteValue("Controller2", "Type");
si.SetBoolValue("MemoryCards", "LoadFromSaveStates", load_memory_cards_from_save_states);
si.SetStringValue("MemoryCards", "Card1Type", GetMemoryCardTypeName(memory_card_types[0]));
si.SetStringValue("MemoryCards", "Card1Path", memory_card_paths[0].c_str());
si.SetStringValue("MemoryCards", "Card2Type", GetMemoryCardTypeName(memory_card_types[1]));

View File

@ -45,6 +45,7 @@ struct Settings
bool start_fullscreen = false;
bool save_state_on_exit = true;
bool confim_power_off = true;
bool load_memory_cards_from_save_states = false;
GPURenderer gpu_renderer = GPURenderer::Software;
u32 gpu_resolution_scale = 1;