From f01ccfdb824d37dd9bee2eb150a7721ea19b6837 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 27 Jun 2020 12:35:18 +0200 Subject: [PATCH] Android: Only allow conversion when appropriate --- .../dolphinemu/dialogs/GamePropertiesDialog.java | 10 ++++++++-- .../java/org/dolphinemu/dolphinemu/model/GameFile.java | 2 ++ Source/Android/jni/GameList/GameFile.cpp | 8 ++++++++ Source/Core/DolphinQt/GameList/GameList.cpp | 7 +++---- Source/Core/UICommon/GameFile.cpp | 5 +++++ Source/Core/UICommon/GameFile.h | 1 + 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java index d3f5395107..6480b24c2c 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java @@ -29,6 +29,7 @@ public class GamePropertiesDialog extends DialogFragment private static final String ARG_GAMEID = "game_id"; public static final String ARG_REVISION = "revision"; private static final String ARG_PLATFORM = "platform"; + private static final String ARG_SHOULD_ALLOW_CONVERSION = "should_allow_conversion"; public static GamePropertiesDialog newInstance(GameFile gameFile) { @@ -39,6 +40,7 @@ public class GamePropertiesDialog extends DialogFragment arguments.putString(ARG_GAMEID, gameFile.getGameId()); arguments.putInt(ARG_REVISION, gameFile.getRevision()); arguments.putInt(ARG_PLATFORM, gameFile.getPlatform()); + arguments.putBoolean(ARG_SHOULD_ALLOW_CONVERSION, gameFile.shouldAllowConversion()); fragment.setArguments(arguments); return fragment; @@ -52,6 +54,7 @@ public class GamePropertiesDialog extends DialogFragment String gameId = requireArguments().getString(ARG_GAMEID); int revision = requireArguments().getInt(ARG_REVISION); int platform = requireArguments().getInt(ARG_PLATFORM); + boolean shouldAllowConversion = requireArguments().getBoolean(ARG_SHOULD_ALLOW_CONVERSION); AlertDialogItemsBuilder itemsBuilder = new AlertDialogItemsBuilder(requireContext()); @@ -59,8 +62,11 @@ public class GamePropertiesDialog extends DialogFragment GameDetailsDialog.newInstance(path).show(requireActivity() .getSupportFragmentManager(), "game_details")); - itemsBuilder.add(R.string.properties_convert, (dialog, i) -> - ConvertActivity.launch(getContext(), path)); + if (shouldAllowConversion) + { + itemsBuilder.add(R.string.properties_convert, (dialog, i) -> + ConvertActivity.launch(getContext(), path)); + } itemsBuilder.add(R.string.properties_set_default_iso, (dialog, i) -> { 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 c0b55f5da7..9ac331c2b2 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 @@ -48,6 +48,8 @@ public class GameFile public native boolean shouldShowFileFormatDetails(); + public native boolean shouldAllowConversion(); + public native long getFileSize(); public native boolean isDatelDisc(); diff --git a/Source/Android/jni/GameList/GameFile.cpp b/Source/Android/jni/GameList/GameFile.cpp index 31c95fc48d..21e8aa24aa 100644 --- a/Source/Android/jni/GameList/GameFile.cpp +++ b/Source/Android/jni/GameList/GameFile.cpp @@ -73,6 +73,8 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getCompressionMethod(JNIEnv* env, jobject obj); JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_shouldShowFileFormatDetails(JNIEnv* env, jobject obj); +JNIEXPORT jboolean JNICALL +Java_org_dolphinemu_dolphinemu_model_GameFile_shouldAllowConversion(JNIEnv* env, jobject obj); JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getFileSize(JNIEnv* env, jobject obj); JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_isDatelDisc(JNIEnv* env, @@ -188,6 +190,12 @@ Java_org_dolphinemu_dolphinemu_model_GameFile_shouldShowFileFormatDetails(JNIEnv return static_cast(GetRef(env, obj)->ShouldShowFileFormatDetails()); } +JNIEXPORT jboolean JNICALL +Java_org_dolphinemu_dolphinemu_model_GameFile_shouldAllowConversion(JNIEnv* env, jobject obj) +{ + return static_cast(GetRef(env, obj)->ShouldAllowConversion()); +} + JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getFileSize(JNIEnv* env, jobject obj) { diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index 956bc704dc..11cbadb2d3 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -267,9 +267,8 @@ void GameList::ShowContextMenu(const QPoint&) { const auto selected_games = GetSelectedGames(); - if (std::all_of(selected_games.begin(), selected_games.end(), [](const auto& game) { - return DiscIO::IsDisc(game->GetPlatform()) && game->IsVolumeSizeAccurate(); - })) + if (std::all_of(selected_games.begin(), selected_games.end(), + [](const auto& game) { return game->ShouldAllowConversion(); })) { menu->addAction(tr("Convert Selected Files..."), this, &GameList::ConvertFile); menu->addSeparator(); @@ -301,7 +300,7 @@ void GameList::ShowContextMenu(const QPoint&) { menu->addAction(tr("Set as &Default ISO"), this, &GameList::SetDefaultISO); - if (game->IsVolumeSizeAccurate()) + if (game->ShouldAllowConversion()) menu->addAction(tr("Convert File..."), this, &GameList::ConvertFile); QAction* change_disc = menu->addAction(tr("Change &Disc"), this, &GameList::ChangeDisc); diff --git a/Source/Core/UICommon/GameFile.cpp b/Source/Core/UICommon/GameFile.cpp index 30641d58e5..ff0fa84798 100644 --- a/Source/Core/UICommon/GameFile.cpp +++ b/Source/Core/UICommon/GameFile.cpp @@ -672,6 +672,11 @@ std::string GameFile::GetFileFormatName() const } } +bool GameFile::ShouldAllowConversion() const +{ + return DiscIO::IsDisc(m_platform) && m_volume_size_is_accurate; +} + const GameBanner& GameFile::GetBannerImage() const { return m_custom_banner.empty() ? m_volume_banner : m_custom_banner; diff --git a/Source/Core/UICommon/GameFile.h b/Source/Core/UICommon/GameFile.h index 9366b33f2e..3aa693507f 100644 --- a/Source/Core/UICommon/GameFile.h +++ b/Source/Core/UICommon/GameFile.h @@ -101,6 +101,7 @@ public: const std::string& GetCompressionMethod() const { return m_compression_method; } bool ShouldShowFileFormatDetails() const; std::string GetFileFormatName() const; + bool ShouldAllowConversion() const; const std::string& GetApploaderDate() const { return m_apploader_date; } u64 GetFileSize() const { return m_file_size; } u64 GetVolumeSize() const { return m_volume_size; }