make it significantly harder to choose an invalid memory card file in the main dolphin config

should fix most errors of "Can not use memory card in slot A"
also fix display of a (rarely seen) panicalertT when the same file is chosen for both memorycards
recent examples ... http://forums.dolphin-emulator.com/showthread.php?tid=18408 http://forums.dolphin-emulator.com/showthread.php?tid=18354

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7694 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99
2011-08-07 07:17:49 +00:00
parent 2a829fe36c
commit 5f9591cf9d
4 changed files with 105 additions and 88 deletions

View File

@ -37,7 +37,7 @@
#include "Frame.h"
#include "HotkeyDlg.h"
#include "Main.h"
#include "MemoryCards\GCMemcard.h"
#include "VideoBackendBase.h"
#define TEXT_BOX(page, text) new wxStaticText(page, wxID_ANY, text, wxDefaultPosition, wxDefaultSize)
@ -1008,6 +1008,17 @@ void CConfigMain::ChooseMemcardPath(std::string& strMemcard, bool isSlotA)
if (!filename.empty())
{
if (File::Exists(filename))
{
GCMemcard memorycard(filename.c_str());
if (!memorycard.IsValid())
{
PanicAlertT("Cannot use that file as a memory card.\n%s\n" \
"is not a valid gamecube memory card file", filename.c_str());
return;
}
}
// also check that the path isn't used for the other memcard...
if (filename.compare(isSlotA ? SConfig::GetInstance().m_strMemoryCardB
: SConfig::GetInstance().m_strMemoryCardA) != 0)
@ -1025,7 +1036,7 @@ void CConfigMain::ChooseMemcardPath(std::string& strMemcard, bool isSlotA)
}
else
{
PanicAlertT("Cannot use that file as a memory card.\n"
PanicAlertT("Cannot use that file as a memory card.\n" \
"Are you trying to use the same file in both slots?");
}
}