mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
WiiSave: Move user interaction to UI frontends
This commit is contained in:
parent
4df266f943
commit
8eafd1928e
@ -28,7 +28,6 @@
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Lazy.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/NandPaths.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Swap.h"
|
||||
@ -520,7 +519,7 @@ bool Copy(Storage* source, Storage* dest)
|
||||
Copy("files", source, &Storage::ReadFiles, dest, &Storage::WriteFiles);
|
||||
}
|
||||
|
||||
bool Import(const std::string& data_bin_path)
|
||||
bool Import(const std::string& data_bin_path, std::function<bool()> can_overwrite)
|
||||
{
|
||||
IOS::HLE::Kernel ios;
|
||||
const auto data_bin = MakeDataBinStorage(&ios.GetIOSC(), data_bin_path, "rb");
|
||||
@ -531,11 +530,8 @@ bool Import(const std::string& data_bin_path)
|
||||
return false;
|
||||
}
|
||||
const auto nand = MakeNandStorage(ios.GetFS().get(), header->hdr.tid);
|
||||
if (nand->SaveExists() && !AskYesNoT("Save data for this title already exists. Consider backing "
|
||||
"up the current data before overwriting.\nOverwrite now?"))
|
||||
{
|
||||
if (nand->SaveExists() && !can_overwrite())
|
||||
return false;
|
||||
}
|
||||
return Copy(data_bin.get(), nand.get());
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@ -37,7 +38,7 @@ StoragePointer MakeDataBinStorage(IOS::HLE::IOSC* iosc, const std::string& path,
|
||||
bool Copy(Storage* source, Storage* destination);
|
||||
|
||||
/// Import a save into the NAND from a .bin file.
|
||||
bool Import(const std::string& data_bin_path);
|
||||
bool Import(const std::string& data_bin_path, std::function<bool()> can_overwrite);
|
||||
/// Export a save to a .bin file.
|
||||
bool Export(u64 tid, const std::string& export_path);
|
||||
/// Export all saves that are in the NAND. Returns the number of exported saves.
|
||||
|
@ -958,9 +958,18 @@ void MenuBar::ImportWiiSave()
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
|
||||
if (WiiSave::Import(file.toStdString()))
|
||||
bool cancelled = false;
|
||||
auto can_overwrite = [&] {
|
||||
bool yes = QMessageBox::question(
|
||||
this, tr("Save Import"),
|
||||
tr("Save data for this title already exists in the NAND. Consider backing up "
|
||||
"the current data before overwriting.\nOverwrite now?")) == QMessageBox::Yes;
|
||||
cancelled = !yes;
|
||||
return yes;
|
||||
};
|
||||
if (WiiSave::Import(file.toStdString(), can_overwrite))
|
||||
QMessageBox::information(this, tr("Save Import"), tr("Successfully imported save files."));
|
||||
else
|
||||
else if (!cancelled)
|
||||
QMessageBox::critical(this, tr("Save Import"), tr("Failed to import save files."));
|
||||
}
|
||||
|
||||
|
@ -1214,8 +1214,14 @@ void CFrame::OnImportSave(wxCommandEvent& WXUNUSED(event))
|
||||
_("Wii save files (*.bin)") + "|*.bin|" + wxGetTranslation(wxALL_FILES),
|
||||
wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST, this);
|
||||
|
||||
auto can_overwrite = [this] {
|
||||
return wxMessageBox(_("Save data for this title already exists in the NAND. Consider backing "
|
||||
"up the current data before overwriting.\nOverwrite now?"),
|
||||
_("Save Import"), wxYES_NO, this) == wxYES;
|
||||
};
|
||||
|
||||
if (!path.IsEmpty())
|
||||
WiiSave::Import(WxStrToStr(path));
|
||||
WiiSave::Import(WxStrToStr(path), can_overwrite);
|
||||
}
|
||||
|
||||
void CFrame::OnShowCheatsWindow(wxCommandEvent& WXUNUSED(event))
|
||||
|
Loading…
x
Reference in New Issue
Block a user