|
|
|
@@ -248,7 +248,7 @@ void GCMemcardManager::UpdateSlotTable(int slot)
|
|
|
|
|
|
|
|
|
|
m_slot_stat_label[slot]->setText(tr("%1 Free Blocks; %2 Free Dir Entries")
|
|
|
|
|
.arg(memcard->GetFreeBlocks())
|
|
|
|
|
.arg(DIRLEN - memcard->GetNumFiles()));
|
|
|
|
|
.arg(Memcard::DIRLEN - memcard->GetNumFiles()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GCMemcardManager::UpdateActions()
|
|
|
|
@@ -268,12 +268,12 @@ void GCMemcardManager::UpdateActions()
|
|
|
|
|
|
|
|
|
|
void GCMemcardManager::SetSlotFile(int slot, QString path)
|
|
|
|
|
{
|
|
|
|
|
auto [error_code, memcard] = GCMemcard::Open(path.toStdString());
|
|
|
|
|
auto [error_code, memcard] = Memcard::GCMemcard::Open(path.toStdString());
|
|
|
|
|
|
|
|
|
|
if (!error_code.HasCriticalErrors() && memcard && memcard->IsValid())
|
|
|
|
|
{
|
|
|
|
|
m_slot_file_edit[slot]->setText(path);
|
|
|
|
|
m_slot_memcard[slot] = std::make_unique<GCMemcard>(std::move(*memcard));
|
|
|
|
|
m_slot_memcard[slot] = std::make_unique<Memcard::GCMemcard>(std::move(*memcard));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@@ -336,7 +336,7 @@ void GCMemcardManager::ExportFiles(bool prompt)
|
|
|
|
|
|
|
|
|
|
// TODO: This is obviously intended to check for success instead.
|
|
|
|
|
const auto exportRetval = memcard->ExportGci(file_index, path.toStdString(), "");
|
|
|
|
|
if (exportRetval == GCMemcardExportFileRetVal::UNUSED)
|
|
|
|
|
if (exportRetval == Memcard::GCMemcardExportFileRetVal::UNUSED)
|
|
|
|
|
{
|
|
|
|
|
File::Delete(path.toStdString());
|
|
|
|
|
}
|
|
|
|
@@ -366,7 +366,7 @@ void GCMemcardManager::ImportFile()
|
|
|
|
|
|
|
|
|
|
const auto result = m_slot_memcard[m_active_slot]->ImportGci(path.toStdString());
|
|
|
|
|
|
|
|
|
|
if (result != GCMemcardImportFileRetVal::SUCCESS)
|
|
|
|
|
if (result != Memcard::GCMemcardImportFileRetVal::SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ModalMessageBox::critical(this, tr("Import failed"), tr("Failed to import \"%1\".").arg(path));
|
|
|
|
|
return;
|
|
|
|
@@ -392,7 +392,7 @@ void GCMemcardManager::CopyFiles()
|
|
|
|
|
|
|
|
|
|
const auto result = m_slot_memcard[!m_active_slot]->CopyFrom(*memcard, file_index);
|
|
|
|
|
|
|
|
|
|
if (result != GCMemcardImportFileRetVal::SUCCESS)
|
|
|
|
|
if (result != Memcard::GCMemcardImportFileRetVal::SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ModalMessageBox::warning(this, tr("Copy failed"), tr("Failed to copy file"));
|
|
|
|
|
}
|
|
|
|
@@ -436,7 +436,7 @@ void GCMemcardManager::DeleteFiles()
|
|
|
|
|
|
|
|
|
|
for (int file_index : file_indices)
|
|
|
|
|
{
|
|
|
|
|
if (memcard->RemoveFile(file_index) != GCMemcardRemoveFileRetVal::SUCCESS)
|
|
|
|
|
if (memcard->RemoveFile(file_index) != Memcard::GCMemcardRemoveFileRetVal::SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
ModalMessageBox::warning(this, tr("Remove failed"), tr("Failed to remove file"));
|
|
|
|
|
}
|
|
|
|
@@ -522,8 +522,8 @@ QPixmap GCMemcardManager::GetBannerFromSaveFile(int file_index, int slot)
|
|
|
|
|
QImage image;
|
|
|
|
|
if (pxdata)
|
|
|
|
|
{
|
|
|
|
|
image = QImage(reinterpret_cast<u8*>(pxdata->data()), MEMORY_CARD_BANNER_WIDTH,
|
|
|
|
|
MEMORY_CARD_BANNER_HEIGHT, QImage::Format_ARGB32);
|
|
|
|
|
image = QImage(reinterpret_cast<u8*>(pxdata->data()), Memcard::MEMORY_CARD_BANNER_WIDTH,
|
|
|
|
|
Memcard::MEMORY_CARD_BANNER_HEIGHT, QImage::Format_ARGB32);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QPixmap::fromImage(image);
|
|
|
|
@@ -545,7 +545,8 @@ GCMemcardManager::IconAnimationData GCMemcardManager::GetIconFromSaveFile(int fi
|
|
|
|
|
for (size_t f = 0; f < decoded_data->size(); ++f)
|
|
|
|
|
{
|
|
|
|
|
QImage img(reinterpret_cast<const u8*>((*decoded_data)[f].image_data.data()),
|
|
|
|
|
MEMORY_CARD_ICON_WIDTH, MEMORY_CARD_ICON_HEIGHT, QImage::Format_ARGB32);
|
|
|
|
|
Memcard::MEMORY_CARD_ICON_WIDTH, Memcard::MEMORY_CARD_ICON_HEIGHT,
|
|
|
|
|
QImage::Format_ARGB32);
|
|
|
|
|
frame_data.m_frames.push_back(QPixmap::fromImage(img));
|
|
|
|
|
for (int i = 0; i < (*decoded_data)[f].delay; ++i)
|
|
|
|
|
{
|
|
|
|
@@ -579,32 +580,32 @@ GCMemcardManager::IconAnimationData GCMemcardManager::GetIconFromSaveFile(int fi
|
|
|
|
|
return frame_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString GCMemcardManager::GetErrorMessagesForErrorCode(const GCMemcardErrorCode& code)
|
|
|
|
|
QString GCMemcardManager::GetErrorMessagesForErrorCode(const Memcard::GCMemcardErrorCode& code)
|
|
|
|
|
{
|
|
|
|
|
QStringList sl;
|
|
|
|
|
|
|
|
|
|
if (code.Test(GCMemcardValidityIssues::FAILED_TO_OPEN))
|
|
|
|
|
if (code.Test(Memcard::GCMemcardValidityIssues::FAILED_TO_OPEN))
|
|
|
|
|
sl.push_back(tr("Couldn't open file."));
|
|
|
|
|
|
|
|
|
|
if (code.Test(GCMemcardValidityIssues::IO_ERROR))
|
|
|
|
|
if (code.Test(Memcard::GCMemcardValidityIssues::IO_ERROR))
|
|
|
|
|
sl.push_back(tr("Couldn't read file."));
|
|
|
|
|
|
|
|
|
|
if (code.Test(GCMemcardValidityIssues::INVALID_CARD_SIZE))
|
|
|
|
|
if (code.Test(Memcard::GCMemcardValidityIssues::INVALID_CARD_SIZE))
|
|
|
|
|
sl.push_back(tr("Filesize does not match any known GameCube Memory Card size."));
|
|
|
|
|
|
|
|
|
|
if (code.Test(GCMemcardValidityIssues::MISMATCHED_CARD_SIZE))
|
|
|
|
|
if (code.Test(Memcard::GCMemcardValidityIssues::MISMATCHED_CARD_SIZE))
|
|
|
|
|
sl.push_back(tr("Filesize in header mismatches actual card size."));
|
|
|
|
|
|
|
|
|
|
if (code.Test(GCMemcardValidityIssues::INVALID_CHECKSUM))
|
|
|
|
|
if (code.Test(Memcard::GCMemcardValidityIssues::INVALID_CHECKSUM))
|
|
|
|
|
sl.push_back(tr("Invalid checksums."));
|
|
|
|
|
|
|
|
|
|
if (code.Test(GCMemcardValidityIssues::FREE_BLOCK_MISMATCH))
|
|
|
|
|
if (code.Test(Memcard::GCMemcardValidityIssues::FREE_BLOCK_MISMATCH))
|
|
|
|
|
sl.push_back(tr("Mismatch between free block count in header and actually unused blocks."));
|
|
|
|
|
|
|
|
|
|
if (code.Test(GCMemcardValidityIssues::DIR_BAT_INCONSISTENT))
|
|
|
|
|
if (code.Test(Memcard::GCMemcardValidityIssues::DIR_BAT_INCONSISTENT))
|
|
|
|
|
sl.push_back(tr("Mismatch between internal data structures."));
|
|
|
|
|
|
|
|
|
|
if (code.Test(GCMemcardValidityIssues::DATA_IN_UNUSED_AREA))
|
|
|
|
|
if (code.Test(Memcard::GCMemcardValidityIssues::DATA_IN_UNUSED_AREA))
|
|
|
|
|
sl.push_back(tr("Data in area of file that should be unused."));
|
|
|
|
|
|
|
|
|
|
if (sl.empty())
|
|
|
|
|