Merge pull request #8300 from AdmiralCurtiss/gcmemcard-construction

GCMemcard: Rework construction logic.
This commit is contained in:
Anthony
2019-08-21 08:56:31 -07:00
committed by GitHub
8 changed files with 509 additions and 247 deletions

View File

@ -28,6 +28,7 @@
#include "Core/HW/GCMemcard/GCMemcard.h"
#include "DolphinQt/Config/Mapping/MappingWindow.h"
#include "DolphinQt/GCMemcardManager.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
enum
@ -212,15 +213,15 @@ void GameCubePane::OnConfigPressed(int slot)
{
if (File::Exists(filename.toStdString()))
{
GCMemcard mc(filename.toStdString());
auto [error_code, mc] = GCMemcard::Open(filename.toStdString());
if (!mc.IsValid())
if (error_code.HasCriticalErrors() || !mc || !mc->IsValid())
{
ModalMessageBox::critical(this, tr("Error"),
tr("Cannot use that file as a memory card.\n%1\n"
"is not a valid GameCube memory card file")
.arg(filename));
ModalMessageBox::critical(
this, tr("Error"),
tr("The file\n%1\nis either corrupted or not a GameCube memory card file.\n%2")
.arg(filename)
.arg(GCMemcardManager::GetErrorMessagesForErrorCode(error_code)));
return;
}
}