diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/ConvertFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/ConvertFragment.java index cb0f045a30..d1f09bbd50 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/ConvertFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/ConvertFragment.java @@ -27,6 +27,7 @@ import java.io.File; import java.util.ArrayList; import androidx.annotation.NonNull; +import androidx.annotation.StringRes; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; @@ -331,32 +332,42 @@ public class ConvertFragment extends Fragment implements View.OnClickListener @Override public void onClick(View view) { - Context context = requireContext(); - boolean scrub = getRemoveJunkData(); - int format = mFormat.getValue(context); + int format = mFormat.getValue(requireContext()); - boolean iso_warning = scrub && format == BLOB_TYPE_PLAIN; - boolean gcz_warning = !scrub && format == BLOB_TYPE_GCZ && !gameFile.isDatelDisc() && - gameFile.getPlatform() == Platform.WII.toInt(); + Runnable action = this::showSavePrompt; - if (iso_warning || gcz_warning) + if (gameFile.isNKit()) { + action = addAreYouSureDialog(action, R.string.convert_warning_nkit); + } + + if (!scrub && format == BLOB_TYPE_GCZ && !gameFile.isDatelDisc() && + gameFile.getPlatform() == Platform.WII.toInt()) + { + action = addAreYouSureDialog(action, R.string.convert_warning_gcz); + } + + if (scrub && format == BLOB_TYPE_PLAIN) + { + action = addAreYouSureDialog(action, R.string.convert_warning_iso); + } + + action.run(); + } + + private Runnable addAreYouSureDialog(Runnable action, @StringRes int warning_text) + { + return () -> + { + Context context = requireContext(); AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DolphinDialogBase); - builder.setMessage(iso_warning ? R.string.convert_warning_iso : R.string.convert_warning_gcz) - .setPositiveButton(R.string.yes, (dialog, i) -> - { - dialog.dismiss(); - showSavePrompt(); - }) - .setNegativeButton(R.string.no, (dialog, i) -> dialog.dismiss()); + builder.setMessage(warning_text) + .setPositiveButton(R.string.yes, (dialog, i) -> action.run()) + .setNegativeButton(R.string.no, null); AlertDialog alert = builder.create(); alert.show(); - } - else - { - showSavePrompt(); - } + }; } private void showSavePrompt() diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java index 93f6f120b3..b8de619e31 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java @@ -60,6 +60,8 @@ public class GameFile public native boolean isDatelDisc(); + public native boolean isNKit(); + public native int[] getBanner(); public native int getBannerWidth(); diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index 0f3e8dfbff..581e2bccfb 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -425,6 +425,7 @@ Converting 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? 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? + Dolphin can\'t convert NKit files to non-NKit files. Converting an NKit file in Dolphin will result in another NKit file.\n\nIf you want to convert an NKit file to a non-NKit file, you can use the same program as you originally used when converting the file to the NKit format.\n\nDo you want to continue anyway? The disc image was successfully converted. Dolphin failed to complete the requested action. diff --git a/Source/Android/jni/GameList/GameFile.cpp b/Source/Android/jni/GameList/GameFile.cpp index 5cc3d6c391..e62052966d 100644 --- a/Source/Android/jni/GameList/GameFile.cpp +++ b/Source/Android/jni/GameList/GameFile.cpp @@ -162,6 +162,12 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_isDatel return static_cast(GetRef(env, obj)->IsDatelDisc()); } +JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_isNKit(JNIEnv* env, + jobject obj) +{ + return static_cast(GetRef(env, obj)->IsNKit()); +} + JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getBanner(JNIEnv* env, jobject obj) { diff --git a/Source/Core/DolphinQt/ConvertDialog.cpp b/Source/Core/DolphinQt/ConvertDialog.cpp index b7bf614291..097ca87a39 100644 --- a/Source/Core/DolphinQt/ConvertDialog.cpp +++ b/Source/Core/DolphinQt/ConvertDialog.cpp @@ -329,6 +329,21 @@ void ConvertDialog::Convert() } } + if (std::any_of(m_files.begin(), m_files.end(), std::mem_fn(&UICommon::GameFile::IsNKit))) + { + if (!ShowAreYouSureDialog( + tr("Dolphin can't convert NKit files to non-NKit files. Converting an NKit file in " + "Dolphin will result in another NKit file.\n" + "\n" + "If you want to convert an NKit file to a non-NKit file, you can use the same " + "program as you originally used when converting the file to the NKit format.\n" + "\n" + "Do you want to continue anyway?"))) + { + return; + } + } + QString extension; QString filter; switch (format) diff --git a/Source/Core/UICommon/GameFile.h b/Source/Core/UICommon/GameFile.h index 019b5ae0a3..fc981cd226 100644 --- a/Source/Core/UICommon/GameFile.h +++ b/Source/Core/UICommon/GameFile.h @@ -106,6 +106,7 @@ public: u64 GetVolumeSize() const { return m_volume_size; } bool IsVolumeSizeAccurate() const { return m_volume_size_is_accurate; } bool IsDatelDisc() const { return m_is_datel_disc; } + bool IsNKit() const { return m_is_nkit; } const GameBanner& GetBannerImage() const; const GameCover& GetCoverImage() const; void DoState(PointerWrap& p);