summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2018-05-13 13:18:19 +0200
committerLéo Lam <leo@innovatetechnologi.es>2018-05-13 17:42:55 +0200
commita93d816c283de6972e3994a7e89f3c423f6afef6 (patch)
tree233186a9a4f49695200e045471cbc44c472febd8 /Source/Core
parent41c4486c653049464794d7831d479e91c26dd6c2 (diff)
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.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/WiiSave.cpp28
-rw-r--r--Source/Core/Core/HW/WiiSave.h9
-rw-r--r--Source/Core/DolphinQt2/GameList/GameList.cpp10
-rw-r--r--Source/Core/DolphinQt2/MenuBar.cpp14
4 files changed, 31 insertions, 30 deletions
diff --git a/Source/Core/Core/HW/WiiSave.cpp b/Source/Core/Core/HW/WiiSave.cpp
index 89f33f8f94..a8fce79221 100644
--- a/Source/Core/Core/HW/WiiSave.cpp
+++ b/Source/Core/Core/HW/WiiSave.cpp
@@ -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}
diff --git a/Source/Core/Core/HW/WiiSave.h b/Source/Core/Core/HW/WiiSave.h
index 160c2b5452..0a4d993a29 100644
--- a/Source/Core/Core/HW/WiiSave.h
+++ b/Source/Core/Core/HW/WiiSave.h
@@ -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);
diff --git a/Source/Core/DolphinQt2/GameList/GameList.cpp b/Source/Core/DolphinQt2/GameList/GameList.cpp
index e3b21af6f7..184f45622a 100644
--- a/Source/Core/DolphinQt2/GameList/GameList.cpp
+++ b/Source/Core/DolphinQt2/GameList/GameList.cpp
@@ -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();
}
diff --git a/Source/Core/DolphinQt2/MenuBar.cpp b/Source/Core/DolphinQt2/MenuBar.cpp
index adadc6301a..61df3f967c 100644
--- a/Source/Core/DolphinQt2/MenuBar.cpp
+++ b/Source/Core/DolphinQt2/MenuBar.cpp
@@ -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()