diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java index 611a62ca13..d34e4a1536 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java @@ -54,6 +54,12 @@ public abstract class SettingViewHolder extends RecyclerView.ViewHolder Toast.LENGTH_SHORT).show(); } + protected static void showIplNotAvailableError() + { + Toast.makeText(DolphinApplication.getAppContext(), R.string.ipl_not_found, Toast.LENGTH_SHORT) + .show(); + } + /** * Called by the adapter to set this ViewHolder's child views to display the list item * it must now represent. diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SwitchSettingViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SwitchSettingViewHolder.java index ea7185b2ec..8e568baf32 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SwitchSettingViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SwitchSettingViewHolder.java @@ -7,13 +7,20 @@ import android.view.View; import androidx.annotation.Nullable; import org.dolphinemu.dolphinemu.databinding.ListItemSettingSwitchBinding; +import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.view.SwitchSetting; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter; +import org.dolphinemu.dolphinemu.utils.DirectoryInitialization; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; public final class SwitchSettingViewHolder extends SettingViewHolder { private SwitchSetting mItem; + private boolean iplExists = false; private final ListItemSettingSwitchBinding mBinding; @@ -32,11 +39,43 @@ public final class SwitchSettingViewHolder extends SettingViewHolder mBinding.textSettingDescription.setText(item.getDescription()); mBinding.settingSwitch.setChecked(mItem.isChecked(getAdapter().getSettings())); + mBinding.settingSwitch.setEnabled(true); - mBinding.settingSwitch.setEnabled(mItem.isEditable()); + // Check for IPL to make sure user can skip. + if (mItem.getSetting() == BooleanSetting.MAIN_SKIP_IPL) + { + ArrayList iplDirs = new ArrayList<>(Arrays.asList("USA", "JAP", "EUR")); + for (String dir : iplDirs) + { + File iplFile = new File(DirectoryInitialization.getUserDirectory(), + File.separator + "GC" + File.separator + dir + File.separator + "IPL.bin"); + if (iplFile.exists()) + { + iplExists = true; + break; + } + } + + if (mItem.isChecked(getAdapter().getSettings())) + { + mBinding.settingSwitch.setEnabled(iplExists); + } + else + { + mBinding.settingSwitch.setEnabled(true); + } + } mBinding.settingSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> { + // If a user has skip IPL disabled previously and deleted their IPL file, we need to allow + // them to skip it or else their game will appear broken. However, once this is enabled, we + // need to disable the option again to prevent the same issue from occurring. + if (mItem.getSetting() == BooleanSetting.MAIN_SKIP_IPL && !iplExists && isChecked) + { + mBinding.settingSwitch.setEnabled(false); + } + getAdapter().onBooleanClick(mItem, mBinding.settingSwitch.isChecked()); setStyle(mBinding.textSettingName, mItem); @@ -54,6 +93,15 @@ public final class SwitchSettingViewHolder extends SettingViewHolder return; } + if (mItem.getSetting() == BooleanSetting.MAIN_SKIP_IPL && !iplExists) + { + if (mItem.isChecked(getAdapter().getSettings())) + { + showIplNotAvailableError(); + return; + } + } + mBinding.settingSwitch.toggle(); } diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index 163a78c3be..670bb3181e 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -642,6 +642,7 @@ It can efficiently compress both junk data and encrypted Wii data. Due to the Scoped Storage policy in Android 11 and newer, you can\'t change this path. Loading Settingsā€¦ This setting can\'t be changed while a game is running. + IPL not found Long press a setting to clear it. Do you want to restore this setting to its default value? Setting cleared