Android: Only allow conversion when appropriate
This commit is contained in:
parent
23ea47d4df
commit
f01ccfdb82
|
@ -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) ->
|
||||
{
|
||||
|
|
|
@ -48,6 +48,8 @@ public class GameFile
|
|||
|
||||
public native boolean shouldShowFileFormatDetails();
|
||||
|
||||
public native boolean shouldAllowConversion();
|
||||
|
||||
public native long getFileSize();
|
||||
|
||||
public native boolean isDatelDisc();
|
||||
|
|
|
@ -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<jboolean>(GetRef(env, obj)->ShouldShowFileFormatDetails());
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_model_GameFile_shouldAllowConversion(JNIEnv* env, jobject obj)
|
||||
{
|
||||
return static_cast<jboolean>(GetRef(env, obj)->ShouldAllowConversion());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getFileSize(JNIEnv* env,
|
||||
jobject obj)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in New Issue