diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java index 8f3a10b8af..86e75d55ec 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -335,6 +335,8 @@ public final class NativeLibrary public static native int DefaultCPUCore(); + public static native String GetDefaultGraphicsBackendName(); + public static native int GetMaxLogLevel(); public static native void ReloadConfig(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java index bb325639c9..dd66031531 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java @@ -33,7 +33,6 @@ import androidx.fragment.app.FragmentManager; import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; -import org.dolphinemu.dolphinemu.features.settings.model.Setting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile; import org.dolphinemu.dolphinemu.fragments.EmulationFragment; diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java index d7007e529e..b60713fb8b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java @@ -9,8 +9,8 @@ import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; import org.dolphinemu.dolphinemu.R; -import org.dolphinemu.dolphinemu.features.settings.model.Setting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; +import org.dolphinemu.dolphinemu.features.settings.model.StringSetting; import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity; import org.dolphinemu.dolphinemu.ui.platform.Platform; @@ -65,7 +65,7 @@ public class GamePropertiesDialog extends DialogFragment case 1: Settings settings = new Settings(); settings.loadSettings(null); - Setting.MAIN_DEFAULT_ISO.setString(settings, path); + StringSetting.MAIN_DEFAULT_ISO.setString(settings, path); settings.saveSettings(null, getContext()); break; case 2: diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractBooleanSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractBooleanSetting.java new file mode 100644 index 0000000000..3ac6ee3640 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractBooleanSetting.java @@ -0,0 +1,8 @@ +package org.dolphinemu.dolphinemu.features.settings.model; + +public interface AbstractBooleanSetting extends AbstractSetting +{ + boolean getBoolean(Settings settings); + + void setBoolean(Settings settings, boolean newValue); +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractFloatSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractFloatSetting.java new file mode 100644 index 0000000000..49b7c4e2ee --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractFloatSetting.java @@ -0,0 +1,8 @@ +package org.dolphinemu.dolphinemu.features.settings.model; + +public interface AbstractFloatSetting extends AbstractSetting +{ + float getFloat(Settings settings); + + void setFloat(Settings settings, float newValue); +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractIntSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractIntSetting.java new file mode 100644 index 0000000000..2d9411a297 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractIntSetting.java @@ -0,0 +1,8 @@ +package org.dolphinemu.dolphinemu.features.settings.model; + +public interface AbstractIntSetting extends AbstractSetting +{ + int getInt(Settings settings); + + void setInt(Settings settings, int newValue); +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractLegacySetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractLegacySetting.java new file mode 100644 index 0000000000..c10dd237a8 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractLegacySetting.java @@ -0,0 +1,21 @@ +package org.dolphinemu.dolphinemu.features.settings.model; + +public class AbstractLegacySetting implements AbstractSetting +{ + protected final String mFile; + protected final String mSection; + protected final String mKey; + + public AbstractLegacySetting(String file, String section, String key) + { + mFile = file; + mSection = section; + mKey = key; + } + + @Override + public boolean delete(Settings settings) + { + return settings.getSection(mFile, mSection).delete(mKey); + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractStringSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractStringSetting.java new file mode 100644 index 0000000000..efc557763b --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractStringSetting.java @@ -0,0 +1,8 @@ +package org.dolphinemu.dolphinemu.features.settings.model; + +public interface AbstractStringSetting extends AbstractSetting +{ + String getString(Settings settings); + + void setString(Settings settings, String newValue); +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java index 4ee266a031..0d3f853120 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java @@ -1,8 +1,127 @@ package org.dolphinemu.dolphinemu.features.settings.model; -public interface BooleanSetting extends AbstractSetting +public enum BooleanSetting implements AbstractBooleanSetting { - boolean getBoolean(Settings settings, boolean defaultValue); + // These entries have the same names and order as in C++, just for consistency. - void setBoolean(Settings settings, boolean newValue); + MAIN_DSP_HLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "DSPHLE", true), + MAIN_CPU_THREAD(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "CPUThread", true), + MAIN_OVERRIDE_REGION_SETTINGS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, + "OverrideRegionSettings", false), + MAIN_AUDIO_STRETCH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "AudioStretch", false), + MAIN_WII_SD_CARD(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "WiiSDCard", true), + MAIN_WIIMOTE_CONTINUOUS_SCANNING(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, + "WiimoteContinuousScanning", false), + MAIN_WIIMOTE_ENABLE_SPEAKER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, + "WiimoteEnableSpeaker", false), + MAIN_OVERCLOCK_ENABLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "OverclockEnable", false), + MAIN_AUTO_DISC_CHANGE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "AutoDiscChange", false), + MAIN_ALLOW_SD_WRITES(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "WiiSDCardAllowWrites", + true), + MAIN_ENABLE_SAVESTATES(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "EnableSaveStates", + false), + + MAIN_DSP_JIT(Settings.FILE_DOLPHIN, Settings.SECTION_INI_DSP, "EnableJIT", true), + + MAIN_USE_PANIC_HANDLERS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_INTERFACE, + "UsePanicHandlers", true), + MAIN_OSD_MESSAGES(Settings.FILE_DOLPHIN, Settings.SECTION_INI_INTERFACE, + "OnScreenDisplayMessages", true), + + MAIN_ANALYTICS_ENABLED(Settings.FILE_DOLPHIN, Settings.SECTION_ANALYTICS, "Enabled", false), + MAIN_ANALYTICS_PERMISSION_ASKED(Settings.FILE_DOLPHIN, Settings.SECTION_ANALYTICS, + "PermissionAsked", false), + + MAIN_RECURSIVE_ISO_PATHS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, + "RecursiveISOPaths", false), + + GFX_WIDESCREEN_HACK(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "wideScreenHack", false), + GFX_SHOW_FPS(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "ShowFPS", false), + GFX_ENABLE_GPU_TEXTURE_DECODING(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, + "EnableGPUTextureDecoding", false), + GFX_ENABLE_PIXEL_LIGHTING(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, + "EnablePixelLighting", false), + GFX_FAST_DEPTH_CALC(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "FastDepthCalc", true), + GFX_DISABLE_FOG(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "DisableFog", false), + GFX_BACKEND_MULTITHREADING(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, + "BackendMultithreading", false), + GFX_WAIT_FOR_SHADERS_BEFORE_STARTING(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, + "WaitForShadersBeforeStarting", false), + + GFX_ENHANCE_FORCE_FILTERING(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, + "ForceFiltering", false), + GFX_ENHANCE_FORCE_TRUE_COLOR(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, + "ForceTrueColor", true), + GFX_ENHANCE_DISABLE_COPY_FILTER(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, + "DisableCopyFilter", true), + GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, + "ArbitraryMipmapDetection", true), + + GFX_STEREO_SWAP_EYES(Settings.FILE_GFX, Settings.SECTION_STEREOSCOPY, "StereoSwapEyes", false), + + GFX_HACK_EFB_ACCESS_ENABLE(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "EFBAccessEnable", + true), + GFX_HACK_SKIP_EFB_COPY_TO_RAM(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, + "EFBToTextureEnable", true), + GFX_HACK_SKIP_XFB_COPY_TO_RAM(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, + "XFBToTextureEnable", true), + GFX_HACK_DEFER_EFB_COPIES(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "DeferEFBCopies", true), + GFX_HACK_IMMEDIATE_XFB(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "ImmediateXFBEnable", + false), + GFX_HACK_SKIP_DUPLICATE_XFBS(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "SkipDuplicateXFBs", + true), + GFX_HACK_COPY_EFB_SCALED(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "EFBScaledCopy", true), + GFX_HACK_EFB_EMULATE_FORMAT_CHANGES(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, + "EFBEmulateFormatChanges", false), + + LOGGER_WRITE_TO_FILE(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_OPTIONS, "WriteToFile", false), + + // These settings are not yet in the new config system in C++ - please move them once they are + + MAIN_JIT_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitOff", false), + MAIN_JIT_LOAD_STORE_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitLoadStoreOff", false), + MAIN_JIT_LOAD_STORE_FLOATING_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, + "JitLoadStoreFloatingOff", false), + MAIN_JIT_LOAD_STORE_PAIRED_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, + "JitLoadStorePairedOff", false), + MAIN_JIT_FLOATING_POINT_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitFloatingPointOff", + false), + MAIN_JIT_INTEGER_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitIntegerOff", false), + MAIN_JIT_PAIRED_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitPairedOff", false), + MAIN_JIT_SYSTEM_REGISTERS_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, + "JitSystemRegistersOff", false), + MAIN_JIT_BRANCH_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitBranchOff", false), + MAIN_JIT_REGISTER_CACHE_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitRegisterCacheOff", + false); + + private final String mFile; + private final String mSection; + private final String mKey; + private final boolean mDefaultValue; + + BooleanSetting(String file, String section, String key, boolean defaultValue) + { + mFile = file; + mSection = section; + mKey = key; + mDefaultValue = defaultValue; + } + + @Override + public boolean delete(Settings settings) + { + return settings.getSection(mFile, mSection).delete(mKey); + } + + @Override + public boolean getBoolean(Settings settings) + { + return settings.getSection(mFile, mSection).getBoolean(mKey, mDefaultValue); + } + + @Override + public void setBoolean(Settings settings, boolean newValue) + { + settings.getSection(mFile, mSection).setBoolean(mKey, newValue); + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.java index b8ed91a4b9..2844074da3 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/FloatSetting.java @@ -1,8 +1,40 @@ package org.dolphinemu.dolphinemu.features.settings.model; -public interface FloatSetting extends AbstractSetting +public enum FloatSetting implements AbstractFloatSetting { - float getFloat(Settings settings, float defaultValue); + // These entries have the same names and order as in C++, just for consistency. - void setFloat(Settings settings, float newValue); + MAIN_EMULATION_SPEED(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "EmulationSpeed", 1.0f), + MAIN_OVERCLOCK(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "Overclock", 1.0f); + + private final String mFile; + private final String mSection; + private final String mKey; + private final float mDefaultValue; + + FloatSetting(String file, String section, String key, float defaultValue) + { + mFile = file; + mSection = section; + mKey = key; + mDefaultValue = defaultValue; + } + + @Override + public boolean delete(Settings settings) + { + return settings.getSection(mFile, mSection).delete(mKey); + } + + @Override + public float getFloat(Settings settings) + { + return settings.getSection(mFile, mSection).getFloat(mKey, mDefaultValue); + } + + @Override + public void setFloat(Settings settings, float newValue) + { + settings.getSection(mFile, mSection).setFloat(mKey, newValue); + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java index 14182df6c3..09ba84f118 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java @@ -1,8 +1,67 @@ package org.dolphinemu.dolphinemu.features.settings.model; -public interface IntSetting extends AbstractSetting -{ - int getInt(Settings settings, int defaultValue); +import org.dolphinemu.dolphinemu.NativeLibrary; - void setInt(Settings settings, int newValue); +public enum IntSetting implements AbstractIntSetting +{ + // These entries have the same names and order as in C++, just for consistency. + + MAIN_CPU_CORE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "CPUCore", + NativeLibrary.DefaultCPUCore()), + MAIN_GC_LANGUAGE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SelectedLanguage", 0), + MAIN_SLOT_A(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SlotA", 8), + MAIN_SLOT_B(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SlotB", 255), + + MAIN_AUDIO_VOLUME(Settings.FILE_DOLPHIN, Settings.SECTION_INI_DSP, "Volume", 100), + + MAIN_LAST_PLATFORM_TAB(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "LastPlatformTab", 0), + + GFX_ASPECT_RATIO(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "AspectRatio", 0), + GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, + "SafeTextureCacheColorSamples", 128), + GFX_MSAA(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "MSAA", 1), + GFX_EFB_SCALE(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "InternalResolution", 1), + GFX_SHADER_COMPILATION_MODE(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, + "ShaderCompilationMode", 0), + + GFX_ENHANCE_MAX_ANISOTROPY(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, "MaxAnisotropy", + 0), + + GFX_STEREO_MODE(Settings.FILE_GFX, Settings.SECTION_STEREOSCOPY, "StereoMode", 0), + GFX_STEREO_DEPTH(Settings.FILE_GFX, Settings.SECTION_STEREOSCOPY, "StereoDepth", 20), + GFX_STEREO_CONVERGENCE_PERCENTAGE(Settings.FILE_GFX, Settings.SECTION_STEREOSCOPY, + "StereoConvergencePercentage", 100), + + LOGGER_VERBOSITY(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_OPTIONS, "Verbosity", 1); + + private final String mFile; + private final String mSection; + private final String mKey; + private final int mDefaultValue; + + IntSetting(String file, String section, String key, int defaultValue) + { + mFile = file; + mSection = section; + mKey = key; + mDefaultValue = defaultValue; + } + + @Override + public boolean delete(Settings settings) + { + return settings.getSection(mFile, mSection).delete(mKey); + } + + @Override + public int getInt(Settings settings) + { + return settings.getSection(mFile, mSection).getInt(mKey, mDefaultValue); + } + + @Override + public void setInt(Settings settings, int newValue) + { + settings.getSection(mFile, mSection).setInt(mKey, newValue); + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyBooleanSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyBooleanSetting.java new file mode 100644 index 0000000000..c2f4a8895d --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyBooleanSetting.java @@ -0,0 +1,24 @@ +package org.dolphinemu.dolphinemu.features.settings.model; + +public class LegacyBooleanSetting extends AbstractLegacySetting implements AbstractBooleanSetting +{ + private final boolean mDefaultValue; + + public LegacyBooleanSetting(String file, String section, String key, boolean defaultValue) + { + super(file, section, key); + mDefaultValue = defaultValue; + } + + @Override + public boolean getBoolean(Settings settings) + { + return settings.getSection(mFile, mSection).getBoolean(mKey, mDefaultValue); + } + + @Override + public void setBoolean(Settings settings, boolean newValue) + { + settings.getSection(mFile, mSection).setBoolean(mKey, newValue); + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyFloatSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyFloatSetting.java new file mode 100644 index 0000000000..fb4858ceea --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyFloatSetting.java @@ -0,0 +1,24 @@ +package org.dolphinemu.dolphinemu.features.settings.model; + +public class LegacyFloatSetting extends AbstractLegacySetting implements AbstractFloatSetting +{ + private final float mDefaultValue; + + public LegacyFloatSetting(String file, String section, String key, float defaultValue) + { + super(file, section, key); + mDefaultValue = defaultValue; + } + + @Override + public float getFloat(Settings settings) + { + return settings.getSection(mFile, mSection).getFloat(mKey, mDefaultValue); + } + + @Override + public void setFloat(Settings settings, float newValue) + { + settings.getSection(mFile, mSection).setFloat(mKey, newValue); + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyIntSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyIntSetting.java new file mode 100644 index 0000000000..7d52660efe --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyIntSetting.java @@ -0,0 +1,24 @@ +package org.dolphinemu.dolphinemu.features.settings.model; + +public class LegacyIntSetting extends AbstractLegacySetting implements AbstractIntSetting +{ + private final int mDefaultValue; + + public LegacyIntSetting(String file, String section, String key, int defaultValue) + { + super(file, section, key); + mDefaultValue = defaultValue; + } + + @Override + public int getInt(Settings settings) + { + return settings.getSection(mFile, mSection).getInt(mKey, mDefaultValue); + } + + @Override + public void setInt(Settings settings, int newValue) + { + settings.getSection(mFile, mSection).setInt(mKey, newValue); + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacySetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacySetting.java deleted file mode 100644 index a04acc47f6..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacySetting.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.dolphinemu.dolphinemu.features.settings.model; - -public class LegacySetting implements StringSetting, BooleanSetting, IntSetting, FloatSetting -{ - private final String mFile; - private final String mSection; - private final String mKey; - - public LegacySetting(String file, String section, String key) - { - mFile = file; - mSection = section; - mKey = key; - } - - @Override - public boolean delete(Settings settings) - { - return settings.getSection(mFile, mSection).delete(mKey); - } - - @Override - public String getString(Settings settings, String defaultValue) - { - return settings.getSection(mFile, mSection).getString(mKey, defaultValue); - } - - @Override - public boolean getBoolean(Settings settings, boolean defaultValue) - { - return settings.getSection(mFile, mSection).getBoolean(mKey, defaultValue); - } - - @Override - public int getInt(Settings settings, int defaultValue) - { - return settings.getSection(mFile, mSection).getInt(mKey, defaultValue); - } - - @Override - public float getFloat(Settings settings, float defaultValue) - { - return settings.getSection(mFile, mSection).getFloat(mKey, defaultValue); - } - - @Override - public void setString(Settings settings, String newValue) - { - settings.getSection(mFile, mSection).setString(mKey, newValue); - } - - @Override - public void setBoolean(Settings settings, boolean newValue) - { - settings.getSection(mFile, mSection).setBoolean(mKey, newValue); - } - - @Override - public void setInt(Settings settings, int newValue) - { - settings.getSection(mFile, mSection).setInt(mKey, newValue); - } - - @Override - public void setFloat(Settings settings, float newValue) - { - settings.getSection(mFile, mSection).setFloat(mKey, newValue); - } -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyStringSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyStringSetting.java new file mode 100644 index 0000000000..8ada455cea --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyStringSetting.java @@ -0,0 +1,24 @@ +package org.dolphinemu.dolphinemu.features.settings.model; + +public class LegacyStringSetting extends AbstractLegacySetting implements AbstractStringSetting +{ + private final String mDefaultValue; + + public LegacyStringSetting(String file, String section, String key, String defaultValue) + { + super(file, section, key); + mDefaultValue = defaultValue; + } + + @Override + public String getString(Settings settings) + { + return settings.getSection(mFile, mSection).getString(mKey, mDefaultValue); + } + + @Override + public void setString(Settings settings, String newValue) + { + settings.getSection(mFile, mSection).setString(mKey, newValue); + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Setting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Setting.java deleted file mode 100644 index a16ea015ee..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Setting.java +++ /dev/null @@ -1,186 +0,0 @@ -package org.dolphinemu.dolphinemu.features.settings.model; - -public enum Setting implements StringSetting, BooleanSetting, IntSetting, FloatSetting -{ - // These entries have the same names and order as in C++, just for consistency. - - MAIN_CPU_CORE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "CPUCore"), - MAIN_DSP_HLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "DSPHLE"), - MAIN_CPU_THREAD(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "CPUThread"), - MAIN_DEFAULT_ISO(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "DefaultISO"), - MAIN_GC_LANGUAGE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SelectedLanguage"), - MAIN_OVERRIDE_REGION_SETTINGS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, - "OverrideRegionSettings"), - MAIN_AUDIO_STRETCH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "AudioStretch"), - MAIN_SLOT_A(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SlotA"), - MAIN_SLOT_B(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "SlotB"), - MAIN_WII_SD_CARD(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "WiiSDCard"), - MAIN_WIIMOTE_CONTINUOUS_SCANNING(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, - "WiimoteContinuousScanning"), - MAIN_WIIMOTE_ENABLE_SPEAKER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, - "WiimoteEnableSpeaker"), - MAIN_EMULATION_SPEED(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "EmulationSpeed"), - MAIN_OVERCLOCK(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "Overclock"), - MAIN_OVERCLOCK_ENABLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "OverclockEnable"), - MAIN_GFX_BACKEND(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "GFXBackend"), - MAIN_AUTO_DISC_CHANGE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "AutoDiscChange"), - MAIN_ALLOW_SD_WRITES(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "WiiSDCardAllowWrites"), - MAIN_ENABLE_SAVESTATES(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "EnableSaveStates"), - - MAIN_DSP_JIT(Settings.FILE_DOLPHIN, Settings.SECTION_INI_DSP, "EnableJIT"), - MAIN_AUDIO_VOLUME(Settings.FILE_DOLPHIN, Settings.SECTION_INI_DSP, "Volume"), - - MAIN_DUMP_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "DumpPath"), - MAIN_LOAD_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "LoadPath"), - MAIN_RESOURCEPACK_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "ResourcePackPath"), - MAIN_FS_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "NANDRootPath"), - MAIN_SD_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "WiiSDCardPath"), - - MAIN_USE_PANIC_HANDLERS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_INTERFACE, - "UsePanicHandlers"), - MAIN_OSD_MESSAGES(Settings.FILE_DOLPHIN, Settings.SECTION_INI_INTERFACE, - "OnScreenDisplayMessages"), - - MAIN_ANALYTICS_ENABLED(Settings.FILE_DOLPHIN, Settings.SECTION_ANALYTICS, "Enabled"), - MAIN_ANALYTICS_PERMISSION_ASKED(Settings.FILE_DOLPHIN, Settings.SECTION_ANALYTICS, - "PermissionAsked"), - - MAIN_RECURSIVE_ISO_PATHS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, - "RecursiveISOPaths"), - - MAIN_LAST_PLATFORM_TAB(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "LastPlatformTab"), - - GFX_WIDESCREEN_HACK(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "wideScreenHack"), - GFX_ASPECT_RATIO(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "AspectRatio"), - GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, - "SafeTextureCacheColorSamples"), - GFX_SHOW_FPS(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "ShowFPS"), - GFX_ENABLE_GPU_TEXTURE_DECODING(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, - "EnableGPUTextureDecoding"), - GFX_ENABLE_PIXEL_LIGHTING(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, - "EnablePixelLighting"), - GFX_FAST_DEPTH_CALC(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "FastDepthCalc"), - GFX_MSAA(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "MSAA"), - GFX_EFB_SCALE(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "InternalResolution"), - GFX_DISABLE_FOG(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, "DisableFog"), - GFX_BACKEND_MULTITHREADING(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, - "BackendMultithreading"), - GFX_WAIT_FOR_SHADERS_BEFORE_STARTING(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, - "WaitForShadersBeforeStarting"), - GFX_SHADER_COMPILATION_MODE(Settings.FILE_GFX, Settings.SECTION_GFX_SETTINGS, - "ShaderCompilationMode"), - - GFX_ENHANCE_FORCE_FILTERING(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, - "ForceFiltering"), - GFX_ENHANCE_MAX_ANISOTROPY(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, "MaxAnisotropy"), - GFX_ENHANCE_POST_SHADER(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, - "PostProcessingShader"), - GFX_ENHANCE_FORCE_TRUE_COLOR(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, - "ForceTrueColor"), - GFX_ENHANCE_DISABLE_COPY_FILTER(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, - "DisableCopyFilter"), - GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, - "ArbitraryMipmapDetection"), - - GFX_STEREO_MODE(Settings.FILE_GFX, Settings.SECTION_STEREOSCOPY, "StereoMode"), - GFX_STEREO_DEPTH(Settings.FILE_GFX, Settings.SECTION_STEREOSCOPY, "StereoDepth"), - GFX_STEREO_CONVERGENCE_PERCENTAGE(Settings.FILE_GFX, Settings.SECTION_STEREOSCOPY, - "StereoConvergencePercentage"), - GFX_STEREO_SWAP_EYES(Settings.FILE_GFX, Settings.SECTION_STEREOSCOPY, "StereoSwapEyes"), - - GFX_HACK_EFB_ACCESS_ENABLE(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "EFBAccessEnable"), - GFX_HACK_SKIP_EFB_COPY_TO_RAM(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, - "EFBToTextureEnable"), - GFX_HACK_SKIP_XFB_COPY_TO_RAM(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, - "XFBToTextureEnable"), - GFX_HACK_DEFER_EFB_COPIES(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "DeferEFBCopies"), - GFX_HACK_IMMEDIATE_XFB(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "ImmediateXFBEnable"), - GFX_HACK_SKIP_DUPLICATE_XFBS(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "SkipDuplicateXFBs"), - GFX_HACK_COPY_EFB_SCALED(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "EFBScaledCopy"), - GFX_HACK_EFB_EMULATE_FORMAT_CHANGES(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, - "EFBEmulateFormatChanges"), - - LOGGER_WRITE_TO_FILE(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_OPTIONS, "WriteToFile"), - LOGGER_VERBOSITY(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_OPTIONS, "Verbosity"), - - // These settings are not yet in the new config system in C++ - please move them once they are - - MAIN_JIT_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitOff"), - MAIN_JIT_LOAD_STORE_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitLoadStoreOff"), - MAIN_JIT_LOAD_STORE_FLOATING_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, - "JitLoadStoreFloatingOff"), - MAIN_JIT_LOAD_STORE_PAIRED_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, - "JitLoadStorePairedOff"), - MAIN_JIT_FLOATING_POINT_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitFloatingPointOff"), - MAIN_JIT_INTEGER_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitIntegerOff"), - MAIN_JIT_PAIRED_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitPairedOff"), - MAIN_JIT_SYSTEM_REGISTERS_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, - "JitSystemRegistersOff"), - MAIN_JIT_BRANCH_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitBranchOff"), - MAIN_JIT_REGISTER_CACHE_OFF(Settings.FILE_DOLPHIN, Settings.SECTION_DEBUG, "JitRegisterCacheOff"); - - private final String mFile; - private final String mSection; - private final String mKey; - - Setting(String file, String section, String key) - { - mFile = file; - mSection = section; - mKey = key; - } - - @Override - public boolean delete(Settings settings) - { - return settings.getSection(mFile, mSection).delete(mKey); - } - - @Override - public String getString(Settings settings, String defaultValue) - { - return settings.getSection(mFile, mSection).getString(mKey, defaultValue); - } - - @Override - public boolean getBoolean(Settings settings, boolean defaultValue) - { - return settings.getSection(mFile, mSection).getBoolean(mKey, defaultValue); - } - - @Override - public int getInt(Settings settings, int defaultValue) - { - return settings.getSection(mFile, mSection).getInt(mKey, defaultValue); - } - - @Override - public float getFloat(Settings settings, float defaultValue) - { - return settings.getSection(mFile, mSection).getFloat(mKey, defaultValue); - } - - @Override - public void setString(Settings settings, String newValue) - { - settings.getSection(mFile, mSection).setString(mKey, newValue); - } - - @Override - public void setBoolean(Settings settings, boolean newValue) - { - settings.getSection(mFile, mSection).setBoolean(mKey, newValue); - } - - @Override - public void setInt(Settings settings, int newValue) - { - settings.getSection(mFile, mSection).setInt(mKey, newValue); - } - - @Override - public void setFloat(Settings settings, float newValue) - { - settings.getSection(mFile, mSection).setFloat(mKey, newValue); - } -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java index d0803f67d0..94dce9fcd0 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/Settings.java @@ -96,7 +96,7 @@ public class Settings loadCustomGameSettings(gameId, view); } - mLoadedRecursiveIsoPathsValue = Setting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(this, false); + mLoadedRecursiveIsoPathsValue = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(this); } private void loadDolphinSettings(SettingsActivityView view) @@ -145,7 +145,7 @@ public class Settings NativeLibrary.ReloadLoggerConfig(); NativeLibrary.UpdateGCAdapterScanThread(); - if (mLoadedRecursiveIsoPathsValue != Setting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(this, false)) + if (mLoadedRecursiveIsoPathsValue != BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(this)) { // Refresh game library GameFileCacheService.startRescan(context); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/StringSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/StringSetting.java index ee710ad7e5..627be71eda 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/StringSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/StringSetting.java @@ -1,8 +1,53 @@ package org.dolphinemu.dolphinemu.features.settings.model; -public interface StringSetting extends AbstractSetting -{ - String getString(Settings settings, String defaultValue); +import org.dolphinemu.dolphinemu.NativeLibrary; - void setString(Settings settings, String newValue); +public enum StringSetting implements AbstractStringSetting +{ + // These entries have the same names and order as in C++, just for consistency. + + MAIN_DEFAULT_ISO(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "DefaultISO", ""), + MAIN_GFX_BACKEND(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, "GFXBackend", + NativeLibrary.GetDefaultGraphicsBackendName()), + + MAIN_DUMP_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "DumpPath", ""), + MAIN_LOAD_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "LoadPath", ""), + MAIN_RESOURCEPACK_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "ResourcePackPath", + ""), + MAIN_FS_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "NANDRootPath", ""), + MAIN_SD_PATH(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL, "WiiSDCardPath", ""), + + GFX_ENHANCE_POST_SHADER(Settings.FILE_GFX, Settings.SECTION_GFX_ENHANCEMENTS, + "PostProcessingShader", ""); + + private final String mFile; + private final String mSection; + private final String mKey; + private final String mDefaultValue; + + StringSetting(String file, String section, String key, String defaultValue) + { + mFile = file; + mSection = section; + mKey = key; + mDefaultValue = defaultValue; + } + + @Override + public boolean delete(Settings settings) + { + return settings.getSection(mFile, mSection).delete(mKey); + } + + @Override + public String getString(Settings settings) + { + return settings.getSection(mFile, mSection).getString(mKey, mDefaultValue); + } + + @Override + public void setString(Settings settings, String newValue) + { + settings.getSection(mFile, mSection).setString(mKey, newValue); + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/CheckBoxSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/CheckBoxSetting.java index 5f8ed11951..b03ecb4b22 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/CheckBoxSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/CheckBoxSetting.java @@ -1,24 +1,21 @@ package org.dolphinemu.dolphinemu.features.settings.model.view; -import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; +import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; public class CheckBoxSetting extends SettingsItem { - protected BooleanSetting mSetting; - protected boolean mDefaultValue; + protected AbstractBooleanSetting mSetting; - public CheckBoxSetting(BooleanSetting setting, int titleId, int descriptionId, - boolean defaultValue) + public CheckBoxSetting(AbstractBooleanSetting setting, int titleId, int descriptionId) { super(titleId, descriptionId); mSetting = setting; - mDefaultValue = defaultValue; } public boolean isChecked(Settings settings) { - return mSetting.getBoolean(settings, mDefaultValue); + return mSetting.getBoolean(settings); } public void setChecked(Settings settings, boolean checked) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FilePicker.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FilePicker.java index d6c2da5319..811f552a46 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FilePicker.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FilePicker.java @@ -1,26 +1,23 @@ package org.dolphinemu.dolphinemu.features.settings.model.view; +import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; -import org.dolphinemu.dolphinemu.features.settings.model.StringSetting; public final class FilePicker extends SettingsItem { - private StringSetting mSetting; - private String mDefaultValue; + private AbstractStringSetting mSetting; private int mRequestType; - public FilePicker(StringSetting setting, int titleId, int descriptionId, - String defaultVault, int requestType) + public FilePicker(AbstractStringSetting setting, int titleId, int descriptionId, int requestType) { super(titleId, descriptionId); mSetting = setting; - mDefaultValue = defaultVault; mRequestType = requestType; } public String getSelectedValue(Settings settings) { - return mSetting.getString(settings, mDefaultValue); + return mSetting.getString(settings); } public void setSelectedValue(Settings settings, String selection) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FloatSliderSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FloatSliderSetting.java index 3c736c376f..6e750957d2 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FloatSliderSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/FloatSliderSetting.java @@ -1,24 +1,22 @@ package org.dolphinemu.dolphinemu.features.settings.model.view; -import org.dolphinemu.dolphinemu.features.settings.model.FloatSetting; +import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; public class FloatSliderSetting extends SliderSetting { - protected FloatSetting mSetting; - protected float mDefaultValue; + protected AbstractFloatSetting mSetting; - public FloatSliderSetting(FloatSetting setting, int titleId, int descriptionId, int max, - String units, float defaultValue) + public FloatSliderSetting(AbstractFloatSetting setting, int titleId, int descriptionId, int max, + String units) { super(titleId, descriptionId, max, units); mSetting = setting; - mDefaultValue = defaultValue; } public int getSelectedValue(Settings settings) { - return Math.round(mSetting.getFloat(settings, mDefaultValue)); + return Math.round(mSetting.getFloat(settings)); } public void setSelectedValue(Settings settings, float selection) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/IntSliderSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/IntSliderSetting.java index eab1d4b54a..c731286205 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/IntSliderSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/IntSliderSetting.java @@ -1,24 +1,22 @@ package org.dolphinemu.dolphinemu.features.settings.model.view; -import org.dolphinemu.dolphinemu.features.settings.model.IntSetting; +import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; public final class IntSliderSetting extends SliderSetting { - private IntSetting mSetting; - private int mDefaultValue; + private AbstractIntSetting mSetting; - public IntSliderSetting(IntSetting setting, int titleId, int descriptionId, int max, - String units, int defaultValue) + public IntSliderSetting(AbstractIntSetting setting, int titleId, int descriptionId, int max, + String units) { super(titleId, descriptionId, max, units); mSetting = setting; - mDefaultValue = defaultValue; } public int getSelectedValue(Settings settings) { - return mSetting.getInt(settings, mDefaultValue); + return mSetting.getInt(settings); } public void setSelectedValue(Settings settings, int selection) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InvertedCheckBoxSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InvertedCheckBoxSetting.java index 9e5b9f08eb..1cf37aa0f1 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InvertedCheckBoxSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InvertedCheckBoxSetting.java @@ -1,20 +1,20 @@ package org.dolphinemu.dolphinemu.features.settings.model.view; -import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; +import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; public final class InvertedCheckBoxSetting extends CheckBoxSetting { - public InvertedCheckBoxSetting(BooleanSetting setting, int titleId, - int descriptionId, boolean defaultValue) + public InvertedCheckBoxSetting(AbstractBooleanSetting setting, int titleId, + int descriptionId) { - super(setting, titleId, descriptionId, !defaultValue); + super(setting, titleId, descriptionId); } @Override public boolean isChecked(Settings settings) { - return !mSetting.getBoolean(settings, mDefaultValue); + return !mSetting.getBoolean(settings); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/LogCheckBoxSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/LogCheckBoxSetting.java index 6bd9fccdda..0f046b40e8 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/LogCheckBoxSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/LogCheckBoxSetting.java @@ -1,17 +1,16 @@ package org.dolphinemu.dolphinemu.features.settings.model.view; -import org.dolphinemu.dolphinemu.features.settings.model.LegacySetting; +import org.dolphinemu.dolphinemu.features.settings.model.LegacyBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; public class LogCheckBoxSetting extends CheckBoxSetting { String mKey; - public LogCheckBoxSetting(String key, int titleId, int descriptionId, - boolean defaultValue) + public LogCheckBoxSetting(String key, int titleId, int descriptionId) { - super(new LegacySetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, key), titleId, - descriptionId, defaultValue); + super(new LegacyBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, key, false), + titleId, descriptionId); mKey = key; } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.java index 14b5eaf459..a0294d4478 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.java @@ -1,20 +1,20 @@ package org.dolphinemu.dolphinemu.features.settings.model.view; -import org.dolphinemu.dolphinemu.features.settings.model.FloatSetting; +import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; public final class PercentSliderSetting extends FloatSliderSetting { - public PercentSliderSetting(FloatSetting setting, int titleId, int descriptionId, int max, - String units, float defaultValue) + public PercentSliderSetting(AbstractFloatSetting setting, int titleId, int descriptionId, int max, + String units) { - super(setting, titleId, descriptionId, max, units, defaultValue / 100); + super(setting, titleId, descriptionId, max, units); } @Override public int getSelectedValue(Settings settings) { - return Math.round(mSetting.getFloat(settings, mDefaultValue) * 100); + return Math.round(mSetting.getFloat(settings) * 100); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SingleChoiceSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SingleChoiceSetting.java index 8dac68e536..f42343002d 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SingleChoiceSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SingleChoiceSetting.java @@ -1,33 +1,31 @@ package org.dolphinemu.dolphinemu.features.settings.model.view; -import org.dolphinemu.dolphinemu.features.settings.model.IntSetting; +import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag; public final class SingleChoiceSetting extends SettingsItem { - private IntSetting mSetting; - private int mDefaultValue; + private AbstractIntSetting mSetting; private int mChoicesId; private int mValuesId; private MenuTag menuTag; - public SingleChoiceSetting(IntSetting setting, int titleId, int descriptionId, int choicesId, - int valuesId, int defaultValue, MenuTag menuTag) + public SingleChoiceSetting(AbstractIntSetting setting, int titleId, int descriptionId, + int choicesId, int valuesId, MenuTag menuTag) { super(titleId, descriptionId); mSetting = setting; - mDefaultValue = defaultValue; mValuesId = valuesId; mChoicesId = choicesId; this.menuTag = menuTag; } - public SingleChoiceSetting(IntSetting setting, int titleId, int descriptionId, int choicesId, - int valuesId, int defaultValue) + public SingleChoiceSetting(AbstractIntSetting setting, int titleId, int descriptionId, + int choicesId, int valuesId) { - this(setting, titleId, descriptionId, choicesId, valuesId, defaultValue, null); + this(setting, titleId, descriptionId, choicesId, valuesId, null); } public int getChoicesId() @@ -42,7 +40,7 @@ public final class SingleChoiceSetting extends SettingsItem public int getSelectedValue(Settings settings) { - return mSetting.getInt(settings, mDefaultValue); + return mSetting.getInt(settings); } public MenuTag getMenuTag() diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SingleChoiceSettingDynamicDescriptions.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SingleChoiceSettingDynamicDescriptions.java index bc1cf1ab65..d39e463d26 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SingleChoiceSettingDynamicDescriptions.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SingleChoiceSettingDynamicDescriptions.java @@ -1,13 +1,12 @@ package org.dolphinemu.dolphinemu.features.settings.model.view; -import org.dolphinemu.dolphinemu.features.settings.model.IntSetting; +import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag; public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem { - private IntSetting mSetting; - private int mDefaultValue; + private AbstractIntSetting mSetting; private int mChoicesId; private int mValuesId; @@ -15,13 +14,12 @@ public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem private int mDescriptionValuesId; private MenuTag menuTag; - public SingleChoiceSettingDynamicDescriptions(IntSetting setting, int titleId, int descriptionId, - int choicesId, int valuesId, int descriptionChoicesId, int descriptionValuesId, - int defaultValue, MenuTag menuTag) + public SingleChoiceSettingDynamicDescriptions(AbstractIntSetting setting, int titleId, + int descriptionId, int choicesId, int valuesId, int descriptionChoicesId, + int descriptionValuesId, MenuTag menuTag) { super(titleId, descriptionId); mSetting = setting; - mDefaultValue = defaultValue; mValuesId = valuesId; mChoicesId = choicesId; mDescriptionChoicesId = descriptionChoicesId; @@ -29,12 +27,12 @@ public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem this.menuTag = menuTag; } - public SingleChoiceSettingDynamicDescriptions(IntSetting setting, int titleId, int descriptionId, - int choicesId, int valuesId, int descriptionChoicesId, int descriptionValuesId, - int defaultValue) + public SingleChoiceSettingDynamicDescriptions(AbstractIntSetting setting, int titleId, + int descriptionId, int choicesId, int valuesId, int descriptionChoicesId, + int descriptionValuesId) { this(setting, titleId, descriptionId, choicesId, valuesId, descriptionChoicesId, - descriptionValuesId, defaultValue, null); + descriptionValuesId, null); } public int getChoicesId() @@ -59,7 +57,7 @@ public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem public int getSelectedValue(Settings settings) { - return mSetting.getInt(settings, mDefaultValue); + return mSetting.getInt(settings); } public MenuTag getMenuTag() diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/StringSingleChoiceSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/StringSingleChoiceSetting.java index 97ce6d00a2..d1279aa4fd 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/StringSingleChoiceSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/StringSingleChoiceSetting.java @@ -1,52 +1,48 @@ package org.dolphinemu.dolphinemu.features.settings.model.view; import org.dolphinemu.dolphinemu.DolphinApplication; +import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; -import org.dolphinemu.dolphinemu.features.settings.model.StringSetting; import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag; public class StringSingleChoiceSetting extends SettingsItem { - private StringSetting mSetting; - private String mDefaultValue; + private AbstractStringSetting mSetting; private String[] mChoicesId; private String[] mValuesId; private MenuTag mMenuTag; - public StringSingleChoiceSetting(StringSetting setting, int titleId, - int descriptionId, String[] choicesId, String[] valuesId, String defaultValue, - MenuTag menuTag) + public StringSingleChoiceSetting(AbstractStringSetting setting, int titleId, + int descriptionId, String[] choicesId, String[] valuesId, MenuTag menuTag) { super(titleId, descriptionId); mSetting = setting; mChoicesId = choicesId; mValuesId = valuesId; - mDefaultValue = defaultValue; mMenuTag = menuTag; } - public StringSingleChoiceSetting(StringSetting setting, int titleId, - int descriptionId, String[] choicesId, String[] valuesId, String defaultValue) + public StringSingleChoiceSetting(AbstractStringSetting setting, int titleId, + int descriptionId, String[] choicesId, String[] valuesId) { - this(setting, titleId, descriptionId, choicesId, valuesId, defaultValue, null); + this(setting, titleId, descriptionId, choicesId, valuesId, null); } - public StringSingleChoiceSetting(StringSetting setting, int titleId, - int descriptionId, int choicesId, int valuesId, String defaultValue, MenuTag menuTag) + public StringSingleChoiceSetting(AbstractStringSetting setting, int titleId, + int descriptionId, int choicesId, int valuesId, MenuTag menuTag) { super(titleId, descriptionId); mSetting = setting; mChoicesId = DolphinApplication.getAppContext().getResources().getStringArray(choicesId); mValuesId = DolphinApplication.getAppContext().getResources().getStringArray(valuesId); - mDefaultValue = defaultValue; mMenuTag = menuTag; } - public StringSingleChoiceSetting(StringSetting setting, int titleId, - int descriptionId, int choicesId, int valuesId, String defaultValue) + public StringSingleChoiceSetting(AbstractStringSetting setting, int titleId, + int descriptionId, int choicesId, int valuesId) { - this(setting, titleId, descriptionId, choicesId, valuesId, defaultValue, null); + this(setting, titleId, descriptionId, choicesId, valuesId, null); } public String[] getChoicesId() @@ -74,7 +70,7 @@ public class StringSingleChoiceSetting extends SettingsItem public String getSelectedValue(Settings settings) { - return mSetting.getString(settings, mDefaultValue); + return mSetting.getString(settings); } public int getSelectValueIndex(Settings settings) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java index da8d00a895..5ba48985a0 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsAdapter.java @@ -13,9 +13,9 @@ import androidx.recyclerview.widget.RecyclerView; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.dialogs.MotionAlertDialog; -import org.dolphinemu.dolphinemu.features.settings.model.LegacySetting; -import org.dolphinemu.dolphinemu.features.settings.model.Setting; +import org.dolphinemu.dolphinemu.features.settings.model.LegacyBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; +import org.dolphinemu.dolphinemu.features.settings.model.StringSetting; import org.dolphinemu.dolphinemu.features.settings.model.view.CheckBoxSetting; import org.dolphinemu.dolphinemu.features.settings.model.view.FilePicker; import org.dolphinemu.dolphinemu.features.settings.model.view.FloatSliderSetting; @@ -319,12 +319,12 @@ public final class SettingsAdapter extends RecyclerView.Adapter entry : SettingsFragmentPresenter.LOG_TYPE_NAMES.entrySet()) { - new LegacySetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, entry.getKey()) - .setBoolean(settings, value); + new LegacyBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, entry.getKey(), + false).setBoolean(settings, value); } mView.onSettingChanged(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java index 79da4a5515..e014c85260 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java @@ -5,10 +5,15 @@ import android.text.TextUtils; import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; +import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting; +import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; +import org.dolphinemu.dolphinemu.features.settings.model.FloatSetting; import org.dolphinemu.dolphinemu.features.settings.model.IntSetting; -import org.dolphinemu.dolphinemu.features.settings.model.LegacySetting; -import org.dolphinemu.dolphinemu.features.settings.model.Setting; +import org.dolphinemu.dolphinemu.features.settings.model.LegacyBooleanSetting; +import org.dolphinemu.dolphinemu.features.settings.model.LegacyIntSetting; +import org.dolphinemu.dolphinemu.features.settings.model.LegacyStringSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; +import org.dolphinemu.dolphinemu.features.settings.model.StringSetting; import org.dolphinemu.dolphinemu.features.settings.model.view.CheckBoxSetting; import org.dolphinemu.dolphinemu.features.settings.model.view.ConfirmRunnable; import org.dolphinemu.dolphinemu.features.settings.model.view.FilePicker; @@ -224,24 +229,24 @@ public final class SettingsFragmentPresenter private void addGeneralSettings(ArrayList sl) { - sl.add(new CheckBoxSetting(Setting.MAIN_CPU_THREAD, R.string.dual_core, - R.string.dual_core_description, true)); - sl.add(new CheckBoxSetting(Setting.MAIN_OVERRIDE_REGION_SETTINGS, - R.string.override_region_settings, 0, false)); - sl.add(new CheckBoxSetting(Setting.MAIN_AUTO_DISC_CHANGE, R.string.auto_disc_change, 0, false)); - sl.add(new PercentSliderSetting(Setting.MAIN_EMULATION_SPEED, R.string.speed_limit, 0, 200, "%", - 100)); - sl.add(new CheckBoxSetting(Setting.MAIN_ANALYTICS_ENABLED, R.string.analytics, 0, false)); - sl.add(new CheckBoxSetting(Setting.MAIN_ENABLE_SAVESTATES, R.string.enable_save_states, - R.string.enable_save_states_description, false)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_CPU_THREAD, R.string.dual_core, + R.string.dual_core_description)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_OVERRIDE_REGION_SETTINGS, + R.string.override_region_settings, 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_AUTO_DISC_CHANGE, R.string.auto_disc_change, 0)); + sl.add(new PercentSliderSetting(FloatSetting.MAIN_EMULATION_SPEED, R.string.speed_limit, 0, 200, + "%")); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_ANALYTICS_ENABLED, R.string.analytics, 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_ENABLE_SAVESTATES, R.string.enable_save_states, + R.string.enable_save_states_description)); } private void addInterfaceSettings(ArrayList sl) { - sl.add(new CheckBoxSetting(Setting.MAIN_USE_PANIC_HANDLERS, R.string.panic_handlers, - R.string.panic_handlers_description, true)); - sl.add(new CheckBoxSetting(Setting.MAIN_OSD_MESSAGES, R.string.osd_messages, - R.string.osd_messages_description, true)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_USE_PANIC_HANDLERS, R.string.panic_handlers, + R.string.panic_handlers_description)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_OSD_MESSAGES, R.string.osd_messages, + R.string.osd_messages_description)); } private void addAudioSettings(ArrayList sl) @@ -250,18 +255,18 @@ public final class SettingsFragmentPresenter final int DSP_LLE_RECOMPILER = 1; final int DSP_LLE_INTERPRETER = 2; - IntSetting dspEmulationEngine = new IntSetting() + AbstractIntSetting dspEmulationEngine = new AbstractIntSetting() { @Override - public int getInt(Settings settings, int defaultValue) + public int getInt(Settings settings) { - if (Setting.MAIN_DSP_HLE.getBoolean(settings, true)) + if (BooleanSetting.MAIN_DSP_HLE.getBoolean(settings)) { return DSP_HLE; } else { - boolean jit = Setting.MAIN_DSP_JIT.getBoolean(settings, true); + boolean jit = BooleanSetting.MAIN_DSP_JIT.getBoolean(settings); return jit ? DSP_LLE_RECOMPILER : DSP_LLE_INTERPRETER; } } @@ -272,18 +277,18 @@ public final class SettingsFragmentPresenter switch (newValue) { case DSP_HLE: - Setting.MAIN_DSP_HLE.setBoolean(settings, true); - Setting.MAIN_DSP_JIT.setBoolean(settings, true); + BooleanSetting.MAIN_DSP_HLE.setBoolean(settings, true); + BooleanSetting.MAIN_DSP_JIT.setBoolean(settings, true); break; case DSP_LLE_RECOMPILER: - Setting.MAIN_DSP_HLE.setBoolean(settings, false); - Setting.MAIN_DSP_JIT.setBoolean(settings, true); + BooleanSetting.MAIN_DSP_HLE.setBoolean(settings, false); + BooleanSetting.MAIN_DSP_JIT.setBoolean(settings, true); break; case DSP_LLE_INTERPRETER: - Setting.MAIN_DSP_HLE.setBoolean(settings, false); - Setting.MAIN_DSP_JIT.setBoolean(settings, false); + BooleanSetting.MAIN_DSP_HLE.setBoolean(settings, false); + BooleanSetting.MAIN_DSP_JIT.setBoolean(settings, false); break; } } @@ -292,7 +297,8 @@ public final class SettingsFragmentPresenter public boolean delete(Settings settings) { // Not short circuiting - return Setting.MAIN_DSP_HLE.delete(settings) & Setting.MAIN_DSP_JIT.delete(settings); + return BooleanSetting.MAIN_DSP_HLE.delete(settings) & + BooleanSetting.MAIN_DSP_JIT.delete(settings); } }; @@ -311,28 +317,27 @@ public final class SettingsFragmentPresenter dspEngineValues = R.array.dspEngineValuesGeneric; } sl.add(new SingleChoiceSetting(dspEmulationEngine, R.string.dsp_emulation_engine, 0, - dspEngineEntries, dspEngineValues, 0)); - sl.add(new CheckBoxSetting(Setting.MAIN_AUDIO_STRETCH, R.string.audio_stretch, - R.string.audio_stretch_description, false)); - sl.add(new IntSliderSetting(Setting.MAIN_AUDIO_VOLUME, R.string.audio_volume, 0, 100, "%", - 100)); + dspEngineEntries, dspEngineValues)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_AUDIO_STRETCH, R.string.audio_stretch, + R.string.audio_stretch_description)); + sl.add(new IntSliderSetting(IntSetting.MAIN_AUDIO_VOLUME, R.string.audio_volume, 0, 100, "%")); } private void addPathsSettings(ArrayList sl) { - sl.add(new CheckBoxSetting(Setting.MAIN_RECURSIVE_ISO_PATHS, R.string.search_subfolders, 0, - false)); - sl.add(new FilePicker(Setting.MAIN_DEFAULT_ISO, R.string.default_ISO, 0, "", + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_RECURSIVE_ISO_PATHS, R.string.search_subfolders, + 0)); + sl.add(new FilePicker(StringSetting.MAIN_DEFAULT_ISO, R.string.default_ISO, 0, MainPresenter.REQUEST_GAME_FILE)); - sl.add(new FilePicker(Setting.MAIN_FS_PATH, R.string.wii_NAND_root, 0, getDefaultNANDRootPath(), + sl.add(new FilePicker(StringSetting.MAIN_FS_PATH, R.string.wii_NAND_root, 0, MainPresenter.REQUEST_DIRECTORY)); - sl.add(new FilePicker(Setting.MAIN_DUMP_PATH, R.string.dump_path, 0, getDefaultDumpPath(), + sl.add(new FilePicker(StringSetting.MAIN_DUMP_PATH, R.string.dump_path, 0, MainPresenter.REQUEST_DIRECTORY)); - sl.add(new FilePicker(Setting.MAIN_LOAD_PATH, R.string.load_path, 0, getDefaultLoadPath(), + sl.add(new FilePicker(StringSetting.MAIN_LOAD_PATH, R.string.load_path, 0, MainPresenter.REQUEST_DIRECTORY)); - sl.add(new FilePicker(Setting.MAIN_RESOURCEPACK_PATH, R.string.resource_pack_path, 0, - getDefaultResourcePackPath(), MainPresenter.REQUEST_DIRECTORY)); - sl.add(new FilePicker(Setting.MAIN_SD_PATH, R.string.SD_card_path, 0, getDefaultSDPath(), + sl.add(new FilePicker(StringSetting.MAIN_RESOURCEPACK_PATH, R.string.resource_pack_path, 0, + MainPresenter.REQUEST_DIRECTORY)); + sl.add(new FilePicker(StringSetting.MAIN_SD_PATH, R.string.SD_card_path, 0, MainPresenter.REQUEST_SD_FILE)); sl.add(new ConfirmRunnable(R.string.reset_paths, 0, R.string.reset_paths_confirmation, 0, mView.getAdapter()::resetPaths)); @@ -340,24 +345,24 @@ public final class SettingsFragmentPresenter private void addGameCubeSettings(ArrayList sl) { - sl.add(new SingleChoiceSetting(Setting.MAIN_GC_LANGUAGE, R.string.gamecube_system_language, 0, - R.array.gameCubeSystemLanguageEntries, R.array.gameCubeSystemLanguageValues, 0)); - sl.add(new SingleChoiceSetting(Setting.MAIN_SLOT_A, R.string.slot_a_device, 0, - R.array.slotDeviceEntries, R.array.slotDeviceValues, 8)); - sl.add(new SingleChoiceSetting(Setting.MAIN_SLOT_B, R.string.slot_b_device, 0, - R.array.slotDeviceEntries, R.array.slotDeviceValues, 255)); + sl.add(new SingleChoiceSetting(IntSetting.MAIN_GC_LANGUAGE, R.string.gamecube_system_language, + 0, R.array.gameCubeSystemLanguageEntries, R.array.gameCubeSystemLanguageValues)); + sl.add(new SingleChoiceSetting(IntSetting.MAIN_SLOT_A, R.string.slot_a_device, 0, + R.array.slotDeviceEntries, R.array.slotDeviceValues)); + sl.add(new SingleChoiceSetting(IntSetting.MAIN_SLOT_B, R.string.slot_b_device, 0, + R.array.slotDeviceEntries, R.array.slotDeviceValues)); } private void addWiiSettings(ArrayList sl) { - sl.add(new CheckBoxSetting(Setting.MAIN_WII_SD_CARD, R.string.insert_sd_card, - R.string.insert_sd_card_description, true)); - sl.add(new CheckBoxSetting(Setting.MAIN_ALLOW_SD_WRITES, R.string.wii_sd_card_allow_writes, 0, - true)); - sl.add(new CheckBoxSetting(Setting.MAIN_WIIMOTE_CONTINUOUS_SCANNING, R.string.wiimote_scanning, - R.string.wiimote_scanning_description, false)); - sl.add(new CheckBoxSetting(Setting.MAIN_WIIMOTE_ENABLE_SPEAKER, R.string.wiimote_speaker, - R.string.wiimote_speaker_description, false)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_WII_SD_CARD, R.string.insert_sd_card, + R.string.insert_sd_card_description)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_ALLOW_SD_WRITES, + R.string.wii_sd_card_allow_writes, 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_WIIMOTE_CONTINUOUS_SCANNING, + R.string.wiimote_scanning, R.string.wiimote_scanning_description)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_WIIMOTE_ENABLE_SPEAKER, R.string.wiimote_speaker, + R.string.wiimote_speaker_description)); } private void addAdvancedSettings(ArrayList sl) @@ -383,32 +388,32 @@ public final class SettingsFragmentPresenter emuCoresEntries = R.array.emuCoresEntriesGeneric; emuCoresValues = R.array.emuCoresValuesGeneric; } - sl.add(new SingleChoiceSetting(Setting.MAIN_CPU_CORE, R.string.cpu_core, 0, emuCoresEntries, - emuCoresValues, defaultCpuCore)); - sl.add(new CheckBoxSetting(Setting.MAIN_OVERCLOCK_ENABLE, R.string.overclock_enable, - R.string.overclock_enable_description, false)); - sl.add(new PercentSliderSetting(Setting.MAIN_OVERCLOCK, R.string.overclock_title, - R.string.overclock_title_description, 400, "%", 100)); + sl.add(new SingleChoiceSetting(IntSetting.MAIN_CPU_CORE, R.string.cpu_core, 0, emuCoresEntries, + emuCoresValues)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_OVERCLOCK_ENABLE, R.string.overclock_enable, + R.string.overclock_enable_description)); + sl.add(new PercentSliderSetting(FloatSetting.MAIN_OVERCLOCK, R.string.overclock_title, + R.string.overclock_title_description, 400, "%")); } private void addGcPadSettings(ArrayList sl) { for (int i = 0; i < 4; i++) { - LegacySetting gcPadSetting; + LegacyIntSetting gcPadSetting; if (mGameID.equals("")) { - gcPadSetting = new LegacySetting(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, - SettingsFile.KEY_GCPAD_TYPE + i); + gcPadSetting = new LegacyIntSetting(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, + SettingsFile.KEY_GCPAD_TYPE + i, 0); } else { - gcPadSetting = new LegacySetting(Settings.GAME_SETTINGS_PLACEHOLDER_FILE_NAME, - Settings.SECTION_CONTROLS, SettingsFile.KEY_GCPAD_G_TYPE + i); + gcPadSetting = new LegacyIntSetting(Settings.GAME_SETTINGS_PLACEHOLDER_FILE_NAME, + Settings.SECTION_CONTROLS, SettingsFile.KEY_GCPAD_G_TYPE + i, 0); } // TODO: This controller_0 + i business is quite the hack. It should work, but only if the definitions are kept together and in order. sl.add(new SingleChoiceSetting(gcPadSetting, R.string.controller_0 + i, 0, - R.array.gcpadTypeEntries, R.array.gcpadTypeValues, 0, MenuTag.getGCPadMenuTag(i))); + R.array.gcpadTypeEntries, R.array.gcpadTypeValues, MenuTag.getGCPadMenuTag(i))); } } @@ -416,20 +421,20 @@ public final class SettingsFragmentPresenter { for (int i = 0; i < 4; i++) { - LegacySetting wiimoteSetting; + LegacyIntSetting wiimoteSetting; if (mGameID.equals("")) { - wiimoteSetting = new LegacySetting(Settings.FILE_WIIMOTE, - Settings.SECTION_WIIMOTE + (i + 1), SettingsFile.KEY_WIIMOTE_TYPE); + wiimoteSetting = new LegacyIntSetting(Settings.FILE_WIIMOTE, + Settings.SECTION_WIIMOTE + (i + 1), SettingsFile.KEY_WIIMOTE_TYPE, 0); } else { - wiimoteSetting = new LegacySetting(Settings.GAME_SETTINGS_PLACEHOLDER_FILE_NAME, - Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIMOTE_G_TYPE + i); + wiimoteSetting = new LegacyIntSetting(Settings.GAME_SETTINGS_PLACEHOLDER_FILE_NAME, + Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIMOTE_G_TYPE + i, 0); } // TODO: This wiimote_0 + i business is quite the hack. It should work, but only if the definitions are kept together and in order. sl.add(new SingleChoiceSetting(wiimoteSetting, R.string.wiimote_4 + i, 0, - R.array.wiimoteTypeEntries, R.array.wiimoteTypeValues, 0, + R.array.wiimoteTypeEntries, R.array.wiimoteTypeValues, MenuTag.getWiimoteMenuTag(i + 4))); } } @@ -437,18 +442,18 @@ public final class SettingsFragmentPresenter private void addGraphicsSettings(ArrayList sl) { sl.add(new HeaderSetting(R.string.graphics_general, 0)); - sl.add(new StringSingleChoiceSetting(Setting.MAIN_GFX_BACKEND, R.string.video_backend, 0, - R.array.videoBackendEntries, R.array.videoBackendValues, "OGL")); - sl.add(new CheckBoxSetting(Setting.GFX_SHOW_FPS, R.string.show_fps, - R.string.show_fps_description, false)); - sl.add(new SingleChoiceSettingDynamicDescriptions(Setting.GFX_SHADER_COMPILATION_MODE, + sl.add(new StringSingleChoiceSetting(StringSetting.MAIN_GFX_BACKEND, R.string.video_backend, 0, + R.array.videoBackendEntries, R.array.videoBackendValues)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_SHOW_FPS, R.string.show_fps, + R.string.show_fps_description)); + sl.add(new SingleChoiceSettingDynamicDescriptions(IntSetting.GFX_SHADER_COMPILATION_MODE, R.string.shader_compilation_mode, 0, R.array.shaderCompilationModeEntries, R.array.shaderCompilationModeValues, R.array.shaderCompilationDescriptionEntries, - R.array.shaderCompilationDescriptionValues, 0)); - sl.add(new CheckBoxSetting(Setting.GFX_WAIT_FOR_SHADERS_BEFORE_STARTING, - R.string.wait_for_shaders, R.string.wait_for_shaders_description, false)); - sl.add(new SingleChoiceSetting(Setting.GFX_ASPECT_RATIO, R.string.aspect_ratio, 0, - R.array.aspectRatioEntries, R.array.aspectRatioValues, 0)); + R.array.shaderCompilationDescriptionValues)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_WAIT_FOR_SHADERS_BEFORE_STARTING, + R.string.wait_for_shaders, R.string.wait_for_shaders_description)); + sl.add(new SingleChoiceSetting(IntSetting.GFX_ASPECT_RATIO, R.string.aspect_ratio, 0, + R.array.aspectRatioEntries, R.array.aspectRatioValues)); sl.add(new HeaderSetting(R.string.graphics_enhancements_and_hacks, 0)); sl.add(new SubmenuSetting(R.string.enhancements_submenu, MenuTag.ENHANCEMENTS)); @@ -457,44 +462,43 @@ public final class SettingsFragmentPresenter private void addEnhanceSettings(ArrayList sl) { - sl.add(new SingleChoiceSetting(Setting.GFX_EFB_SCALE, R.string.internal_resolution, + sl.add(new SingleChoiceSetting(IntSetting.GFX_EFB_SCALE, R.string.internal_resolution, R.string.internal_resolution_description, R.array.internalResolutionEntries, - R.array.internalResolutionValues, 1)); - sl.add(new SingleChoiceSetting(Setting.GFX_MSAA, R.string.FSAA, R.string.FSAA_description, - R.array.FSAAEntries, R.array.FSAAValues, 1)); - sl.add(new SingleChoiceSetting(Setting.GFX_ENHANCE_MAX_ANISOTROPY, + R.array.internalResolutionValues)); + sl.add(new SingleChoiceSetting(IntSetting.GFX_MSAA, R.string.FSAA, R.string.FSAA_description, + R.array.FSAAEntries, R.array.FSAAValues)); + sl.add(new SingleChoiceSetting(IntSetting.GFX_ENHANCE_MAX_ANISOTROPY, R.string.anisotropic_filtering, R.string.anisotropic_filtering_description, - R.array.anisotropicFilteringEntries, R.array.anisotropicFilteringValues, 0)); + R.array.anisotropicFilteringEntries, R.array.anisotropicFilteringValues)); - int stereoModeValue = Setting.GFX_STEREO_MODE.getInt(mSettings, 0); + int stereoModeValue = IntSetting.GFX_STEREO_MODE.getInt(mSettings); final int anaglyphMode = 3; String subDir = stereoModeValue == anaglyphMode ? "Anaglyph" : null; String[] shaderListEntries = getShaderList(subDir); String[] shaderListValues = new String[shaderListEntries.length]; System.arraycopy(shaderListEntries, 0, shaderListValues, 0, shaderListEntries.length); shaderListValues[0] = ""; - sl.add(new StringSingleChoiceSetting(Setting.GFX_ENHANCE_POST_SHADER, - R.string.post_processing_shader, 0, shaderListEntries, shaderListValues, "")); + sl.add(new StringSingleChoiceSetting(StringSetting.GFX_ENHANCE_POST_SHADER, + R.string.post_processing_shader, 0, shaderListEntries, shaderListValues)); - sl.add(new CheckBoxSetting(Setting.GFX_HACK_COPY_EFB_SCALED, R.string.scaled_efb_copy, - R.string.scaled_efb_copy_description, true)); - sl.add(new CheckBoxSetting(Setting.GFX_ENABLE_PIXEL_LIGHTING, R.string.per_pixel_lighting, - R.string.per_pixel_lighting_description, false)); - sl.add(new CheckBoxSetting(Setting.GFX_ENHANCE_FORCE_FILTERING, - R.string.force_texture_filtering, R.string.force_texture_filtering_description, false)); - sl.add(new CheckBoxSetting(Setting.GFX_ENHANCE_FORCE_TRUE_COLOR, R.string.force_24bit_color, - R.string.force_24bit_color_description, true)); - sl.add(new CheckBoxSetting(Setting.GFX_DISABLE_FOG, R.string.disable_fog, - R.string.disable_fog_description, false)); - sl.add(new CheckBoxSetting(Setting.GFX_ENHANCE_DISABLE_COPY_FILTER, - R.string.disable_copy_filter, R.string.disable_copy_filter_description, false)); - sl.add(new CheckBoxSetting(Setting.GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION, - R.string.arbitrary_mipmap_detection, R.string.arbitrary_mipmap_detection_description, - true)); - sl.add(new CheckBoxSetting(Setting.GFX_WIDESCREEN_HACK, R.string.wide_screen_hack, - R.string.wide_screen_hack_description, false)); - sl.add(new CheckBoxSetting(Setting.GFX_BACKEND_MULTITHREADING, R.string.backend_multithreading, - R.string.backend_multithreading_description, false)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_HACK_COPY_EFB_SCALED, R.string.scaled_efb_copy, + R.string.scaled_efb_copy_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_ENABLE_PIXEL_LIGHTING, + R.string.per_pixel_lighting, R.string.per_pixel_lighting_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_ENHANCE_FORCE_FILTERING, + R.string.force_texture_filtering, R.string.force_texture_filtering_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_ENHANCE_FORCE_TRUE_COLOR, + R.string.force_24bit_color, R.string.force_24bit_color_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_DISABLE_FOG, R.string.disable_fog, + R.string.disable_fog_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_ENHANCE_DISABLE_COPY_FILTER, + R.string.disable_copy_filter, R.string.disable_copy_filter_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_ENHANCE_ARBITRARY_MIPMAP_DETECTION, + R.string.arbitrary_mipmap_detection, R.string.arbitrary_mipmap_detection_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_WIDESCREEN_HACK, R.string.wide_screen_hack, + R.string.wide_screen_hack_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_BACKEND_MULTITHREADING, + R.string.backend_multithreading, R.string.backend_multithreading_description)); /* Check if we support stereo @@ -554,41 +558,41 @@ public final class SettingsFragmentPresenter private void addHackSettings(ArrayList sl) { sl.add(new HeaderSetting(R.string.embedded_frame_buffer, 0)); - sl.add(new InvertedCheckBoxSetting(Setting.GFX_HACK_EFB_ACCESS_ENABLE, R.string.skip_efb_access, - R.string.skip_efb_access_description, false)); - sl.add(new InvertedCheckBoxSetting(Setting.GFX_HACK_EFB_EMULATE_FORMAT_CHANGES, - R.string.ignore_format_changes, R.string.ignore_format_changes_description, true)); - sl.add(new CheckBoxSetting(Setting.GFX_HACK_SKIP_EFB_COPY_TO_RAM, R.string.efb_copy_method, - R.string.efb_copy_method_description, true)); - sl.add(new CheckBoxSetting(Setting.GFX_HACK_DEFER_EFB_COPIES, R.string.defer_efb_copies, - R.string.defer_efb_copies_description, true)); + sl.add(new InvertedCheckBoxSetting(BooleanSetting.GFX_HACK_EFB_ACCESS_ENABLE, + R.string.skip_efb_access, R.string.skip_efb_access_description)); + sl.add(new InvertedCheckBoxSetting(BooleanSetting.GFX_HACK_EFB_EMULATE_FORMAT_CHANGES, + R.string.ignore_format_changes, R.string.ignore_format_changes_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_HACK_SKIP_EFB_COPY_TO_RAM, + R.string.efb_copy_method, R.string.efb_copy_method_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_HACK_DEFER_EFB_COPIES, R.string.defer_efb_copies, + R.string.defer_efb_copies_description)); sl.add(new HeaderSetting(R.string.texture_cache, 0)); - sl.add(new SingleChoiceSetting(Setting.GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES, + sl.add(new SingleChoiceSetting(IntSetting.GFX_SAFE_TEXTURE_CACHE_COLOR_SAMPLES, R.string.texture_cache_accuracy, R.string.texture_cache_accuracy_description, - R.array.textureCacheAccuracyEntries, R.array.textureCacheAccuracyValues, 128)); - sl.add(new CheckBoxSetting(Setting.GFX_ENABLE_GPU_TEXTURE_DECODING, - R.string.gpu_texture_decoding, R.string.gpu_texture_decoding_description, false)); + R.array.textureCacheAccuracyEntries, R.array.textureCacheAccuracyValues)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_ENABLE_GPU_TEXTURE_DECODING, + R.string.gpu_texture_decoding, R.string.gpu_texture_decoding_description)); sl.add(new HeaderSetting(R.string.external_frame_buffer, 0)); - sl.add(new CheckBoxSetting(Setting.GFX_HACK_SKIP_XFB_COPY_TO_RAM, R.string.xfb_copy_method, - R.string.xfb_copy_method_description, true)); - sl.add(new CheckBoxSetting(Setting.GFX_HACK_IMMEDIATE_XFB, R.string.immediate_xfb, - R.string.immediate_xfb_description, false)); - sl.add(new CheckBoxSetting(Setting.GFX_HACK_SKIP_DUPLICATE_XFBS, R.string.skip_duplicate_xfbs, - R.string.skip_duplicate_xfbs_description, true)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_HACK_SKIP_XFB_COPY_TO_RAM, + R.string.xfb_copy_method, R.string.xfb_copy_method_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_HACK_IMMEDIATE_XFB, R.string.immediate_xfb, + R.string.immediate_xfb_description)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_HACK_SKIP_DUPLICATE_XFBS, + R.string.skip_duplicate_xfbs, R.string.skip_duplicate_xfbs_description)); sl.add(new HeaderSetting(R.string.other, 0)); - sl.add(new CheckBoxSetting(Setting.GFX_FAST_DEPTH_CALC, R.string.fast_depth_calculation, - R.string.fast_depth_calculation_description, true)); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_FAST_DEPTH_CALC, R.string.fast_depth_calculation, + R.string.fast_depth_calculation_description)); } private void addLogConfigurationSettings(ArrayList sl) { - sl.add(new CheckBoxSetting(Setting.LOGGER_WRITE_TO_FILE, R.string.enable_logging, - R.string.enable_logging_description, false)); - sl.add(new SingleChoiceSetting(Setting.LOGGER_VERBOSITY, R.string.log_verbosity, 0, - getLogVerbosityEntries(), getLogVerbosityValues(), 1)); + sl.add(new CheckBoxSetting(BooleanSetting.LOGGER_WRITE_TO_FILE, R.string.enable_logging, + R.string.enable_logging_description)); + sl.add(new SingleChoiceSetting(IntSetting.LOGGER_VERBOSITY, R.string.log_verbosity, 0, + getLogVerbosityEntries(), getLogVerbosityValues())); sl.add(new ConfirmRunnable(R.string.log_enable_all, 0, R.string.log_enable_all_confirmation, 0, () -> mView.getAdapter().setAllLogTypes(true))); sl.add(new ConfirmRunnable(R.string.log_disable_all, 0, R.string.log_disable_all_confirmation, @@ -598,7 +602,7 @@ public final class SettingsFragmentPresenter for (Map.Entry entry : LOG_TYPE_NAMES.entrySet()) { // TitleID is handled by special case in CheckBoxSettingViewHolder. - sl.add(new LogCheckBoxSetting(entry.getKey(), 0, 0, false)); + sl.add(new LogCheckBoxSetting(entry.getKey(), 0, 0)); } } @@ -607,36 +611,36 @@ public final class SettingsFragmentPresenter sl.add(new HeaderSetting(R.string.debug_warning, 0)); sl.add(new HeaderSetting(R.string.debug_jit_header, 0)); - sl.add(new CheckBoxSetting(Setting.MAIN_JIT_OFF, R.string.debug_jitoff, 0, false)); - sl.add(new CheckBoxSetting(Setting.MAIN_JIT_LOAD_STORE_OFF, R.string.debug_jitloadstoreoff, 0, - false)); - sl.add(new CheckBoxSetting(Setting.MAIN_JIT_LOAD_STORE_FLOATING_OFF, - R.string.debug_jitloadstorefloatingoff, 0, false)); - sl.add(new CheckBoxSetting(Setting.MAIN_JIT_LOAD_STORE_PAIRED_OFF, - R.string.debug_jitloadstorepairedoff, 0, false)); - sl.add(new CheckBoxSetting(Setting.MAIN_JIT_FLOATING_POINT_OFF, - R.string.debug_jitfloatingpointoff, 0, false)); - sl.add(new CheckBoxSetting(Setting.MAIN_JIT_INTEGER_OFF, R.string.debug_jitintegeroff, 0, - false)); - sl.add(new CheckBoxSetting(Setting.MAIN_JIT_PAIRED_OFF, R.string.debug_jitpairedoff, 0, false)); - sl.add(new CheckBoxSetting(Setting.MAIN_JIT_SYSTEM_REGISTERS_OFF, - R.string.debug_jitsystemregistersoff, 0, false)); - sl.add(new CheckBoxSetting(Setting.MAIN_JIT_BRANCH_OFF, R.string.debug_jitbranchoff, 0, false)); - sl.add(new CheckBoxSetting(Setting.MAIN_JIT_REGISTER_CACHE_OFF, - R.string.debug_jitregistercacheoff, 0, false)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_JIT_OFF, R.string.debug_jitoff, 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_JIT_LOAD_STORE_OFF, + R.string.debug_jitloadstoreoff, 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_JIT_LOAD_STORE_FLOATING_OFF, + R.string.debug_jitloadstorefloatingoff, 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_JIT_LOAD_STORE_PAIRED_OFF, + R.string.debug_jitloadstorepairedoff, 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_JIT_FLOATING_POINT_OFF, + R.string.debug_jitfloatingpointoff, 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_JIT_INTEGER_OFF, R.string.debug_jitintegeroff, + 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_JIT_PAIRED_OFF, R.string.debug_jitpairedoff, 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_JIT_SYSTEM_REGISTERS_OFF, + R.string.debug_jitsystemregistersoff, 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_JIT_BRANCH_OFF, R.string.debug_jitbranchoff, 0)); + sl.add(new CheckBoxSetting(BooleanSetting.MAIN_JIT_REGISTER_CACHE_OFF, + R.string.debug_jitregistercacheoff, 0)); } private void addStereoSettings(ArrayList sl) { - sl.add(new SingleChoiceSetting(Setting.GFX_STEREO_MODE, R.string.stereoscopy_mode, 0, - R.array.stereoscopyEntries, R.array.stereoscopyValues, 0)); - sl.add(new IntSliderSetting(Setting.GFX_STEREO_DEPTH, R.string.stereoscopy_depth, - R.string.stereoscopy_depth_description, 100, "%", 20)); - sl.add(new IntSliderSetting(Setting.GFX_STEREO_CONVERGENCE_PERCENTAGE, + sl.add(new SingleChoiceSetting(IntSetting.GFX_STEREO_MODE, R.string.stereoscopy_mode, 0, + R.array.stereoscopyEntries, R.array.stereoscopyValues)); + sl.add(new IntSliderSetting(IntSetting.GFX_STEREO_DEPTH, R.string.stereoscopy_depth, + R.string.stereoscopy_depth_description, 100, "%")); + sl.add(new IntSliderSetting(IntSetting.GFX_STEREO_CONVERGENCE_PERCENTAGE, R.string.stereoscopy_convergence, R.string.stereoscopy_convergence_description, 200, - "%", 0)); - sl.add(new CheckBoxSetting(Setting.GFX_STEREO_SWAP_EYES, R.string.stereoscopy_swap_eyes, - R.string.stereoscopy_swap_eyes_description, false)); + "%")); + sl.add(new CheckBoxSetting(BooleanSetting.GFX_STEREO_SWAP_EYES, R.string.stereoscopy_swap_eyes, + R.string.stereoscopy_swap_eyes_description)); } private void addGcPadSubSettings(ArrayList sl, int gcPadNumber, int gcPadType) @@ -702,15 +706,15 @@ public final class SettingsFragmentPresenter } else // Adapter { - LegacySetting rumble = new LegacySetting(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, - SettingsFile.KEY_GCADAPTER_RUMBLE + gcPadNumber); - LegacySetting bongo = new LegacySetting(Settings.FILE_DOLPHIN, Settings.SECTION_INI_CORE, - SettingsFile.KEY_GCADAPTER_BONGOS + gcPadNumber); + LegacyBooleanSetting rumble = new LegacyBooleanSetting(Settings.FILE_DOLPHIN, + Settings.SECTION_INI_CORE, SettingsFile.KEY_GCADAPTER_RUMBLE + gcPadNumber, false); + LegacyBooleanSetting bongo = new LegacyBooleanSetting(Settings.FILE_DOLPHIN, + Settings.SECTION_INI_CORE, SettingsFile.KEY_GCADAPTER_BONGOS + gcPadNumber, false); sl.add(new CheckBoxSetting(rumble, R.string.gc_adapter_rumble, - R.string.gc_adapter_rumble_description, false)); + R.string.gc_adapter_rumble_description)); sl.add(new CheckBoxSetting(bongo, R.string.gc_adapter_bongos, - R.string.gc_adapter_bongos_description, false)); + R.string.gc_adapter_bongos_description)); } } @@ -720,22 +724,23 @@ public final class SettingsFragmentPresenter // But game game specific extension settings are saved in their own profile. These profiles // do not have any way to specify the controller that is loaded outside of knowing the filename // of the profile that was loaded. - LegacySetting extension; + LegacyStringSetting extension; if (mGameID.isEmpty()) { - extension = new LegacySetting(Settings.FILE_WIIMOTE, - Settings.SECTION_WIIMOTE + (wiimoteNumber - 3), SettingsFile.KEY_WIIMOTE_EXTENSION); + extension = new LegacyStringSetting(Settings.FILE_WIIMOTE, + Settings.SECTION_WIIMOTE + (wiimoteNumber - 3), SettingsFile.KEY_WIIMOTE_EXTENSION, + getExtensionValue(wiimoteNumber - 3)); } else { mSettings.loadWiimoteProfile(mGameID, wiimoteNumber - 4); - extension = new LegacySetting(Settings.GAME_SETTINGS_PLACEHOLDER_FILE_NAME, - Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIMOTE_EXTENSION + (wiimoteNumber - 4)); + extension = new LegacyStringSetting(Settings.GAME_SETTINGS_PLACEHOLDER_FILE_NAME, + Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIMOTE_EXTENSION + (wiimoteNumber - 4), + getExtensionValue(wiimoteNumber - 4)); } sl.add(new StringSingleChoiceSetting(extension, R.string.wiimote_extensions, 0, R.array.wiimoteExtensionsEntries, R.array.wiimoteExtensionsValues, - getExtensionValue(wiimoteNumber - 3), MenuTag.getWiimoteExtensionMenuTag(wiimoteNumber))); sl.add(new HeaderSetting(R.string.generic_buttons, 0)); @@ -1166,31 +1171,6 @@ public final class SettingsFragmentPresenter return section.getString(SettingsFile.KEY_WIIMOTE_EXTENSION, "None"); } - public static String getDefaultNANDRootPath() - { - return DirectoryInitialization.getUserDirectory() + "/Wii"; - } - - public static String getDefaultDumpPath() - { - return DirectoryInitialization.getUserDirectory() + "/Dump"; - } - - public static String getDefaultLoadPath() - { - return DirectoryInitialization.getUserDirectory() + "/Load"; - } - - public static String getDefaultResourcePackPath() - { - return DirectoryInitialization.getUserDirectory() + "/ResourcePacks"; - } - - public static String getDefaultSDPath() - { - return DirectoryInitialization.getUserDirectory() + "/Wii/sd.raw"; - } - private static int getLogVerbosityEntries() { // Value obtained from LOG_LEVELS in Common/Logging/Log.h diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java index eeff9cda14..2328f5c0dc 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java @@ -16,7 +16,7 @@ import androidx.fragment.app.Fragment; import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.activities.EmulationActivity; -import org.dolphinemu.dolphinemu.features.settings.model.Setting; +import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; public final class MenuFragment extends Fragment implements View.OnClickListener @@ -84,7 +84,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener updatePauseUnpauseVisibility(); Settings settings = ((EmulationActivity) getActivity()).getSettings(); - if (Setting.MAIN_ENABLE_SAVESTATES.getBoolean(settings, false)) + if (BooleanSetting.MAIN_ENABLE_SAVESTATES.getBoolean(settings)) { options.findViewById(R.id.menu_quicksave).setVisibility(View.VISIBLE); options.findViewById(R.id.menu_quickload).setVisibility(View.VISIBLE); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java index 7ee178c9b7..87285f5eb3 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFileCache.java @@ -4,7 +4,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; -import org.dolphinemu.dolphinemu.features.settings.model.Setting; +import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; import java.io.File; @@ -83,7 +83,7 @@ public class GameFileCache { Settings settings = new Settings(); settings.loadSettings(null); - boolean recursiveScan = Setting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(settings, false); + boolean recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(settings); removeNonExistentGameFolders(context); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java index bebe91e064..2728bc980a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java @@ -20,7 +20,7 @@ import com.google.android.material.tabs.TabLayout; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.adapters.PlatformPagerAdapter; -import org.dolphinemu.dolphinemu.features.settings.model.Setting; +import org.dolphinemu.dolphinemu.features.settings.model.IntSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity; @@ -273,7 +273,7 @@ public final class MainActivity extends AppCompatActivity implements MainView Settings settings = new Settings(); settings.loadSettings(null); - Setting.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); @@ -282,7 +282,7 @@ public final class MainActivity extends AppCompatActivity implements MainView Settings settings = new Settings(); settings.loadSettings(null); - mViewPager.setCurrentItem(Setting.MAIN_LAST_PLATFORM_TAB.getInt(settings, 0)); + mViewPager.setCurrentItem(IntSetting.MAIN_LAST_PLATFORM_TAB.getInt(settings)); showGames(); GameFileCacheService.startLoad(this); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.java index 59e44c7087..8848db4ad7 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.java @@ -10,7 +10,7 @@ import com.android.volley.toolbox.StringRequest; import org.dolphinemu.dolphinemu.DolphinApplication; import org.dolphinemu.dolphinemu.R; -import org.dolphinemu.dolphinemu.features.settings.model.Setting; +import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; public class Analytics @@ -26,7 +26,7 @@ public class Analytics { Settings settings = new Settings(); settings.loadSettings(null); - if (!Setting.MAIN_ANALYTICS_PERMISSION_ASKED.getBoolean(settings, false)) + if (!BooleanSetting.MAIN_ANALYTICS_PERMISSION_ASKED.getBoolean(settings)) { showMessage(context, settings); } @@ -51,8 +51,8 @@ public class Analytics private static void firstAnalyticsAdd(Settings settings, boolean enabled) { - Setting.MAIN_ANALYTICS_ENABLED.setBoolean(settings, enabled); - Setting.MAIN_ANALYTICS_PERMISSION_ASKED.setBoolean(settings, true); + BooleanSetting.MAIN_ANALYTICS_ENABLED.setBoolean(settings, enabled); + BooleanSetting.MAIN_ANALYTICS_PERMISSION_ASKED.setBoolean(settings, true); // Context is set to null to avoid toasts settings.saveSettings(null, null); diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index 0732987a9d..4c7345b8dd 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -241,6 +241,9 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetCacheDire JNIEnv* env, jobject obj, jstring jDirectory); JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCore(JNIEnv* env, jobject obj); +JNIEXPORT jstring JNICALL +Java_org_dolphinemu_dolphinemu_NativeLibrary_GetDefaultGraphicsBackendName(JNIEnv* env, + jobject obj); JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetMaxLogLevel(JNIEnv* env, jobject obj); JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv* env, @@ -425,6 +428,12 @@ JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCo return static_cast(PowerPC::DefaultCPUCore()); } +JNIEXPORT jstring JNICALL +Java_org_dolphinemu_dolphinemu_NativeLibrary_GetDefaultGraphicsBackendName(JNIEnv* env, jobject obj) +{ + return ToJString(env, VideoBackendBase::GetDefaultBackendName()); +} + JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetMaxLogLevel(JNIEnv* env, jobject obj) {