mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-12 22:56:52 +01:00
Android: Hook up game settings to the new config system
This commit is contained in:
parent
a538301891
commit
e24d50e881
@ -363,6 +363,13 @@ public final class EmulationActivity extends AppCompatActivity
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
mSettings.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
|
@ -156,11 +156,12 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
|
||||
return true;
|
||||
}
|
||||
|
||||
GamePropertiesDialog fragment =
|
||||
GamePropertiesDialog
|
||||
.newInstance(holder.gameFile.getPath(), gameId, holder.gameFile.getPlatform());
|
||||
GamePropertiesDialog fragment = GamePropertiesDialog.newInstance(holder.gameFile.getPath(),
|
||||
gameId, holder.gameFile.getRevision(), holder.gameFile.getPlatform());
|
||||
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction()
|
||||
.add(fragment, GamePropertiesDialog.TAG).commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -100,9 +100,9 @@ public final class GameRowPresenter extends Presenter
|
||||
return true;
|
||||
}
|
||||
|
||||
GamePropertiesDialog fragment =
|
||||
GamePropertiesDialog.newInstance(holder.gameFile.getPath(), gameId,
|
||||
holder.gameFile.getPlatform());
|
||||
GamePropertiesDialog fragment = GamePropertiesDialog.newInstance(holder.gameFile.getPath(),
|
||||
gameId, holder.gameFile.getRevision(), holder.gameFile.getPlatform());
|
||||
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction()
|
||||
.add(fragment, GamePropertiesDialog.TAG).commit();
|
||||
|
||||
|
@ -24,15 +24,18 @@ public class GamePropertiesDialog extends DialogFragment
|
||||
public static final String TAG = "GamePropertiesDialog";
|
||||
public static final String ARG_PATH = "path";
|
||||
public static final String ARG_GAMEID = "game_id";
|
||||
public static final String ARG_REVISION = "revision";
|
||||
public static final String ARG_PLATFORM = "platform";
|
||||
|
||||
public static GamePropertiesDialog newInstance(String path, String gameId, int platform)
|
||||
public static GamePropertiesDialog newInstance(String path, String gameId, int revision,
|
||||
int platform)
|
||||
{
|
||||
GamePropertiesDialog fragment = new GamePropertiesDialog();
|
||||
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putString(ARG_PATH, path);
|
||||
arguments.putString(ARG_GAMEID, gameId);
|
||||
arguments.putInt(ARG_REVISION, revision);
|
||||
arguments.putInt(ARG_PLATFORM, platform);
|
||||
fragment.setArguments(arguments);
|
||||
|
||||
@ -48,6 +51,7 @@ public class GamePropertiesDialog extends DialogFragment
|
||||
|
||||
String path = requireArguments().getString(ARG_PATH);
|
||||
String gameId = requireArguments().getString(ARG_GAMEID);
|
||||
int revision = requireArguments().getInt(ARG_REVISION);
|
||||
int platform = requireArguments().getInt(ARG_PLATFORM);
|
||||
|
||||
builder.setTitle(requireContext()
|
||||
@ -63,26 +67,28 @@ public class GamePropertiesDialog extends DialogFragment
|
||||
.getSupportFragmentManager(), "game_details");
|
||||
break;
|
||||
case 1:
|
||||
Settings settings = new Settings();
|
||||
settings.loadSettings(null);
|
||||
StringSetting.MAIN_DEFAULT_ISO.setString(settings, path);
|
||||
settings.saveSettings(null, getContext());
|
||||
try (Settings settings = new Settings())
|
||||
{
|
||||
settings.loadSettings(null);
|
||||
StringSetting.MAIN_DEFAULT_ISO.setString(settings, path);
|
||||
settings.saveSettings(null, getContext());
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
SettingsActivity.launch(getContext(), MenuTag.CONFIG, gameId);
|
||||
SettingsActivity.launch(getContext(), MenuTag.CONFIG, gameId, revision);
|
||||
break;
|
||||
case 3:
|
||||
SettingsActivity.launch(getContext(), MenuTag.GRAPHICS, gameId);
|
||||
SettingsActivity.launch(getContext(), MenuTag.GRAPHICS, gameId, revision);
|
||||
break;
|
||||
case 4:
|
||||
SettingsActivity.launch(getContext(), MenuTag.GCPAD_TYPE, gameId);
|
||||
SettingsActivity.launch(getContext(), MenuTag.GCPAD_TYPE, gameId, revision);
|
||||
break;
|
||||
case 5:
|
||||
// Clear option for GC, Wii controls for else
|
||||
if (platform == Platform.GAMECUBE.toInt())
|
||||
clearGameSettings(gameId);
|
||||
else
|
||||
SettingsActivity.launch(getActivity(), MenuTag.WIIMOTE, gameId);
|
||||
SettingsActivity.launch(getActivity(), MenuTag.WIIMOTE, gameId, revision);
|
||||
break;
|
||||
case 6:
|
||||
clearGameSettings(gameId);
|
||||
|
@ -1,12 +1,17 @@
|
||||
package org.dolphinemu.dolphinemu.features.settings.model;
|
||||
|
||||
public class AdHocBooleanSetting extends AbstractLegacySetting implements AbstractBooleanSetting
|
||||
public class AdHocBooleanSetting implements AbstractBooleanSetting
|
||||
{
|
||||
private final String mFile;
|
||||
private final String mSection;
|
||||
private final String mKey;
|
||||
private final boolean mDefaultValue;
|
||||
|
||||
public AdHocBooleanSetting(String file, String section, String key, boolean defaultValue)
|
||||
{
|
||||
super(file, section, key);
|
||||
mFile = file;
|
||||
mSection = section;
|
||||
mKey = key;
|
||||
mDefaultValue = defaultValue;
|
||||
|
||||
if (!NativeConfig.isSettingSaveable(file, section, key))
|
||||
@ -18,40 +23,18 @@ public class AdHocBooleanSetting extends AbstractLegacySetting implements Abstra
|
||||
@Override
|
||||
public boolean delete(Settings settings)
|
||||
{
|
||||
if (!settings.isGameSpecific())
|
||||
{
|
||||
return NativeConfig.deleteKey(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
return settings.getSection(mFile, mSection).delete(mKey);
|
||||
}
|
||||
return NativeConfig.deleteKey(settings.getActiveLayer(), mFile, mSection, mKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(Settings settings)
|
||||
{
|
||||
if (!settings.isGameSpecific())
|
||||
{
|
||||
return NativeConfig.getBoolean(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey,
|
||||
mDefaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
return settings.getSection(mFile, mSection).getBoolean(mKey, mDefaultValue);
|
||||
}
|
||||
return NativeConfig.getBoolean(settings.getActiveLayer(), mFile, mSection, mKey, mDefaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoolean(Settings settings, boolean newValue)
|
||||
{
|
||||
if (!settings.isGameSpecific())
|
||||
{
|
||||
NativeConfig.setBoolean(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey, newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.getSection(mFile, mSection).setBoolean(mKey, newValue);
|
||||
}
|
||||
NativeConfig.setBoolean(settings.getActiveLayer(), mFile, mSection, mKey, newValue);
|
||||
}
|
||||
}
|
||||
|
@ -110,9 +110,9 @@ public enum BooleanSetting implements AbstractBooleanSetting
|
||||
@Override
|
||||
public boolean delete(Settings settings)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
return NativeConfig.deleteKey(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey);
|
||||
return NativeConfig.deleteKey(settings.getActiveLayer(), mFile, mSection, mKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -123,9 +123,9 @@ public enum BooleanSetting implements AbstractBooleanSetting
|
||||
@Override
|
||||
public boolean getBoolean(Settings settings)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
return NativeConfig.getBoolean(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey,
|
||||
return NativeConfig.getBoolean(settings.getActiveLayer(), mFile, mSection, mKey,
|
||||
mDefaultValue);
|
||||
}
|
||||
else
|
||||
@ -137,9 +137,9 @@ public enum BooleanSetting implements AbstractBooleanSetting
|
||||
@Override
|
||||
public void setBoolean(Settings settings, boolean newValue)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
NativeConfig.setBoolean(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey, newValue);
|
||||
NativeConfig.setBoolean(settings.getActiveLayer(), mFile, mSection, mKey, newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -23,9 +23,9 @@ public enum FloatSetting implements AbstractFloatSetting
|
||||
@Override
|
||||
public boolean delete(Settings settings)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
return NativeConfig.deleteKey(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey);
|
||||
return NativeConfig.deleteKey(settings.getActiveLayer(), mFile, mSection, mKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -36,10 +36,9 @@ public enum FloatSetting implements AbstractFloatSetting
|
||||
@Override
|
||||
public float getFloat(Settings settings)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
return NativeConfig.getFloat(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey,
|
||||
mDefaultValue);
|
||||
return NativeConfig.getFloat(settings.getActiveLayer(), mFile, mSection, mKey, mDefaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -50,9 +49,9 @@ public enum FloatSetting implements AbstractFloatSetting
|
||||
@Override
|
||||
public void setFloat(Settings settings, float newValue)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
NativeConfig.setFloat(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey, newValue);
|
||||
NativeConfig.setFloat(settings.getActiveLayer(), mFile, mSection, mKey, newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -50,9 +50,9 @@ public enum IntSetting implements AbstractIntSetting
|
||||
@Override
|
||||
public boolean delete(Settings settings)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
return NativeConfig.deleteKey(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey);
|
||||
return NativeConfig.deleteKey(settings.getActiveLayer(), mFile, mSection, mKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -63,10 +63,9 @@ public enum IntSetting implements AbstractIntSetting
|
||||
@Override
|
||||
public int getInt(Settings settings)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
return NativeConfig.getInt(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey,
|
||||
mDefaultValue);
|
||||
return NativeConfig.getInt(settings.getActiveLayer(), mFile, mSection, mKey, mDefaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -77,9 +76,9 @@ public enum IntSetting implements AbstractIntSetting
|
||||
@Override
|
||||
public void setInt(Settings settings, int newValue)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
NativeConfig.setInt(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey, newValue);
|
||||
NativeConfig.setInt(settings.getActiveLayer(), mFile, mSection, mKey, newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -7,6 +7,10 @@ public class NativeConfig
|
||||
|
||||
public static native boolean isSettingSaveable(String file, String section, String key);
|
||||
|
||||
public static native void loadGameInis(String gameId, int revision);
|
||||
|
||||
public static native void unloadGameInis();
|
||||
|
||||
public static native void save(int layer);
|
||||
|
||||
public static native boolean deleteKey(int layer, String file, String section, String key);
|
||||
|
@ -10,10 +10,11 @@ import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
|
||||
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
|
||||
import org.dolphinemu.dolphinemu.utils.IniFile;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Settings
|
||||
public class Settings implements Closeable
|
||||
{
|
||||
public static final String FILE_DOLPHIN = "Dolphin";
|
||||
public static final String FILE_GFX = "GFX";
|
||||
@ -48,7 +49,8 @@ public class Settings
|
||||
|
||||
public static final String GAME_SETTINGS_PLACEHOLDER_FILE_NAME = "";
|
||||
|
||||
private String gameId;
|
||||
private String mGameId;
|
||||
private int mRevision;
|
||||
|
||||
private static final String[] configFiles = new String[]{FILE_DOLPHIN, FILE_GFX, FILE_LOGGER,
|
||||
FILE_WIIMOTE};
|
||||
@ -80,7 +82,12 @@ public class Settings
|
||||
|
||||
public boolean isGameSpecific()
|
||||
{
|
||||
return !TextUtils.isEmpty(gameId);
|
||||
return !TextUtils.isEmpty(mGameId);
|
||||
}
|
||||
|
||||
public int getActiveLayer()
|
||||
{
|
||||
return isGameSpecific() ? NativeConfig.LAYER_LOCAL_GAME : NativeConfig.LAYER_BASE_OR_CURRENT;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
@ -98,7 +105,8 @@ public class Settings
|
||||
}
|
||||
else
|
||||
{
|
||||
loadCustomGameSettings(gameId, view);
|
||||
NativeConfig.loadGameInis(mGameId, mRevision);
|
||||
loadCustomGameSettings(mGameId, view);
|
||||
}
|
||||
|
||||
mLoadedRecursiveIsoPathsValue = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(this);
|
||||
@ -126,9 +134,10 @@ public class Settings
|
||||
SettingsFile.readWiimoteProfile(gameId, getGameSpecificFile(), padId);
|
||||
}
|
||||
|
||||
public void loadSettings(String gameId, SettingsActivityView view)
|
||||
public void loadSettings(String gameId, int revision, SettingsActivityView view)
|
||||
{
|
||||
this.gameId = gameId;
|
||||
mGameId = gameId;
|
||||
mRevision = revision;
|
||||
loadSettings(view);
|
||||
}
|
||||
|
||||
@ -163,9 +172,11 @@ public class Settings
|
||||
// custom game settings
|
||||
|
||||
if (context != null)
|
||||
Toast.makeText(context, "Saved settings for " + gameId, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(context, "Saved settings for " + mGameId, Toast.LENGTH_SHORT).show();
|
||||
|
||||
SettingsFile.saveCustomGameSettings(gameId, getGameSpecificFile());
|
||||
SettingsFile.saveCustomGameSettings(mGameId, getGameSpecificFile());
|
||||
|
||||
NativeConfig.save(NativeConfig.LAYER_LOCAL_GAME);
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,4 +213,13 @@ public class Settings
|
||||
|
||||
return getSection(Settings.FILE_DOLPHIN, SECTION_INI_INTERFACE).exists("ThemeName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
if (isGameSpecific())
|
||||
{
|
||||
NativeConfig.unloadGameInis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ public enum StringSetting implements AbstractStringSetting
|
||||
@Override
|
||||
public boolean delete(Settings settings)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
return NativeConfig.deleteKey(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey);
|
||||
return NativeConfig.deleteKey(settings.getActiveLayer(), mFile, mSection, mKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -49,9 +49,9 @@ public enum StringSetting implements AbstractStringSetting
|
||||
@Override
|
||||
public String getString(Settings settings)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
return NativeConfig.getString(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey,
|
||||
return NativeConfig.getString(settings.getActiveLayer(), mFile, mSection, mKey,
|
||||
mDefaultValue);
|
||||
}
|
||||
else
|
||||
@ -63,9 +63,9 @@ public enum StringSetting implements AbstractStringSetting
|
||||
@Override
|
||||
public void setString(Settings settings, String newValue)
|
||||
{
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey) && !settings.isGameSpecific())
|
||||
if (NativeConfig.isSettingSaveable(mFile, mSection, mKey))
|
||||
{
|
||||
NativeConfig.setString(NativeConfig.LAYER_BASE_OR_CURRENT, mFile, mSection, mKey, newValue);
|
||||
NativeConfig.setString(settings.getActiveLayer(), mFile, mSection, mKey, newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -26,16 +26,27 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
||||
{
|
||||
private static final String ARG_MENU_TAG = "menu_tag";
|
||||
private static final String ARG_GAME_ID = "game_id";
|
||||
private static final String ARG_REVISION = "revision";
|
||||
private static final String FRAGMENT_TAG = "settings";
|
||||
private SettingsActivityPresenter mPresenter;
|
||||
|
||||
private ProgressDialog dialog;
|
||||
|
||||
public static void launch(Context context, MenuTag menuTag, String gameId)
|
||||
public static void launch(Context context, MenuTag menuTag, String gameId, int revision)
|
||||
{
|
||||
Intent settings = new Intent(context, SettingsActivity.class);
|
||||
settings.putExtra(ARG_MENU_TAG, menuTag);
|
||||
settings.putExtra(ARG_GAME_ID, gameId);
|
||||
settings.putExtra(ARG_REVISION, revision);
|
||||
context.startActivity(settings);
|
||||
}
|
||||
|
||||
public static void launch(Context context, MenuTag menuTag)
|
||||
{
|
||||
Intent settings = new Intent(context, SettingsActivity.class);
|
||||
settings.putExtra(ARG_MENU_TAG, menuTag);
|
||||
settings.putExtra(ARG_GAME_ID, "");
|
||||
settings.putExtra(ARG_REVISION, 0);
|
||||
context.startActivity(settings);
|
||||
}
|
||||
|
||||
@ -57,10 +68,11 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
||||
|
||||
Intent launcher = getIntent();
|
||||
String gameID = launcher.getStringExtra(ARG_GAME_ID);
|
||||
int revision = launcher.getIntExtra(ARG_REVISION, 0);
|
||||
MenuTag menuTag = (MenuTag) launcher.getSerializableExtra(ARG_MENU_TAG);
|
||||
|
||||
mPresenter = new SettingsActivityPresenter(this, getSettings());
|
||||
mPresenter.onCreate(savedInstanceState, menuTag, gameID, getApplicationContext());
|
||||
mPresenter.onCreate(savedInstanceState, menuTag, gameID, revision, getApplicationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -95,17 +107,22 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
|
||||
|
||||
/**
|
||||
* If this is called, the user has left the settings screen (potentially through the
|
||||
* home button) and will expect their changes to be persisted. So we kick off an
|
||||
* IntentService which will do so on a background thread.
|
||||
* home button) and will expect their changes to be persisted.
|
||||
*/
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
super.onStop();
|
||||
|
||||
mPresenter.onStop(isFinishing());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
mPresenter.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showSettingsFragment(MenuTag menuTag, Bundle extras, boolean addToStack,
|
||||
String gameID)
|
||||
|
@ -24,6 +24,7 @@ public final class SettingsActivityPresenter
|
||||
|
||||
private MenuTag menuTag;
|
||||
private String gameId;
|
||||
private int revision;
|
||||
private Context context;
|
||||
|
||||
SettingsActivityPresenter(SettingsActivityView view, Settings settings)
|
||||
@ -32,15 +33,26 @@ public final class SettingsActivityPresenter
|
||||
mSettings = settings;
|
||||
}
|
||||
|
||||
public void onCreate(Bundle savedInstanceState, MenuTag menuTag, String gameId, Context context)
|
||||
public void onCreate(Bundle savedInstanceState, MenuTag menuTag, String gameId, int revision,
|
||||
Context context)
|
||||
{
|
||||
this.menuTag = menuTag;
|
||||
this.gameId = gameId;
|
||||
this.revision = revision;
|
||||
this.context = context;
|
||||
|
||||
mShouldSave = savedInstanceState != null && savedInstanceState.getBoolean(KEY_SHOULD_SAVE);
|
||||
}
|
||||
|
||||
public void onDestroy()
|
||||
{
|
||||
if (mSettings != null)
|
||||
{
|
||||
mSettings.close();
|
||||
mSettings = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void onStart()
|
||||
{
|
||||
prepareDolphinDirectoriesIfNeeded();
|
||||
@ -52,7 +64,7 @@ public final class SettingsActivityPresenter
|
||||
{
|
||||
if (!TextUtils.isEmpty(gameId))
|
||||
{
|
||||
mSettings.loadSettings(gameId, mView);
|
||||
mSettings.loadSettings(gameId, revision, mView);
|
||||
|
||||
if (mSettings.gameIniContainsJunk())
|
||||
{
|
||||
|
@ -81,9 +81,12 @@ public class GameFileCache
|
||||
*/
|
||||
public boolean scanLibrary(Context context)
|
||||
{
|
||||
Settings settings = new Settings();
|
||||
settings.loadSettings(null);
|
||||
boolean recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(settings);
|
||||
boolean recursiveScan;
|
||||
try (Settings settings = new Settings())
|
||||
{
|
||||
settings.loadSettings(null);
|
||||
recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(settings);
|
||||
}
|
||||
|
||||
removeNonExistentGameFolders(context);
|
||||
|
||||
|
@ -143,7 +143,7 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
||||
@Override
|
||||
public void launchSettingsActivity(MenuTag menuTag)
|
||||
{
|
||||
SettingsActivity.launch(this, menuTag, "");
|
||||
SettingsActivity.launch(this, menuTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -270,19 +270,23 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
||||
{
|
||||
super.onTabSelected(tab);
|
||||
|
||||
Settings settings = new Settings();
|
||||
settings.loadSettings(null);
|
||||
try (Settings settings = new Settings())
|
||||
{
|
||||
settings.loadSettings(null);
|
||||
|
||||
IntSetting.MAIN_LAST_PLATFORM_TAB.setInt(settings, tab.getPosition());
|
||||
IntSetting.MAIN_LAST_PLATFORM_TAB.setInt(settings, tab.getPosition());
|
||||
|
||||
// Context is set to null to avoid toasts
|
||||
settings.saveSettings(null, null);
|
||||
// Context is set to null to avoid toasts
|
||||
settings.saveSettings(null, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Settings settings = new Settings();
|
||||
settings.loadSettings(null);
|
||||
mViewPager.setCurrentItem(IntSetting.MAIN_LAST_PLATFORM_TAB.getInt(settings));
|
||||
try (Settings settings = new Settings())
|
||||
{
|
||||
settings.loadSettings(null);
|
||||
mViewPager.setCurrentItem(IntSetting.MAIN_LAST_PLATFORM_TAB.getInt(settings));
|
||||
}
|
||||
|
||||
showGames();
|
||||
GameFileCacheService.startLoad(this);
|
||||
|
@ -145,7 +145,7 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
||||
@Override
|
||||
public void launchSettingsActivity(MenuTag menuTag)
|
||||
{
|
||||
SettingsActivity.launch(this, menuTag, "");
|
||||
SettingsActivity.launch(this, menuTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,6 +30,10 @@ public class Analytics
|
||||
{
|
||||
showMessage(context, settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -56,6 +60,8 @@ public class Analytics
|
||||
|
||||
// Context is set to null to avoid toasts
|
||||
settings.saveSettings(null, null);
|
||||
|
||||
settings.close();
|
||||
}
|
||||
|
||||
public static void sendReport(String endpoint, byte[] data)
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/Config/Config.h"
|
||||
#include "Core/ConfigLoaders/GameConfigLoader.h"
|
||||
#include "Core/ConfigLoaders/IsSettingSaveable.h"
|
||||
#include "jni/AndroidCommon/AndroidCommon.h"
|
||||
|
||||
@ -85,6 +86,26 @@ Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_isSettingSav
|
||||
return static_cast<jboolean>(ConfigLoaders::IsSettingSaveable(location));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_loadGameInis(JNIEnv* env,
|
||||
jclass obj,
|
||||
jstring jGameId,
|
||||
jint jRevision)
|
||||
{
|
||||
const std::string game_id = GetJString(env, jGameId);
|
||||
const u16 revision = static_cast<u16>(jRevision);
|
||||
Config::AddLayer(ConfigLoaders::GenerateGlobalGameConfigLoader(game_id, revision));
|
||||
Config::AddLayer(ConfigLoaders::GenerateLocalGameConfigLoader(game_id, revision));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_unloadGameInis(JNIEnv* env,
|
||||
jclass obj)
|
||||
{
|
||||
Config::RemoveLayer(Config::LayerType::GlobalGame);
|
||||
Config::RemoveLayer(Config::LayerType::LocalGame);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_save(
|
||||
JNIEnv* env, jclass obj, jint layer)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user