diff options
| author | Lioncash <mathew1800@gmail.com> | 2013-08-20 15:35:16 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2013-08-20 15:35:16 -0400 |
| commit | 8de32505505e521dd1e518c2c88d6a8298397331 (patch) | |
| tree | 8800b4518580dcf704a3778d4ccb577775cfad52 /Source/Android/src | |
| parent | 3fdfd758320c10b0ca826859e27ef5cc421eb15f (diff) | |
[Android] Load all of the new settings from the ini when the app is launched.
- Also fix a typo in the ini saving method in UserPreferences. Accidentally spelt the ini name wrong.
- Also include the relocated XML preferences. I meant to push this with the previous commit.
Diffstat (limited to 'Source/Android/src')
3 files changed, 98 insertions, 14 deletions
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java index e593a996ad..f1abc215d1 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java @@ -3,10 +3,8 @@ package org.dolphinemu.dolphinemu; import android.app.Activity; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.os.Bundle; import android.os.Environment; -import android.preference.PreferenceManager; import android.util.DisplayMetrics; import android.util.Log; import android.view.InputDevice; @@ -124,13 +122,8 @@ public final class DolphinEmulator<MainActivity> extends Activity CopyAsset("setting-jpn.txt", WiiDir + File.separator + "setting-jpn.txt"); CopyAsset("setting-kor.txt", WiiDir + File.separator + "setting-kor.txt"); CopyAsset("setting-usa.txt", WiiDir + File.separator + "setting-usa.txt"); - - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - SharedPreferences.Editor editor = prefs.edit(); - 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(); + + UserPreferences.LoadDolphinConfigToPrefs(this); } } } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java index 0919e09964..f6196c7236 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java @@ -8,6 +8,18 @@ import android.preference.PreferenceFragment; import javax.microedition.khronos.egl.*; import javax.microedition.khronos.opengles.GL10; +// +// TODO: It would be nice to situate the preferences in a ViewPager. +// In such a way that the video settings are divided into sections like +// [General | Enhancements | Hacks] +// +// However I do not know how to correctly get ViewPagers to work with PreferenceFragments +// (at the time of writing), so if anyone else can implement this (AND document it nicely) +// that would be awesome +// +// - Lioncash +// + /** * Copyright 2013 Dolphin Emulator Project * Licensed under GPLv2 @@ -143,7 +155,7 @@ public final class PrefsFragment extends PreferenceFragment super.onCreate(savedInstanceState); // Load the preferences from an XML resource - addPreferencesFromResource(R.layout.prefs); + addPreferencesFromResource(R.xml.prefs); final ListPreference cpuCores = (ListPreference) findPreference("cpuCorePref"); diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/UserPreferences.java b/Source/Android/src/org/dolphinemu/dolphinemu/UserPreferences.java index 26644664cc..80e8b9dfdc 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/UserPreferences.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/UserPreferences.java @@ -13,6 +13,85 @@ import android.preference.PreferenceManager; */ public final class UserPreferences { + /** + * Loads the set config items from the Dolphin config files to the shared preferences of this front-end + * + * @param ctx The context used to retrieve the SharedPreferences instance. + */ + public static void LoadDolphinConfigToPrefs(Context ctx) + { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); + + // Get an editor. + SharedPreferences.Editor editor = prefs.edit(); + + // Add the settings. + editor.putString("cpuCorePref", getConfig("Dolphin.ini", "Core", "CPUCore", "3")); + editor.putBoolean("dualCorePref", getConfig("Dolphin.ini", "Core", "CPUThread", "False").equals("True")); + editor.putString("gpuPref", getConfig("Dolphin.ini", "Core", "GFXBackend ", "Software Renderer")); + + editor.putString("internalResolution", getConfig("gfx_opengl.ini", "Settings", "EFBScale", "2") ); + editor.putString("anisotropicFiltering", getConfig("gfx_opengl.ini", "Enhancements", "MaxAnisotropy", "0")); + editor.putBoolean("scaledEFBCopy", getConfig("gfx_opengl.ini", "Hacks", "EFBScaleCopy", "True").equals("True")); + editor.putBoolean("perPixelLighting", getConfig("gfx_opengl.ini", "Settings", "EnablePixelLighting", "False").equals("True")); + editor.putBoolean("forceTextureFiltering", getConfig("gfx_opengl.ini", "Enhancements", "ForceFiltering", "False").equals("True")); + editor.putBoolean("disableFog", getConfig("gfx_opengl.ini", "Settings", "DisableFog", "False").equals("True")); + editor.putBoolean("skipEFBAccess", getConfig("gfx_opengl.ini", "Hacks", "EFBAccessEnable", "False").equals("True")); + editor.putBoolean("ignoreFormatChanges", getConfig("gfx_opengl.ini", "Hacks", "EFBEmulateFormatChanges", "False").equals("False")); + + String efbCopyOn = getConfig("gfx_opengl.ini", "Hacks", "EFBCopyEnable", "False"); + String efbToTexture = getConfig("gfx_opengl.ini", "Hacks", "EFBToTextureEnable", "False"); + String efbCopyCache = getConfig("gfx_opengl.ini", "Hacks", "EFBCopyCacheEnable", "False"); + + if (efbCopyOn.equals("False")) + { + editor.putString("efbCopyMethod", "Off"); + } + else if (efbCopyOn.equals("True") && efbToTexture.equals("True")) + { + editor.putString("efbCopyMethod", "Texture"); + } + else if(efbCopyOn.equals("True") && efbToTexture.equals("False") && efbCopyCache.equals("False")) + { + editor.putString("efbCopyMethod", "RAM (uncached)"); + } + else if(efbCopyOn.equals("True") && efbToTexture.equals("False") && efbCopyCache.equals("True")) + { + editor.putString("efbCopyMethod", "RAM (cached)"); + } + + editor.putString("textureCacheAccuracy", getConfig("gfx_opengl.ini", "Settings", "SafeTextureCacheColorSamples", "128")); + + String usingXFB = getConfig("gfx_opengl.ini", "Settings", "UseXFB", "False"); + String usingRealXFB = getConfig("gfx_opengl.ini", "Settings", "UseRealXFB", "False"); + + if (usingXFB.equals("False")) + { + editor.putString("externalFrameBuffer", "Disabled"); + } + else if (usingXFB.equals("True") && usingRealXFB.equals("False")) + { + editor.putString("externalFrameBuffer", "Virtual"); + } + else if (usingXFB.equals("True") && usingRealXFB.equals("True")) + { + editor.putString("externalFrameBuffer", "Real"); + } + + editor.putBoolean("cacheDisplayLists", getConfig("gfx_opengl.ini", "Hacks", "DlistCachingEnable", "False").equals("True")); + editor.putBoolean("disableDestinationAlpha", getConfig("gfx_opengl.ini", "Settings", "DstAlphaPass", "False").equals("True")); + editor.putBoolean("fastDepthCalculation", getConfig("gfx_opengl.ini", "Settings", "FastDepthCalc", "True").equals("True")); + + // Apply the changes. + editor.commit(); + } + + // Small utility method that shortens calls to NativeLibrary.GetConfig. + private static String getConfig(String ini, String section, String key, String defaultValue) + { + return NativeLibrary.GetConfig(ini, section, key, defaultValue); + } + /** * Writes the config to the Dolphin ini file. * @@ -134,9 +213,9 @@ public final class UserPreferences //-- Enhancement Settings --// NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "EFBScale", internalResolution); NativeLibrary.SetConfig("gfx_opengl.ini", "Enhancements", "MaxAnisotropy", anisotropicFiltLevel); - NativeLibrary.SetConfig("gfx.opengl.ini", "Hacks", "EFBScaledCopy", usingScaledEFBCopy ? "True" : "False"); - NativeLibrary.SetConfig("gfx.opengl.ini", "Settings", "EnablePixelLighting", usingPerPixelLighting ? "True" : "False"); - NativeLibrary.SetConfig("gfx.opengl.ini", "Enhancements", "ForceFiltering", isForcingTextureFiltering ? "True" : "False"); - NativeLibrary.SetConfig("gfx.opengl.ini", "Settings", "DisableFog", fogIsDisabled ? "True" : "False"); + NativeLibrary.SetConfig("gfx_opengl.ini", "Hacks", "EFBScaledCopy", usingScaledEFBCopy ? "True" : "False"); + NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "EnablePixelLighting", usingPerPixelLighting ? "True" : "False"); + NativeLibrary.SetConfig("gfx_opengl.ini", "Enhancements", "ForceFiltering", isForcingTextureFiltering ? "True" : "False"); + NativeLibrary.SetConfig("gfx_opengl.ini", "Settings", "DisableFog", fogIsDisabled ? "True" : "False"); } } |
