mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 23:59:27 +01:00
WiiSave: Move dialogs to UI code
This moves the result dialogs to DolphinQt2, since WiiSave should not really be responsible for interacting with the user as a simple Wii save importing/exporting class. This also fixes Wii save import/export showing result dialogs twice, once from WiiSave, and another time from DolphinQt2.
This commit is contained in:
parent
41c4486c65
commit
a93d816c28
@ -39,28 +39,16 @@ constexpr u32 s_ng_id = 0x0403AC68;
|
||||
bool WiiSave::Import(const std::string& filename)
|
||||
{
|
||||
WiiSave save_file{filename};
|
||||
if (save_file.Import())
|
||||
{
|
||||
SuccessAlertT("Successfully imported save file(s)");
|
||||
return true;
|
||||
}
|
||||
PanicAlertT("Import failed");
|
||||
return false;
|
||||
return save_file.Import();
|
||||
}
|
||||
|
||||
bool WiiSave::Export(u64 title_id)
|
||||
std::string WiiSave::Export(u64 title_id)
|
||||
{
|
||||
WiiSave export_save{title_id};
|
||||
if (export_save.Export())
|
||||
{
|
||||
SuccessAlertT("Successfully exported file to %s", export_save.m_encrypted_save_path.c_str());
|
||||
return true;
|
||||
}
|
||||
PanicAlertT("Export failed");
|
||||
return false;
|
||||
return export_save.Export() ? export_save.m_encrypted_save_path : "";
|
||||
}
|
||||
|
||||
void WiiSave::ExportAll()
|
||||
std::pair<size_t, std::string> WiiSave::ExportAll()
|
||||
{
|
||||
std::string title_folder = File::GetUserPath(D_WIIROOT_IDX) + "/title";
|
||||
std::vector<u64> titles;
|
||||
@ -88,16 +76,14 @@ void WiiSave::ExportAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
SuccessAlertT("Found %zu save file(s)", titles.size());
|
||||
u32 success = 0;
|
||||
size_t exported_save_count = 0;
|
||||
for (const u64& title : titles)
|
||||
{
|
||||
WiiSave export_save{title};
|
||||
if (export_save.Export())
|
||||
success++;
|
||||
++exported_save_count;
|
||||
}
|
||||
SuccessAlertT("Successfully exported %u save(s) to %s", success,
|
||||
(File::GetUserPath(D_USER_IDX) + "private/wii/title/").c_str());
|
||||
return {exported_save_count, File::GetUserPath(D_USER_IDX) + "private/wii/title/"};
|
||||
}
|
||||
|
||||
WiiSave::WiiSave(std::string filename) : m_encrypted_save_path(std::move(filename)), m_valid{true}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <mbedtls/aes.h>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -14,9 +15,13 @@
|
||||
class WiiSave
|
||||
{
|
||||
public:
|
||||
/// Import a save into the NAND from a .bin file.
|
||||
static bool Import(const std::string& filename);
|
||||
static bool Export(u64 title_id);
|
||||
static void ExportAll();
|
||||
/// Export a save to a .bin file. Returns the path to the .bin.
|
||||
static std::string Export(u64 title_id);
|
||||
/// Export all saves that are in the NAND. Returns the number of exported saves and a path
|
||||
/// to the .bins.
|
||||
static std::pair<size_t, std::string> ExportAll();
|
||||
|
||||
private:
|
||||
explicit WiiSave(std::string filename);
|
||||
|
@ -260,11 +260,13 @@ void GameList::ExportWiiSave()
|
||||
{
|
||||
QMessageBox result_dialog(this);
|
||||
|
||||
const bool success = WiiSave::Export(GetSelectedGame()->GetTitleID());
|
||||
const QString bin_path = QString::fromStdString(WiiSave::Export(GetSelectedGame()->GetTitleID()));
|
||||
|
||||
result_dialog.setIcon(success ? QMessageBox::Information : QMessageBox::Critical);
|
||||
result_dialog.setText(success ? tr("Successfully exported save files") :
|
||||
tr("Failed to export save files!"));
|
||||
result_dialog.setIcon(!bin_path.isEmpty() ? QMessageBox::Information : QMessageBox::Critical);
|
||||
if (!bin_path.isEmpty())
|
||||
result_dialog.setText(tr("Successfully exported save files to %1").arg(bin_path));
|
||||
else
|
||||
result_dialog.setText(tr("Failed to export save files."));
|
||||
result_dialog.exec();
|
||||
}
|
||||
|
||||
|
@ -896,13 +896,21 @@ void MenuBar::ImportWiiSave()
|
||||
tr("Wii save files (*.bin);;"
|
||||
"All Files (*)"));
|
||||
|
||||
if (!file.isEmpty())
|
||||
WiiSave::Import(file.toStdString());
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
|
||||
if (WiiSave::Import(file.toStdString()))
|
||||
QMessageBox::information(this, tr("Save Import"), tr("Successfully imported save files."));
|
||||
else
|
||||
QMessageBox::critical(this, tr("Save Import"), tr("Failed to import save files."));
|
||||
}
|
||||
|
||||
void MenuBar::ExportWiiSaves()
|
||||
{
|
||||
WiiSave::ExportAll();
|
||||
const std::pair<size_t, std::string> result = WiiSave::ExportAll();
|
||||
QMessageBox::information(this, tr("Save Export"),
|
||||
tr("Exported %n save(s) to %1", "", static_cast<int>(result.first))
|
||||
.arg(QString::fromStdString(result.second)));
|
||||
}
|
||||
|
||||
void MenuBar::CheckNAND()
|
||||
|
Loading…
x
Reference in New Issue
Block a user