diff options
| author | JosJuice <josjuice@gmail.com> | 2020-04-10 17:40:07 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2020-04-24 15:11:20 +0200 |
| commit | 6ffcbcee70c043a0d158d87458f99d20eddbb939 (patch) | |
| tree | 9782c56a64cb48afa5e2f3af437032712e060efc /Source/Core/DolphinQt/ConvertDialog.cpp | |
| parent | 04c7892b93f4ae129609060be5347628fa29eced (diff) | |
DiscIO: Move scrubbing code out of ConvertToGCZ
This way, scrubbing can also be performed when converting
to other formats.
Diffstat (limited to 'Source/Core/DolphinQt/ConvertDialog.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/ConvertDialog.cpp | 80 |
1 files changed, 58 insertions, 22 deletions
diff --git a/Source/Core/DolphinQt/ConvertDialog.cpp b/Source/Core/DolphinQt/ConvertDialog.cpp index c3e102bd7c..f35569b96e 100644 --- a/Source/Core/DolphinQt/ConvertDialog.cpp +++ b/Source/Core/DolphinQt/ConvertDialog.cpp @@ -6,6 +6,7 @@ #include <algorithm> #include <future> +#include <memory> #include <utility> #include <QComboBox> @@ -21,6 +22,7 @@ #include "Common/Assert.h" #include "DiscIO/Blob.h" +#include "DiscIO/ScrubbedBlob.h" #include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/ParallelProgressDialog.h" #include "UICommon/GameFile.h" @@ -179,34 +181,68 @@ void ConvertDialog::Convert() QFileInfo(QString::fromStdString(original_path)).fileName()); } - std::future<bool> good; + std::unique_ptr<DiscIO::BlobReader> blob_reader; + bool scrub_current_file = scrub_wii && file->GetPlatform() == DiscIO::Platform::WiiDisc; - if (format == DiscIO::BlobType::PLAIN) + if (scrub_current_file) { - good = std::async(std::launch::async, [&] { - const bool good = DiscIO::ConvertToPlain(original_path, dst_path.toStdString(), &CompressCB, - &progress_dialog); - progress_dialog.Reset(); - return good; - }); + blob_reader = DiscIO::ScrubbedBlob::Create(original_path); + if (!blob_reader) + { + const int result = + ModalMessageBox::warning(this, tr("Question"), + tr("Failed to remove junk data from file \"%1\".\n\n" + "Would you like to convert it without removing junk data?") + .arg(QString::fromStdString(original_path)), + QMessageBox::Ok | QMessageBox::Abort); + + if (result == QMessageBox::Ok) + scrub_current_file = false; + else + return; + } } - else if (format == DiscIO::BlobType::GCZ) + + if (!scrub_current_file) + blob_reader = DiscIO::CreateBlobReader(original_path); + + if (!blob_reader) { - good = std::async(std::launch::async, [&] { - const bool good = - DiscIO::ConvertToGCZ(original_path, dst_path.toStdString(), - file->GetPlatform() == DiscIO::Platform::WiiDisc ? 1 : 0, 16384, - &CompressCB, &progress_dialog); - progress_dialog.Reset(); - return good; - }); + QErrorMessage(this).showMessage( + tr("Failed to open the input file \"%1\".").arg(QString::fromStdString(original_path))); } - - progress_dialog.GetRaw()->exec(); - if (!good.get()) + else { - QErrorMessage(this).showMessage(tr("Dolphin failed to complete the requested action.")); - return; + std::future<bool> good; + + if (format == DiscIO::BlobType::PLAIN) + { + good = std::async(std::launch::async, [&] { + const bool good = + DiscIO::ConvertToPlain(blob_reader.get(), original_path, dst_path.toStdString(), + &CompressCB, &progress_dialog); + progress_dialog.Reset(); + return good; + }); + } + else if (format == DiscIO::BlobType::GCZ) + { + good = std::async(std::launch::async, [&] { + const bool good = + DiscIO::ConvertToGCZ(blob_reader.get(), original_path, dst_path.toStdString(), + file->GetPlatform() == DiscIO::Platform::WiiDisc ? 1 : 0, 16384, + &CompressCB, &progress_dialog); + progress_dialog.Reset(); + return good; + }); + } + + progress_dialog.GetRaw()->exec(); + if (!good.get()) + { + QErrorMessage(this).showMessage(tr("Dolphin failed to complete the requested action.")); + return; + } } } |
