diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java index 52312b29f931..5b34d09ab06a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java @@ -138,6 +138,7 @@ public boolean onLongClick(View view) FragmentActivity activity = (FragmentActivity) view.getContext(); GameViewHolder holder = (GameViewHolder) view.getTag(); String gameId = holder.gameFile.getGameId(); + String gamePath = holder.gameFile.getPath(); if (gameId.isEmpty()) { @@ -150,7 +151,7 @@ public boolean onLongClick(View view) } GameSettingsDialog fragment = - GameSettingsDialog.newInstance(gameId, holder.gameFile.getPlatform()); + GameSettingsDialog.newInstance(gameId, gamePath, holder.gameFile.getPlatform()); ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction() .add(fragment, GameSettingsDialog.TAG).commit(); return true; diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java index 8047a438e8f1..8cb8b7eedf0a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java @@ -85,6 +85,7 @@ public void onBindViewHolder(ViewHolder viewHolder, Object item) { FragmentActivity activity = (FragmentActivity) view.getContext(); String gameId = gameFile.getGameId(); + String gamePath = holder.gameFile.getPath(); if (gameId.isEmpty()) { @@ -97,7 +98,7 @@ public void onBindViewHolder(ViewHolder viewHolder, Object item) } GameSettingsDialog fragment = - GameSettingsDialog.newInstance(gameId, holder.gameFile.getPlatform()); + GameSettingsDialog.newInstance(gameId, gamePath, holder.gameFile.getPlatform()); ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction() .add(fragment, GameSettingsDialog.TAG).commit(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameSettingsDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameSettingsDialog.java index 5639897d629c..deeaa0ba6ffc 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameSettingsDialog.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameSettingsDialog.java @@ -9,6 +9,7 @@ import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity; +import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile; import org.dolphinemu.dolphinemu.ui.platform.Platform; import org.dolphinemu.dolphinemu.utils.DirectoryInitialization; @@ -18,14 +19,16 @@ public class GameSettingsDialog extends DialogFragment { public static final String TAG = "GameSettingsDialog"; public static final String ARG_GAMEID = "game_id"; + public static final String ARG_GAMEPATH = "gamePath"; public static final String ARG_PLATFORM = "platform"; - public static GameSettingsDialog newInstance(String gameId, int platform) + public static GameSettingsDialog newInstance(String gameId, String gamePath, int platform) { GameSettingsDialog fragment = new GameSettingsDialog(); Bundle arguments = new Bundle(); arguments.putString(ARG_GAMEID, gameId); + arguments.putString(ARG_GAMEPATH, gamePath); arguments.putInt(ARG_PLATFORM, platform); fragment.setArguments(arguments); @@ -38,6 +41,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); String gameId = getArguments().getString(ARG_GAMEID); + String gamePath = getArguments().getString(ARG_GAMEPATH); int platform = getArguments().getInt(ARG_PLATFORM); builder.setTitle(getActivity().getString(R.string.preferences_game_settings)) @@ -64,14 +68,24 @@ public Dialog onCreateDialog(Bundle savedInstanceState) SettingsActivity.launch(getActivity(), MenuTag.WIIMOTE, gameId); break; case 4: - clearGameSettings(gameId); + // Set as default ISO for GC, Wii clear game settings for else + if (platform == Platform.GAMECUBE.toInt()) + { + SettingsFile.putDefaultISOSetting(gamePath); + Toast.makeText(getContext(), "Default ISO set", Toast.LENGTH_SHORT).show(); + } + else + clearGameSettings(gameId); + break; + case 5: + SettingsFile.putDefaultISOSetting(gamePath); + Toast.makeText(getContext(), "Default ISO set", Toast.LENGTH_SHORT).show(); break; } }); return builder.create(); } - private void clearGameSettings(String gameId) { String path = diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java index aac139266f87..efefac2bac85 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java @@ -53,6 +53,7 @@ public final class SettingsFile public static final String KEY_SLOT_B_DEVICE = "SlotB"; public static final String KEY_ENABLE_SAVE_STATES = "EnableSaveStates"; public static final String KEY_LOCK_LANDSCAPE = "LockLandscape"; + public static final String KEY_DEFAULT_ISO = "DefaultISO"; public static final String KEY_ANALYTICS_ENABLED = "Enabled"; public static final String KEY_ANALYTICS_PERMISSION_ASKED = "PermissionAsked"; @@ -631,6 +632,23 @@ public static void firstAnalyticsAdd(boolean enabled) saveFile(SettingsFile.FILE_NAME_DOLPHIN, saveSection, null); } + public static void putDefaultISOSetting(String gamePath) + { + HashMap dolphinSections = + readFile(SettingsFile.FILE_NAME_DOLPHIN, null); + SettingSection coreSection = dolphinSections.get(Settings.SECTION_INI_CORE); + + Setting defaultISO = + new StringSetting(KEY_DEFAULT_ISO, Settings.SECTION_INI_CORE, gamePath); + + coreSection.putSetting(defaultISO); + + dolphinSections.put(Settings.SECTION_INI_CORE, coreSection); + + TreeMap saveSection = new TreeMap<>(dolphinSections); + saveFile(SettingsFile.FILE_NAME_DOLPHIN, saveSection, null); + } + /** * For a line of text, determines what type of data is being represented, and returns * a Setting object containing this data. diff --git a/Source/Android/app/src/main/res/values/arrays.xml b/Source/Android/app/src/main/res/values/arrays.xml index 9e2f268151c7..4e2a7f91c5e3 100644 --- a/Source/Android/app/src/main/res/values/arrays.xml +++ b/Source/Android/app/src/main/res/values/arrays.xml @@ -340,6 +340,7 @@ GFX Settings GameCube Controller Settings Clear Game Settings + Set as Default ISO Core Settings @@ -347,5 +348,6 @@ GameCube Controller Settings Wii Controller Settings Clear Game Settings + Set as Default ISO