Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Turn SaveConfigToDolphinIni() into a static method. Now sav…
…ing settings to the ini config just uses one call in PrefsFragment.onDestroy().
  • Loading branch information
lioncash committed Aug 20, 2013
1 parent 6dbfdce commit 9595457
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 39 deletions.
Expand Up @@ -208,9 +208,7 @@ public void onDestroy()
{
super.onDestroy();

// When the fragment is done being used, save the settings
// to the Dolphin ini file.
UserPreferences userPrefs = new UserPreferences(m_activity);
userPrefs.SaveConfigToDolphinIni();
// When the fragment is done being used, save the settings to the Dolphin ini file.
UserPreferences.SaveConfigToDolphinIni(m_activity);
}
}
46 changes: 11 additions & 35 deletions Source/Android/src/org/dolphinemu/dolphinemu/UserPreferences.java
Expand Up @@ -12,46 +12,22 @@
* aren't made necessary.
*/
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)
{
/** Writes the config to the Dolphin ini file. */
public static void SaveConfigToDolphinIni(Context ctx)
{
// Get an instance of all of our stored preferences.
this.mPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);

//-- Assign to the variables to cache the settings. --//
// Whether or not the user is using dual core.
boolean isUsingDualCore = prefs.getBoolean("dualCorePref", true);

this.isUsingDualCore = mPrefs.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");

// 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. */
public void SaveConfigToDolphinIni()
{
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUCore", currentEmuCore);
NativeLibrary.SetConfig("Dolphin.ini", "Core", "CPUThread", isUsingDualCore ? "True" : "False");
NativeLibrary.SetConfig("Dolphin.ini", "Core", "GFXBackend", currentVideoBackend);
Expand Down

0 comments on commit 9595457

Please sign in to comment.