[Android] Turn SaveConfigToDolphinIni() into a static method. Now saving settings to the ini config just uses one call in PrefsFragment.onDestroy().
This commit is contained in:
parent
6dbfdce775
commit
9595457e1c
|
@ -208,9 +208,7 @@ public final class PrefsFragment extends PreferenceFragment
|
||||||
{
|
{
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
// When the fragment is done being used, save the settings
|
// When the fragment is done being used, save the settings to the Dolphin ini file.
|
||||||
// to the Dolphin ini file.
|
UserPreferences.SaveConfigToDolphinIni(m_activity);
|
||||||
UserPreferences userPrefs = new UserPreferences(m_activity);
|
|
||||||
userPrefs.SaveConfigToDolphinIni();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,45 +13,21 @@ import android.preference.PreferenceManager;
|
||||||
*/
|
*/
|
||||||
public final class UserPreferences
|
public final class UserPreferences
|
||||||
{
|
{
|
||||||
// The cached shared preferences.
|
|
||||||
private final SharedPreferences mPrefs;
|
|
||||||
|
|
||||||
// Whether or not the user is using dual core.
|
|
||||||
private final boolean isUsingDualCore;
|
|
||||||
|
|
||||||
// The current CPU core being used.
|
|
||||||
private final String currentEmuCore;
|
|
||||||
|
|
||||||
// The current video back-end being used.
|
|
||||||
private final String currentVideoBackend;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param ctx The context to use an instance of this class in.
|
|
||||||
* This allows the class to retrieve the SharedPreferences
|
|
||||||
* instance from the given context, which, in turn allows
|
|
||||||
* this class to function for its intended purpose.
|
|
||||||
*/
|
|
||||||
public UserPreferences(Context ctx)
|
|
||||||
{
|
|
||||||
// Get an instance of all of our stored preferences.
|
|
||||||
this.mPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
|
||||||
|
|
||||||
//-- Assign to the variables to cache the settings. --//
|
|
||||||
|
|
||||||
this.isUsingDualCore = mPrefs.getBoolean("dualCorePref", true);
|
|
||||||
|
|
||||||
// Fall back to interpreter if it somehow can't find a CPU core.
|
|
||||||
this.currentEmuCore = mPrefs.getString("cpuCorePref", "0");
|
|
||||||
|
|
||||||
// Fall back to using software rendering if another valid backend can't be found.
|
|
||||||
this.currentVideoBackend = mPrefs.getString("gpuPref", "Software Renderer");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Writes the config to the Dolphin ini file. */
|
/** Writes the config to the Dolphin ini file. */
|
||||||
public void SaveConfigToDolphinIni()
|
public static void SaveConfigToDolphinIni(Context ctx)
|
||||||
{
|
{
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||||
|
|
||||||
|
// Whether or not the user is using dual core.
|
||||||
|
boolean isUsingDualCore = prefs.getBoolean("dualCorePref", true);
|
||||||
|
|
||||||
|
// Current CPU core being used. Falls back to interpreter upon error.
|
||||||
|
String currentEmuCore = prefs.getString("cpuCorePref", "0");
|
||||||
|
|
||||||
|
// Current video backend being used. Falls back to software rendering upon error
|
||||||
|
String currentVideoBackend = prefs.getString("gpuPref", "Software Rendering");
|
||||||
|
|
||||||
|
|
||||||
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUCore", currentEmuCore);
|
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUCore", currentEmuCore);
|
||||||
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUThread", isUsingDualCore ? "True" : "False");
|
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUThread", isUsingDualCore ? "True" : "False");
|
||||||
NativeLibrary.SetConfig("Dolphin.ini", "Core", "GFXBackend", currentVideoBackend);
|
NativeLibrary.SetConfig("Dolphin.ini", "Core", "GFXBackend", currentVideoBackend);
|
||||||
|
|
Loading…
Reference in New Issue