| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| public enum BooleanSetting implements AbstractBooleanSetting | ||
| { | ||
| // These entries have the same names and order as in C++, just for consistency. | ||
|
|
||
| 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 static final BooleanSetting[] NOT_RUNTIME_EDITABLE_ARRAY = new BooleanSetting[]{ | ||
| MAIN_DSP_HLE, | ||
| MAIN_CPU_THREAD, | ||
| MAIN_OVERRIDE_REGION_SETTINGS, | ||
| MAIN_WII_SD_CARD, // Can actually be changed, but specific code is required | ||
| MAIN_DSP_JIT | ||
| }; | ||
|
|
||
| private static final Set<BooleanSetting> NOT_RUNTIME_EDITABLE = | ||
| new HashSet<>(Arrays.asList(NOT_RUNTIME_EDITABLE_ARRAY)); | ||
|
|
||
| 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 isOverridden(Settings settings) | ||
| { | ||
| if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| return settings.getSection(mFile, mSection).exists(mKey); | ||
| else | ||
| return NativeConfig.isOverridden(mFile, mSection, mKey); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isRuntimeEditable() | ||
| { | ||
| for (BooleanSetting setting : NOT_RUNTIME_EDITABLE) | ||
| { | ||
| if (setting == this) | ||
| return false; | ||
| } | ||
|
|
||
| return NativeConfig.isSettingSaveable(mFile, mSection, mKey); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean delete(Settings settings) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| return NativeConfig.deleteKey(settings.getActiveLayer(), mFile, mSection, mKey); | ||
| } | ||
| else | ||
| { | ||
| return settings.getSection(mFile, mSection).delete(mKey); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public boolean getBoolean(Settings settings) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| return NativeConfig.getBoolean(settings.getActiveLayer(), mFile, mSection, mKey, | ||
| mDefaultValue); | ||
| } | ||
| else | ||
| { | ||
| return settings.getSection(mFile, mSection).getBoolean(mKey, mDefaultValue); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void setBoolean(Settings settings, boolean newValue) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| NativeConfig.setBoolean(settings.getActiveLayer(), mFile, mSection, mKey, newValue); | ||
| } | ||
| else | ||
| { | ||
| settings.getSection(mFile, mSection).setBoolean(mKey, newValue); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model; | ||
|
|
||
| public enum FloatSetting implements AbstractFloatSetting | ||
| { | ||
| // These entries have the same names and order as in C++, just for consistency. | ||
|
|
||
| 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 isOverridden(Settings settings) | ||
| { | ||
| if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| return settings.getSection(mFile, mSection).exists(mKey); | ||
| else | ||
| return NativeConfig.isOverridden(mFile, mSection, mKey); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isRuntimeEditable() | ||
| { | ||
| return NativeConfig.isSettingSaveable(mFile, mSection, mKey); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean delete(Settings settings) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| return NativeConfig.deleteKey(settings.getActiveLayer(), mFile, mSection, mKey); | ||
| } | ||
| else | ||
| { | ||
| return settings.getSection(mFile, mSection).delete(mKey); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public float getFloat(Settings settings) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| return NativeConfig.getFloat(settings.getActiveLayer(), mFile, mSection, mKey, mDefaultValue); | ||
| } | ||
| else | ||
| { | ||
| return settings.getSection(mFile, mSection).getFloat(mKey, mDefaultValue); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void setFloat(Settings settings, float newValue) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| NativeConfig.setFloat(settings.getActiveLayer(), mFile, mSection, mKey, newValue); | ||
| } | ||
| else | ||
| { | ||
| settings.getSection(mFile, mSection).setFloat(mKey, newValue); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model; | ||
|
|
||
| import org.dolphinemu.dolphinemu.NativeLibrary; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| 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 static final IntSetting[] NOT_RUNTIME_EDITABLE_ARRAY = new IntSetting[]{ | ||
| MAIN_CPU_CORE, | ||
| MAIN_GC_LANGUAGE, | ||
| MAIN_SLOT_A, // Can actually be changed, but specific code is required | ||
| MAIN_SLOT_B, // Can actually be changed, but specific code is required | ||
| }; | ||
|
|
||
| private static final Set<IntSetting> NOT_RUNTIME_EDITABLE = | ||
| new HashSet<>(Arrays.asList(NOT_RUNTIME_EDITABLE_ARRAY)); | ||
|
|
||
| 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 isOverridden(Settings settings) | ||
| { | ||
| if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| return settings.getSection(mFile, mSection).exists(mKey); | ||
| else | ||
| return NativeConfig.isOverridden(mFile, mSection, mKey); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isRuntimeEditable() | ||
| { | ||
| for (IntSetting setting : NOT_RUNTIME_EDITABLE) | ||
| { | ||
| if (setting == this) | ||
| return false; | ||
| } | ||
|
|
||
| return NativeConfig.isSettingSaveable(mFile, mSection, mKey); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean delete(Settings settings) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| return NativeConfig.deleteKey(settings.getActiveLayer(), mFile, mSection, mKey); | ||
| } | ||
| else | ||
| { | ||
| return settings.getSection(mFile, mSection).delete(mKey); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public int getInt(Settings settings) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| return NativeConfig.getInt(settings.getActiveLayer(), mFile, mSection, mKey, mDefaultValue); | ||
| } | ||
| else | ||
| { | ||
| return settings.getSection(mFile, mSection).getInt(mKey, mDefaultValue); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void setInt(Settings settings, int newValue) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| NativeConfig.setInt(settings.getActiveLayer(), mFile, mSection, mKey, newValue); | ||
| } | ||
| else | ||
| { | ||
| settings.getSection(mFile, mSection).setInt(mKey, newValue); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model; | ||
|
|
||
| public class NativeConfig | ||
| { | ||
| public static final int LAYER_BASE_OR_CURRENT = 0; | ||
| public static final int LAYER_LOCAL_GAME = 1; | ||
|
|
||
| public static native boolean isSettingSaveable(String file, String section, String key); | ||
|
|
||
| public static native void loadGameInis(String gameId, int revision); | ||
|
|
||
| public static native void unloadGameInis(); | ||
|
|
||
| public static native void save(int layer); | ||
|
|
||
| public static native boolean isOverridden(String file, String section, String key); | ||
|
|
||
| public static native boolean deleteKey(int layer, String file, String section, String key); | ||
|
|
||
| public static native String getString(int layer, String file, String section, String key, | ||
| String defaultValue); | ||
|
|
||
| public static native boolean getBoolean(int layer, String file, String section, String key, | ||
| boolean defaultValue); | ||
|
|
||
| public static native int getInt(int layer, String file, String section, String key, | ||
| int defaultValue); | ||
|
|
||
| public static native float getFloat(int layer, String file, String section, String key, | ||
| float defaultValue); | ||
|
|
||
| public static native void setString(int layer, String file, String section, String key, | ||
| String value); | ||
|
|
||
| public static native void setBoolean(int layer, String file, String section, String key, | ||
| boolean value); | ||
|
|
||
| public static native void setInt(int layer, String file, String section, String key, int value); | ||
|
|
||
| public static native void setFloat(int layer, String file, String section, String key, | ||
| float value); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model; | ||
|
|
||
| import org.dolphinemu.dolphinemu.NativeLibrary; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| 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 static final StringSetting[] NOT_RUNTIME_EDITABLE_ARRAY = new StringSetting[]{ | ||
| MAIN_GFX_BACKEND, | ||
| }; | ||
|
|
||
| private static final Set<StringSetting> NOT_RUNTIME_EDITABLE = | ||
| new HashSet<>(Arrays.asList(NOT_RUNTIME_EDITABLE_ARRAY)); | ||
|
|
||
| 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 isOverridden(Settings settings) | ||
| { | ||
| if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| return settings.getSection(mFile, mSection).exists(mKey); | ||
| else | ||
| return NativeConfig.isOverridden(mFile, mSection, mKey); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isRuntimeEditable() | ||
| { | ||
| for (StringSetting setting : NOT_RUNTIME_EDITABLE) | ||
| { | ||
| if (setting == this) | ||
| return false; | ||
| } | ||
|
|
||
| return NativeConfig.isSettingSaveable(mFile, mSection, mKey); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean delete(Settings settings) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| return NativeConfig.deleteKey(settings.getActiveLayer(), mFile, mSection, mKey); | ||
| } | ||
| else | ||
| { | ||
| return settings.getSection(mFile, mSection).delete(mKey); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String getString(Settings settings) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| return NativeConfig.getString(settings.getActiveLayer(), mFile, mSection, mKey, | ||
| mDefaultValue); | ||
| } | ||
| else | ||
| { | ||
| return settings.getSection(mFile, mSection).getString(mKey, mDefaultValue); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void setString(Settings settings, String newValue) | ||
| { | ||
| if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) | ||
| { | ||
| NativeConfig.setString(settings.getActiveLayer(), mFile, mSection, mKey, newValue); | ||
| } | ||
| else | ||
| { | ||
| settings.getSection(mFile, mSection).setString(mKey, newValue); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,38 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model.view; | ||
|
|
||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.Settings; | ||
|
|
||
| public class CheckBoxSetting extends SettingsItem | ||
| { | ||
| protected AbstractBooleanSetting mSetting; | ||
|
|
||
| public CheckBoxSetting(AbstractBooleanSetting setting, int titleId, int descriptionId) | ||
| { | ||
| super(titleId, descriptionId); | ||
| mSetting = setting; | ||
| } | ||
|
|
||
| public boolean isChecked(Settings settings) | ||
| { | ||
| return mSetting.getBoolean(settings); | ||
| } | ||
|
|
||
| public void setChecked(Settings settings, boolean checked) | ||
| { | ||
| mSetting.setBoolean(settings, checked); | ||
| } | ||
|
|
||
| @Override | ||
| public int getType() | ||
| { | ||
| return TYPE_CHECKBOX; | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractSetting getSetting() | ||
| { | ||
| return mSetting; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,56 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model.view; | ||
|
|
||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractStringSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.Settings; | ||
|
|
||
| import androidx.annotation.Nullable; | ||
|
|
||
| public final class FilePicker extends SettingsItem | ||
| { | ||
| private AbstractStringSetting mSetting; | ||
| private int mRequestType; | ||
| private String mDefaultPathRelativeToUserDirectory; | ||
|
|
||
| public FilePicker(AbstractStringSetting setting, int titleId, int descriptionId, int requestType, | ||
| @Nullable String defaultPathRelativeToUserDirectory) | ||
| { | ||
| super(titleId, descriptionId); | ||
| mSetting = setting; | ||
| mRequestType = requestType; | ||
| mDefaultPathRelativeToUserDirectory = defaultPathRelativeToUserDirectory; | ||
| } | ||
|
|
||
| public String getSelectedValue(Settings settings) | ||
| { | ||
| return mSetting.getString(settings); | ||
| } | ||
|
|
||
| public void setSelectedValue(Settings settings, String selection) | ||
| { | ||
| mSetting.setString(settings, selection); | ||
| } | ||
|
|
||
| public int getRequestType() | ||
| { | ||
| return mRequestType; | ||
| } | ||
|
|
||
| @Nullable | ||
| public String getDefaultPathRelativeToUserDirectory() | ||
| { | ||
| return mDefaultPathRelativeToUserDirectory; | ||
| } | ||
|
|
||
| @Override | ||
| public int getType() | ||
| { | ||
| return TYPE_FILE_PICKER; | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractSetting getSetting() | ||
| { | ||
| return mSetting; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,33 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model.view; | ||
|
|
||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.Settings; | ||
|
|
||
| public class FloatSliderSetting extends SliderSetting | ||
| { | ||
| protected AbstractFloatSetting mSetting; | ||
|
|
||
| public FloatSliderSetting(AbstractFloatSetting setting, int titleId, int descriptionId, int max, | ||
| String units) | ||
| { | ||
| super(titleId, descriptionId, max, units); | ||
| mSetting = setting; | ||
| } | ||
|
|
||
| public int getSelectedValue(Settings settings) | ||
| { | ||
| return Math.round(mSetting.getFloat(settings)); | ||
| } | ||
|
|
||
| public void setSelectedValue(Settings settings, float selection) | ||
| { | ||
| mSetting.setFloat(settings, selection); | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractSetting getSetting() | ||
| { | ||
| return mSetting; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,23 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model.view; | ||
|
|
||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; | ||
|
|
||
| public final class HeaderSetting extends SettingsItem | ||
| { | ||
| public HeaderSetting(int titleId, int descriptionId) | ||
| { | ||
| super(titleId, descriptionId); | ||
| } | ||
|
|
||
| @Override | ||
| public int getType() | ||
| { | ||
| return SettingsItem.TYPE_HEADER; | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractSetting getSetting() | ||
| { | ||
| return null; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,33 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model.view; | ||
|
|
||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.Settings; | ||
|
|
||
| public final class IntSliderSetting extends SliderSetting | ||
| { | ||
| private AbstractIntSetting mSetting; | ||
|
|
||
| public IntSliderSetting(AbstractIntSetting setting, int titleId, int descriptionId, int max, | ||
| String units) | ||
| { | ||
| super(titleId, descriptionId, max, units); | ||
| mSetting = setting; | ||
| } | ||
|
|
||
| public int getSelectedValue(Settings settings) | ||
| { | ||
| return mSetting.getInt(settings); | ||
| } | ||
|
|
||
| public void setSelectedValue(Settings settings, int selection) | ||
| { | ||
| mSetting.setInt(settings, selection); | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractSetting getSetting() | ||
| { | ||
| return mSetting; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,32 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model.view; | ||
|
|
||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.Settings; | ||
|
|
||
| public final class InvertedCheckBoxSetting extends CheckBoxSetting | ||
| { | ||
| public InvertedCheckBoxSetting(AbstractBooleanSetting setting, int titleId, | ||
| int descriptionId) | ||
| { | ||
| super(setting, titleId, descriptionId); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isChecked(Settings settings) | ||
| { | ||
| return !mSetting.getBoolean(settings); | ||
| } | ||
|
|
||
| @Override | ||
| public void setChecked(Settings settings, boolean checked) | ||
| { | ||
| mSetting.setBoolean(settings, !checked); | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractSetting getSetting() | ||
| { | ||
| return mSetting; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model.view; | ||
|
|
||
| import org.dolphinemu.dolphinemu.features.settings.model.AdHocBooleanSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.Settings; | ||
|
|
||
| public class LogCheckBoxSetting extends CheckBoxSetting | ||
| { | ||
| String mKey; | ||
|
|
||
| public LogCheckBoxSetting(String key, int titleId, int descriptionId) | ||
| { | ||
| super(new AdHocBooleanSetting(Settings.FILE_LOGGER, Settings.SECTION_LOGGER_LOGS, key, false), | ||
| titleId, descriptionId); | ||
| mKey = key; | ||
| } | ||
|
|
||
| public String getKey() | ||
| { | ||
| return mKey; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,32 @@ | ||
| package org.dolphinemu.dolphinemu.features.settings.model.view; | ||
|
|
||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; | ||
| import org.dolphinemu.dolphinemu.features.settings.model.Settings; | ||
|
|
||
| public final class PercentSliderSetting extends FloatSliderSetting | ||
| { | ||
| public PercentSliderSetting(AbstractFloatSetting setting, int titleId, int descriptionId, int max, | ||
| String units) | ||
| { | ||
| super(setting, titleId, descriptionId, max, units); | ||
| } | ||
|
|
||
| @Override | ||
| public int getSelectedValue(Settings settings) | ||
| { | ||
| return Math.round(mSetting.getFloat(settings) * 100); | ||
| } | ||
|
|
||
| @Override | ||
| public void setSelectedValue(Settings settings, float selection) | ||
| { | ||
| mSetting.setFloat(settings, selection / 100); | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractSetting getSetting() | ||
| { | ||
| return mSetting; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -193,9 +193,9 @@ public Settings getSettings() | ||
| } | ||
|
|
||
| @Override | ||
| public void onSettingChanged() | ||
| { | ||
| mActivity.onSettingChanged(); | ||
| } | ||
|
|
||
| @Override | ||