diff --git a/Source/Core/DolphinQt/ConvertDialog.cpp b/Source/Core/DolphinQt/ConvertDialog.cpp index f35569b96e..6d124dcc18 100644 --- a/Source/Core/DolphinQt/ConvertDialog.cpp +++ b/Source/Core/DolphinQt/ConvertDialog.cpp @@ -5,10 +5,12 @@ #include "DolphinQt/ConvertDialog.h" #include +#include #include #include #include +#include #include #include #include @@ -56,6 +58,12 @@ ConvertDialog::ConvertDialog(QList> fi grid_layout->addWidget(new QLabel(tr("Format:")), 0, 0); grid_layout->addWidget(m_format, 0, 1); + m_scrub = new QCheckBox; + grid_layout->addWidget(new QLabel(tr("Remove Junk Data (Irreversible):")), 1, 0); + grid_layout->addWidget(m_scrub, 1, 1); + m_scrub->setEnabled( + std::none_of(m_files.begin(), m_files.end(), std::mem_fn(&UICommon::GameFile::IsDatelDisc))); + QPushButton* convert_button = new QPushButton(tr("Convert")); QVBoxLayout* main_layout = new QVBoxLayout; @@ -78,27 +86,44 @@ void ConvertDialog::AddToFormatComboBox(const QString& name, DiscIO::BlobType fo m_format->addItem(name, static_cast(format)); } +bool ConvertDialog::ShowAreYouSureDialog(const QString& text) +{ + ModalMessageBox warning(this); + warning.setIcon(QMessageBox::Warning); + warning.setWindowTitle(tr("Confirm")); + warning.setText(tr("Are you sure?")); + warning.setInformativeText(text); + warning.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + + return warning.exec() == QMessageBox::Yes; +} + void ConvertDialog::Convert() { const DiscIO::BlobType format = static_cast(m_format->currentData().toInt()); + const bool scrub = m_scrub->isChecked(); - const bool scrub_wii = format == DiscIO::BlobType::GCZ; + if (scrub && format == DiscIO::BlobType::PLAIN) + { + if (!ShowAreYouSureDialog(tr("Removing junk data does not save any space when converting to " + "ISO (unless you package the ISO file in a compressed file format " + "such as ZIP afterwards). Do you want to continue anyway?"))) + { + return; + } + } - if (scrub_wii && std::any_of(m_files.begin(), m_files.end(), [](const auto& file) { - return file->GetPlatform() == DiscIO::Platform::WiiDisc; + if (!scrub && format == DiscIO::BlobType::GCZ && + std::any_of(m_files.begin(), m_files.end(), [](const auto& file) { + return file->GetPlatform() == DiscIO::Platform::WiiDisc && !file->IsDatelDisc(); })) { - ModalMessageBox wii_warning(this); - wii_warning.setIcon(QMessageBox::Warning); - wii_warning.setWindowTitle(tr("Confirm")); - wii_warning.setText(tr("Are you sure?")); - wii_warning.setInformativeText( - tr("Compressing a Wii disc image will irreversibly change the compressed copy by removing " - "padding data. Your disc image will still work. Continue?")); - wii_warning.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - - if (wii_warning.exec() == QMessageBox::No) + if (!ShowAreYouSureDialog(tr("Converting Wii disc images to GCZ without removing junk data " + "does not save any noticeable amount of space compared to " + "converting to ISO. Do you want to continue anyway?"))) + { return; + } } QString extension; @@ -182,7 +207,7 @@ void ConvertDialog::Convert() } std::unique_ptr blob_reader; - bool scrub_current_file = scrub_wii && file->GetPlatform() == DiscIO::Platform::WiiDisc; + bool scrub_current_file = scrub; if (scrub_current_file) { diff --git a/Source/Core/DolphinQt/ConvertDialog.h b/Source/Core/DolphinQt/ConvertDialog.h index 17aeb8f3e7..e4664d3f00 100644 --- a/Source/Core/DolphinQt/ConvertDialog.h +++ b/Source/Core/DolphinQt/ConvertDialog.h @@ -11,6 +11,7 @@ #include "DiscIO/Blob.h" +class QCheckBox; class QComboBox; namespace UICommon @@ -32,6 +33,9 @@ private slots: private: void AddToFormatComboBox(const QString& name, DiscIO::BlobType format); + bool ShowAreYouSureDialog(const QString& text); + QComboBox* m_format; + QCheckBox* m_scrub; QList> m_files; }; diff --git a/Source/Core/UICommon/GameFile.cpp b/Source/Core/UICommon/GameFile.cpp index 139dcce688..ca5c53ae31 100644 --- a/Source/Core/UICommon/GameFile.cpp +++ b/Source/Core/UICommon/GameFile.cpp @@ -38,6 +38,7 @@ #include "Core/TitleDatabase.h" #include "DiscIO/Blob.h" +#include "DiscIO/DiscExtractor.h" #include "DiscIO/Enums.h" #include "DiscIO/Volume.h" #include "DiscIO/WiiSaveBanner.h" @@ -117,6 +118,8 @@ GameFile::GameFile(std::string path) : m_file_path(std::move(path)) m_file_size = volume->GetRawSize(); m_volume_size = volume->GetSize(); m_volume_size_is_accurate = volume->IsSizeAccurate(); + m_is_datel_disc = DiscIO::IsDisc(m_platform) && + !DiscIO::GetBootDOLOffset(*volume, volume->GetGamePartition()); m_internal_name = volume->GetInternalName(); m_game_id = volume->GetGameID(); @@ -138,6 +141,7 @@ GameFile::GameFile(std::string path) : m_file_path(std::move(path)) m_valid = true; m_file_size = m_volume_size = File::GetSize(m_file_path); m_volume_size_is_accurate = true; + m_is_datel_disc = false; m_platform = DiscIO::Platform::ELFOrDOL; m_blob_type = DiscIO::BlobType::DIRECTORY; } @@ -299,6 +303,7 @@ void GameFile::DoState(PointerWrap& p) p.Do(m_file_size); p.Do(m_volume_size); p.Do(m_volume_size_is_accurate); + p.Do(m_is_datel_disc); p.Do(m_short_names); p.Do(m_long_names); diff --git a/Source/Core/UICommon/GameFile.h b/Source/Core/UICommon/GameFile.h index 53401e8756..e3c29860f4 100644 --- a/Source/Core/UICommon/GameFile.h +++ b/Source/Core/UICommon/GameFile.h @@ -90,6 +90,7 @@ public: u64 GetFileSize() const { return m_file_size; } u64 GetVolumeSize() const { return m_volume_size; } bool IsVolumeSizeAccurate() const { return m_volume_size_is_accurate; } + bool IsDatelDisc() const { return m_is_datel_disc; } const GameBanner& GetBannerImage() const; const GameCover& GetCoverImage() const; void DoState(PointerWrap& p); @@ -126,6 +127,7 @@ private: u64 m_file_size{}; u64 m_volume_size{}; bool m_volume_size_is_accurate{}; + bool m_is_datel_disc{}; std::map m_short_names; std::map m_long_names;