mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-04 15:40:02 +00: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)
|
bool WiiSave::Import(const std::string& filename)
|
||||||
{
|
{
|
||||||
WiiSave save_file{filename};
|
WiiSave save_file{filename};
|
||||||
if (save_file.Import())
|
return save_file.Import();
|
||||||
{
|
|
||||||
SuccessAlertT("Successfully imported save file(s)");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PanicAlertT("Import failed");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WiiSave::Export(u64 title_id)
|
std::string WiiSave::Export(u64 title_id)
|
||||||
{
|
{
|
||||||
WiiSave export_save{title_id};
|
WiiSave export_save{title_id};
|
||||||
if (export_save.Export())
|
return export_save.Export() ? export_save.m_encrypted_save_path : "";
|
||||||
{
|
|
||||||
SuccessAlertT("Successfully exported file to %s", export_save.m_encrypted_save_path.c_str());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PanicAlertT("Export failed");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiiSave::ExportAll()
|
std::pair<size_t, std::string> WiiSave::ExportAll()
|
||||||
{
|
{
|
||||||
std::string title_folder = File::GetUserPath(D_WIIROOT_IDX) + "/title";
|
std::string title_folder = File::GetUserPath(D_WIIROOT_IDX) + "/title";
|
||||||
std::vector<u64> titles;
|
std::vector<u64> titles;
|
||||||
@ -88,16 +76,14 @@ void WiiSave::ExportAll()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SuccessAlertT("Found %zu save file(s)", titles.size());
|
size_t exported_save_count = 0;
|
||||||
u32 success = 0;
|
|
||||||
for (const u64& title : titles)
|
for (const u64& title : titles)
|
||||||
{
|
{
|
||||||
WiiSave export_save{title};
|
WiiSave export_save{title};
|
||||||
if (export_save.Export())
|
if (export_save.Export())
|
||||||
success++;
|
++exported_save_count;
|
||||||
}
|
}
|
||||||
SuccessAlertT("Successfully exported %u save(s) to %s", success,
|
return {exported_save_count, File::GetUserPath(D_USER_IDX) + "private/wii/title/"};
|
||||||
(File::GetUserPath(D_USER_IDX) + "private/wii/title/").c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WiiSave::WiiSave(std::string filename) : m_encrypted_save_path(std::move(filename)), m_valid{true}
|
WiiSave::WiiSave(std::string filename) : m_encrypted_save_path(std::move(filename)), m_valid{true}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <mbedtls/aes.h>
|
#include <mbedtls/aes.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
@ -14,9 +15,13 @@
|
|||||||
class WiiSave
|
class WiiSave
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// Import a save into the NAND from a .bin file.
|
||||||
static bool Import(const std::string& filename);
|
static bool Import(const std::string& filename);
|
||||||
static bool Export(u64 title_id);
|
/// Export a save to a .bin file. Returns the path to the .bin.
|
||||||
static void ExportAll();
|
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:
|
private:
|
||||||
explicit WiiSave(std::string filename);
|
explicit WiiSave(std::string filename);
|
||||||
|
@ -260,11 +260,13 @@ void GameList::ExportWiiSave()
|
|||||||
{
|
{
|
||||||
QMessageBox result_dialog(this);
|
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.setIcon(!bin_path.isEmpty() ? QMessageBox::Information : QMessageBox::Critical);
|
||||||
result_dialog.setText(success ? tr("Successfully exported save files") :
|
if (!bin_path.isEmpty())
|
||||||
tr("Failed to export save files!"));
|
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();
|
result_dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -896,13 +896,21 @@ void MenuBar::ImportWiiSave()
|
|||||||
tr("Wii save files (*.bin);;"
|
tr("Wii save files (*.bin);;"
|
||||||
"All Files (*)"));
|
"All Files (*)"));
|
||||||
|
|
||||||
if (!file.isEmpty())
|
if (file.isEmpty())
|
||||||
WiiSave::Import(file.toStdString());
|
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()
|
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()
|
void MenuBar::CheckNAND()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user