mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
GCMemcardManager: Rewrite file copying logic to provide a better user experience.
This commit is contained in:
@ -573,31 +573,27 @@ void GCMemcardManager::ImportFile()
|
|||||||
|
|
||||||
void GCMemcardManager::CopyFiles()
|
void GCMemcardManager::CopyFiles()
|
||||||
{
|
{
|
||||||
auto selection = m_slot_table[m_active_slot]->selectedItems();
|
const auto& source_card = m_slot_memcard[m_active_slot];
|
||||||
auto& memcard = m_slot_memcard[m_active_slot];
|
if (!source_card)
|
||||||
|
return;
|
||||||
|
|
||||||
auto count = selection.count() / m_slot_table[m_active_slot]->columnCount();
|
auto& target_card = m_slot_memcard[!m_active_slot];
|
||||||
|
if (!target_card)
|
||||||
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
const auto selected_indices = GetSelectedFileIndices();
|
||||||
|
if (selected_indices.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto savefiles = Memcard::GetSavefiles(*source_card, selected_indices);
|
||||||
|
if (savefiles.empty())
|
||||||
{
|
{
|
||||||
auto sel = selection[i * m_slot_table[m_active_slot]->columnCount()];
|
ModalMessageBox::warning(this, tr("Copy Failed"),
|
||||||
int file_index = memcard->GetFileIndex(m_slot_table[m_active_slot]->row(sel));
|
tr("Failed to read selected savefile(s) from memory card."));
|
||||||
|
return;
|
||||||
const auto result = m_slot_memcard[!m_active_slot]->CopyFrom(*memcard, file_index);
|
|
||||||
|
|
||||||
if (result != Memcard::GCMemcardImportFileRetVal::SUCCESS)
|
|
||||||
{
|
|
||||||
ModalMessageBox::warning(this, tr("Copy failed"), tr("Failed to copy file"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < SLOT_COUNT; i++)
|
ImportFiles(!m_active_slot, savefiles);
|
||||||
{
|
|
||||||
if (!m_slot_memcard[i]->Save())
|
|
||||||
PanicAlertFmtT("File write failed");
|
|
||||||
|
|
||||||
UpdateSlotTable(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCMemcardManager::DeleteFiles()
|
void GCMemcardManager::DeleteFiles()
|
||||||
|
Reference in New Issue
Block a user