From 77a5af3bcf093b81df92921096e1d74bef505b46 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 19 Aug 2013 19:10:13 -0400 Subject: [PATCH] [Android] Change the settings menu a little more. Instead of the settings being a single view with settings from all components being displayed, I have broken it into sections. This future-proofs the settings menu in the sense that it won't get cluttered before people start asking "Hey, shouldn't this be broken into sections?". As of this commit, it is broken into CPU Settings and Video Settings. I also simplified the code that is responsible for setting the valid CPU cores and video backends by simply making UI string arrays that get chosen, based on the platform the Android device is running on. --- Source/Android/res/layout/prefs.xml | 46 ++++++------ Source/Android/res/values-ja/strings.xml | 1 + Source/Android/res/values/arrays.xml | 55 +++++++++++++++ Source/Android/res/values/prefvalues.xml | 12 ---- Source/Android/res/values/strings.xml | 1 + .../dolphinemu/DolphinEmulator.java | 6 +- .../dolphinemu/GameListActivity.java | 6 +- .../dolphinemu/dolphinemu/PrefsFragment.java | 70 +++++++------------ 8 files changed, 115 insertions(+), 82 deletions(-) create mode 100644 Source/Android/res/values/arrays.xml delete mode 100644 Source/Android/res/values/prefvalues.xml diff --git a/Source/Android/res/layout/prefs.xml b/Source/Android/res/layout/prefs.xml index d8d8664a97..53dd443300 100644 --- a/Source/Android/res/layout/prefs.xml +++ b/Source/Android/res/layout/prefs.xml @@ -1,24 +1,30 @@ - - + + + + + - - + android:key="dualCorePref" + android:summary="@string/on_off" + android:title="@string/dual_core" /> + - + android:key="cpuCorePref" + android:summary="@string/emu_core_to_use" + android:title="@string/cpu_core" /> + + + + + + + + + \ No newline at end of file diff --git a/Source/Android/res/values-ja/strings.xml b/Source/Android/res/values-ja/strings.xml index 329d464ccb..ff2ce33212 100644 --- a/Source/Android/res/values-ja/strings.xml +++ b/Source/Android/res/values-ja/strings.xml @@ -73,6 +73,7 @@ ビデオ設定 Software Renderer + OpenGL ES 3 ビデオレンダラ 使用するビデオレンダラー diff --git a/Source/Android/res/values/arrays.xml b/Source/Android/res/values/arrays.xml new file mode 100644 index 0000000000..05d4668b99 --- /dev/null +++ b/Source/Android/res/values/arrays.xml @@ -0,0 +1,55 @@ + + + + + + + + @string/interpreter + @string/jit64_recompiler + @string/jitil_recompiler + + + 0 + 1 + 2 + + + + + @string/interpreter + @string/jit_arm_recompiler + + + 0 + 3 + + + + + @string/interpreter + + + 0 + + + + + + @string/software_renderer + @string/opengl_es3 + + + Software Renderer + OGL + + + + + @string/software_renderer + + + Software Renderer + + + \ No newline at end of file diff --git a/Source/Android/res/values/prefvalues.xml b/Source/Android/res/values/prefvalues.xml deleted file mode 100644 index 8564801f6f..0000000000 --- a/Source/Android/res/values/prefvalues.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Software Renderer - OpenGL ES 3 - - - - Software Renderer - OGL - - \ No newline at end of file diff --git a/Source/Android/res/values/strings.xml b/Source/Android/res/values/strings.xml index ea1e02297a..8fc3805134 100644 --- a/Source/Android/res/values/strings.xml +++ b/Source/Android/res/values/strings.xml @@ -73,6 +73,7 @@ Video Settings Software Renderer + OpenGL ES 3 Video Backend Video backend to use diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java index 08c95fd2cd..e593a996ad 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java @@ -127,9 +127,9 @@ public final class DolphinEmulator extends Activity SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = prefs.edit(); - editor.putString("cpupref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "CPUCore", "3")); - editor.putBoolean("dualcorepref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "CPUThread", "False").equals("True") ? true : false); - editor.putString("gpupref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "GFXBackend ", "Software Renderer")); + editor.putString("cpuCorePref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "CPUCore", "3")); + editor.putBoolean("dualCorePref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "CPUThread", "False").equals("True") ? true : false); + editor.putString("gpuPref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "GFXBackend ", "Software Renderer")); editor.commit(); } } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java index 2bd61cb0f2..bbc3a0be72 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java @@ -113,9 +113,9 @@ public final class GameListActivity extends Activity case 2: { String Keys[] = { - "cpupref", - "dualcorepref", - "gpupref", + "cpuCorePref", + "dualCorePref", + "gpuPref", }; String ConfigKeys[] = { "Core-CPUCore", diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java index ad69a89a9d..bdc036e38a 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java @@ -1,12 +1,9 @@ package org.dolphinemu.dolphinemu; -import java.util.HashMap; - import android.app.Activity; import android.os.Build; import android.os.Bundle; import android.preference.ListPreference; -import android.preference.PreferenceCategory; import android.preference.PreferenceFragment; import javax.microedition.khronos.egl.*; @@ -111,11 +108,11 @@ public final class PrefsFragment extends PreferenceFragment boolean mSupportsGLES3 = false; // Check for OpenGL ES 3 support (General case). - if (m_GLVersion.contains("OpenGL ES 3.0") || m_GLVersion.equals("OpenGL ES 3.0")) + if (m_GLVersion != null && (m_GLVersion.contains("OpenGL ES 3.0") || m_GLVersion.equals("OpenGL ES 3.0"))) mSupportsGLES3 = true; // Checking for OpenGL ES 3 support for certain Qualcomm devices. - if (!mSupportsGLES3 && m_GLVendor.equals("Qualcomm")) + if (!mSupportsGLES3 && m_GLVendor != null && m_GLVendor.equals("Qualcomm")) { if (m_GLRenderer.contains("Adreno (TM) 3")) { @@ -149,58 +146,43 @@ public final class PrefsFragment extends PreferenceFragment // Load the preferences from an XML resource addPreferencesFromResource(R.layout.prefs); - final ListPreference etp = new ListPreference(m_activity); - final HashMap entries = new HashMap(); + final ListPreference cpuCores = (ListPreference) findPreference("cpuCorePref"); + // + // Set valid emulation cores depending on the CPU architecture + // that the Android device is running on. + // if (Build.CPU_ABI.contains("x86")) { - entries.put(getString(R.string.interpreter), "0"); - entries.put(getString(R.string.jit64_recompiler), "1"); - entries.put(getString(R.string.jitil_recompiler), "2"); + cpuCores.setEntries(R.array.emuCoreEntriesX86); + cpuCores.setEntryValues(R.array.emuCoreValuesX86); } else if (Build.CPU_ABI.contains("arm")) { - entries.put(getString(R.string.interpreter), "0"); - entries.put(getString(R.string.jit_arm_recompiler), "3"); + cpuCores.setEntries(R.array.emuCoreEntriesARM); + cpuCores.setEntryValues(R.array.emuCoreValuesARM); } else { - entries.put(getString(R.string.interpreter), "0"); + cpuCores.setEntries(R.array.emuCoreEntriesOther); + cpuCores.setEntryValues(R.array.emuCoreValuesOther); } - - // Convert the key/value sections to arrays respectively so the list can be set. - // If Java had proper generics it wouldn't look this disgusting. - etp.setEntries(entries.keySet().toArray(new CharSequence[entries.size()])); - etp.setEntryValues(entries.values().toArray(new CharSequence[entries.size()])); - etp.setKey("cpupref"); - etp.setTitle(getString(R.string.cpu_core)); - etp.setSummary(getString(R.string.emu_core_to_use)); - PreferenceCategory mCategory = (PreferenceCategory) findPreference("cpuprefcat"); - mCategory.addPreference(etp); + // + // Setting valid video backends. + // + final ListPreference videoBackends = (ListPreference) findPreference("gpuPref"); + final boolean deviceSupportsGLES3 = SupportsGLES3(); - boolean mSupportsGLES3 = SupportsGLES3(); - - if (!mSupportsGLES3) + if (deviceSupportsGLES3) { - mCategory = (PreferenceCategory) findPreference("videoprefcat"); - ListPreference mPref = (ListPreference) findPreference("gpupref"); - mCategory.removePreference(mPref); - - final ListPreference videobackend = new ListPreference(m_activity); - - // Add available graphics renderers to the hashmap to add to the list. - entries.clear(); - entries.put(getString(R.string.software_renderer), "Software Renderer"); - - videobackend.setKey("gpupref"); - videobackend.setTitle(getString(R.string.video_backend)); - videobackend.setSummary(getString(R.string.video_backend_to_use)); - - videobackend.setEntries(entries.keySet().toArray(new CharSequence[entries.size()])); - videobackend.setEntryValues(entries.values().toArray(new CharSequence[entries.size()])); - - mCategory.addPreference(videobackend); + videoBackends.setEntries(R.array.videoBackendEntriesGLES3); + videoBackends.setEntryValues(R.array.videoBackendValuesGLES3); + } + else + { + videoBackends.setEntries(R.array.videoBackendEntriesNoGLES3); + videoBackends.setEntryValues(R.array.videoBackendValuesNoGLES3); } }