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