From 53e7090f5559106875ee5d1170a641439df66379 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 11 Mar 2023 17:14:01 +0100 Subject: [PATCH 1/5] Migrate game INI profile setting to new config system --- .../settings/model/AbstractLegacySetting.java | 37 ------------------- .../settings/model/LegacyStringSetting.java | 28 -------------- .../features/settings/model/Settings.java | 1 + .../ui/SettingsFragmentPresenter.java | 4 +- Source/Android/jni/Config/NativeConfig.cpp | 4 ++ Source/Core/Common/Config/Config.cpp | 3 +- Source/Core/Common/Config/Enums.h | 1 + .../Core/ConfigLoaders/BaseConfigLoader.cpp | 3 ++ .../Core/ConfigLoaders/GameConfigLoader.cpp | 1 + .../Core/ConfigLoaders/IsSettingSaveable.cpp | 3 +- 10 files changed, 16 insertions(+), 69 deletions(-) delete mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractLegacySetting.java delete mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyStringSetting.java 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 deleted file mode 100644 index 94925b89f0..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractLegacySetting.java +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -package org.dolphinemu.dolphinemu.features.settings.model; - -import androidx.annotation.NonNull; - -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 isOverridden(@NonNull Settings settings) - { - return settings.isGameSpecific() && settings.getSection(mFile, mSection).exists(mKey); - } - - @Override - public boolean isRuntimeEditable() - { - return false; - } - - @Override - public boolean delete(@NonNull Settings settings) - { - return settings.getSection(mFile, mSection).delete(mKey); - } -} 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 deleted file mode 100644 index f73c747216..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/LegacyStringSetting.java +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -package org.dolphinemu.dolphinemu.features.settings.model; - -import androidx.annotation.NonNull; - -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; - } - - @NonNull @Override - public String getString(@NonNull Settings settings) - { - return settings.getSection(mFile, mSection).getString(mKey, mDefaultValue); - } - - @Override - public void setString(@NonNull Settings settings, @NonNull String newValue) - { - settings.getSection(mFile, mSection).setString(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 fb5e16965b..6b9cf5226c 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 @@ -26,6 +26,7 @@ public class Settings implements Closeable public static final String FILE_GFX = "GFX"; public static final String FILE_LOGGER = "Logger"; public static final String FILE_WIIMOTE = "WiimoteNew"; + public static final String FILE_GAME_SETTINGS_ONLY = "GameSettingsOnly"; public static final String SECTION_INI_ANDROID = "Android"; public static final String SECTION_INI_ANDROID_OVERLAY_BUTTONS = "AndroidOverlayButtons"; 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 cd39f8c10f..19b3178ac0 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 @@ -29,10 +29,10 @@ import org.dolphinemu.dolphinemu.features.input.ui.ProfileDialogPresenter; import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting; import org.dolphinemu.dolphinemu.features.settings.model.AdHocBooleanSetting; +import org.dolphinemu.dolphinemu.features.settings.model.AdHocStringSetting; 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.LegacyStringSetting; import org.dolphinemu.dolphinemu.features.settings.model.PostProcessing; import org.dolphinemu.dolphinemu.features.settings.model.ScaledIntSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; @@ -1198,7 +1198,7 @@ public final class SettingsFragmentPresenter String[] profiles = new ProfileDialogPresenter(mMenuTag).getProfileNames(false); String profileKey = profileString + "Profile" + controllerNumber; sl.add(new StringSingleChoiceSetting(mContext, - new LegacyStringSetting("", "Controls", profileKey, ""), + new AdHocStringSetting(Settings.FILE_GAME_SETTINGS_ONLY, "Controls", profileKey, ""), R.string.input_profile, 0, profiles, profiles, R.string.input_profiles_empty)); } diff --git a/Source/Android/jni/Config/NativeConfig.cpp b/Source/Android/jni/Config/NativeConfig.cpp index f707e91f5b..3c67eb3af4 100644 --- a/Source/Android/jni/Config/NativeConfig.cpp +++ b/Source/Android/jni/Config/NativeConfig.cpp @@ -43,6 +43,10 @@ static Config::Location GetLocation(JNIEnv* env, jstring file, jstring section, { system = Config::System::WiiPad; } + else if (decoded_file == "GameSettingsOnly") + { + system = Config::System::GameSettingsOnly; + } else { ASSERT(false); diff --git a/Source/Core/Common/Config/Config.cpp b/Source/Core/Common/Config/Config.cpp index 67b21ea33b..4a55ab5b7b 100644 --- a/Source/Core/Common/Config/Config.cpp +++ b/Source/Core/Common/Config/Config.cpp @@ -159,7 +159,8 @@ static const std::map system_to_name = { {System::SYSCONF, "SYSCONF"}, {System::DualShockUDPClient, "DualShockUDPClient"}, {System::FreeLook, "FreeLook"}, - {System::Session, "Session"}}; + {System::Session, "Session"}, + {System::GameSettingsOnly, "GameSettingsOnly"}}; const std::string& GetSystemName(System system) { diff --git a/Source/Core/Common/Config/Enums.h b/Source/Core/Common/Config/Enums.h index 8f224e50d6..1f6d0a1966 100644 --- a/Source/Core/Common/Config/Enums.h +++ b/Source/Core/Common/Config/Enums.h @@ -33,6 +33,7 @@ enum class System DualShockUDPClient, FreeLook, Session, + GameSettingsOnly, }; constexpr std::array SEARCH_ORDER{{ diff --git a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp index 7b9d1c2782..acce10521b 100644 --- a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp @@ -159,6 +159,9 @@ public: if (location.system == Config::System::Session) continue; + if (location.system == Config::System::GameSettingsOnly) + continue; + auto ini = inis.find(location.system); if (ini == inis.end()) { diff --git a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp index 62fe3e5968..7b6466b20f 100644 --- a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp @@ -104,6 +104,7 @@ static const INIToSectionMap& GetINIToSectionMap() {"Video_Stereoscopy", {Config::System::GFX, "Stereoscopy"}}, {"Video_Hacks", {Config::System::GFX, "Hacks"}}, {"Video", {Config::System::GFX, "GameSpecific"}}, + {"Controls", {Config::System::GameSettingsOnly, "Controls"}}, }; return ini_to_section; } diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 01e278d576..d7746baa41 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -18,7 +18,8 @@ bool IsSettingSaveable(const Config::Location& config_location) { for (Config::System system : {Config::System::SYSCONF, Config::System::GFX, Config::System::DualShockUDPClient, - Config::System::Logger, Config::System::FreeLook, Config::System::Main}) + Config::System::Logger, Config::System::FreeLook, Config::System::Main, + Config::System::GameSettingsOnly}) { if (config_location.system == system) return true; From 68fd133057edc70fccf91c6757c5f1d929cc5ab0 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 11 Mar 2023 17:48:42 +0100 Subject: [PATCH 2/5] Android: Remove support for the old config system All settings that we care about from an Android perspective are now supported by the new config system, so we can remove all the Android code for the old config system. This should have no impact on users. --- .../settings/model/BooleanSetting.java | 54 +++++------- .../features/settings/model/FloatSetting.java | 36 +++----- .../features/settings/model/IntSetting.java | 42 ++++----- .../features/settings/model/NativeConfig.java | 4 + .../features/settings/model/Settings.java | 88 ++----------------- .../settings/model/StringSetting.java | 35 ++------ .../settings/ui/SettingsActivity.java | 2 +- .../ui/SettingsActivityPresenter.java | 6 +- Source/Android/jni/Config/NativeConfig.cpp | 22 +++-- 9 files changed, 95 insertions(+), 194 deletions(-) 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 cbaa7a4292..ad54b93a61 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 @@ -298,10 +298,7 @@ public enum BooleanSetting implements AbstractBooleanSetting @Override public boolean isOverridden(@NonNull Settings settings) { - if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey)) - return settings.getSection(mFile, mSection).exists(mKey); - else - return NativeConfig.isOverridden(mFile, mSection, mKey); + return NativeConfig.isOverridden(mFile, mSection, mKey); } @Override @@ -322,53 +319,42 @@ public enum BooleanSetting implements AbstractBooleanSetting @Override public boolean delete(@NonNull Settings settings) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) + if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) { - return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey); - } - else - { - return settings.getSection(mFile, mSection).delete(mKey); + throw new UnsupportedOperationException( + "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey); } + + return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey); } @Override public boolean getBoolean(@NonNull Settings settings) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) - { - return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, - mDefaultValue); - } - else - { - return settings.getSection(mFile, mSection).getBoolean(mKey, mDefaultValue); - } + return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); } @Override public void setBoolean(@NonNull Settings settings, boolean newValue) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) + if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) { - NativeConfig.setBoolean(settings.getWriteLayer(), mFile, mSection, mKey, newValue); - } - else - { - settings.getSection(mFile, mSection).setBoolean(mKey, newValue); + throw new UnsupportedOperationException( + "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey); } + + NativeConfig.setBoolean(settings.getWriteLayer(), mFile, mSection, mKey, newValue); } public void setBoolean(int layerType, boolean newValue) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) + if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) { - NativeConfig.setBoolean(layerType, mFile, mSection, mKey, newValue); - } - else - { - throw new UnsupportedOperationException("The old config system doesn't support layers"); + throw new UnsupportedOperationException( + "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey); } + + NativeConfig.setBoolean(layerType, mFile, mSection, mKey, newValue); } public boolean getBooleanGlobal() @@ -378,6 +364,12 @@ public enum BooleanSetting implements AbstractBooleanSetting public void setBooleanGlobal(int layer, boolean newValue) { + if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) + { + throw new UnsupportedOperationException( + "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey); + } + NativeConfig.setBoolean(layer, mFile, mSection, 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 3bcb3e34c1..734839f8ec 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 @@ -27,10 +27,7 @@ public enum FloatSetting implements AbstractFloatSetting @Override public boolean isOverridden(@NonNull Settings settings) { - if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey)) - return settings.getSection(mFile, mSection).exists(mKey); - else - return NativeConfig.isOverridden(mFile, mSection, mKey); + return NativeConfig.isOverridden(mFile, mSection, mKey); } @Override @@ -42,40 +39,31 @@ public enum FloatSetting implements AbstractFloatSetting @Override public boolean delete(@NonNull Settings settings) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) + if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) { - return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey); - } - else - { - return settings.getSection(mFile, mSection).delete(mKey); + throw new UnsupportedOperationException( + "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey); } + + return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey); } @Override public float getFloat(@NonNull Settings settings) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) - { - return NativeConfig.getFloat(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); - } - else - { - return settings.getSection(mFile, mSection).getFloat(mKey, mDefaultValue); - } + return NativeConfig.getFloat(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); } @Override public void setFloat(@NonNull Settings settings, float newValue) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) + if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) { - NativeConfig.setFloat(settings.getWriteLayer(), mFile, mSection, mKey, newValue); - } - else - { - settings.getSection(mFile, mSection).setFloat(mKey, newValue); + throw new UnsupportedOperationException( + "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey); } + + NativeConfig.setFloat(settings.getWriteLayer(), mFile, mSection, mKey, newValue); } public float getFloatGlobal() 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 77cf7b339a..6c3c565552 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 @@ -123,10 +123,7 @@ public enum IntSetting implements AbstractIntSetting @Override public boolean isOverridden(@NonNull Settings settings) { - if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey)) - return settings.getSection(mFile, mSection).exists(mKey); - else - return NativeConfig.isOverridden(mFile, mSection, mKey); + return NativeConfig.isOverridden(mFile, mSection, mKey); } @Override @@ -147,40 +144,31 @@ public enum IntSetting implements AbstractIntSetting @Override public boolean delete(@NonNull Settings settings) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) + if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) { - return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey); - } - else - { - return settings.getSection(mFile, mSection).delete(mKey); + throw new UnsupportedOperationException( + "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey); } + + return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey); } @Override public int getInt(@NonNull Settings settings) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) - { - return NativeConfig.getInt(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); - } - else - { - return settings.getSection(mFile, mSection).getInt(mKey, mDefaultValue); - } + return NativeConfig.getInt(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); } @Override public void setInt(@NonNull Settings settings, int newValue) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) + if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) { - NativeConfig.setInt(settings.getWriteLayer(), mFile, mSection, mKey, newValue); - } - else - { - settings.getSection(mFile, mSection).setInt(mKey, newValue); + throw new UnsupportedOperationException( + "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey); } + + NativeConfig.setInt(settings.getWriteLayer(), mFile, mSection, mKey, newValue); } public int getIntGlobal() @@ -190,6 +178,12 @@ public enum IntSetting implements AbstractIntSetting public void setIntGlobal(int layer, int newValue) { + if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) + { + throw new UnsupportedOperationException( + "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey); + } + NativeConfig.setInt(layer, mFile, mSection, mKey, newValue); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/NativeConfig.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/NativeConfig.java index 07646a2eb8..7fbe96f95e 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/NativeConfig.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/NativeConfig.java @@ -18,10 +18,14 @@ public class NativeConfig public static native void save(int layer); + public static native void deleteAllKeys(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 boolean exists(int layer, String file, String section, String key); + public static native String getString(int layer, String file, String section, String key, String defaultValue); 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 6b9cf5226c..480dee0174 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 @@ -10,14 +10,9 @@ import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.input.model.MappingCommon; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivityView; -import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile; import org.dolphinemu.dolphinemu.services.GameFileCacheManager; -import org.dolphinemu.dolphinemu.utils.DirectoryInitialization; -import org.dolphinemu.dolphinemu.utils.IniFile; import java.io.Closeable; -import java.util.HashMap; -import java.util.Map; public class Settings implements Closeable { @@ -52,40 +47,14 @@ public class Settings implements Closeable public static final String SECTION_ANALYTICS = "Analytics"; - public static final String GAME_SETTINGS_PLACEHOLDER_FILE_NAME = ""; - private String mGameId; private int mRevision; private boolean mIsWii; - private static final String[] configFiles = new String[]{FILE_DOLPHIN, FILE_GFX, FILE_LOGGER, - FILE_WIIMOTE}; - - private Map mIniFiles = new HashMap<>(); + private boolean mSettingsLoaded = false; private boolean mLoadedRecursiveIsoPathsValue = false; - private IniFile getGameSpecificFile() - { - if (!isGameSpecific() || mIniFiles.size() != 1) - throw new IllegalStateException(); - - return mIniFiles.get(GAME_SETTINGS_PLACEHOLDER_FILE_NAME); - } - - public IniFile.Section getSection(String fileName, String sectionName) - { - if (!isGameSpecific()) - { - return mIniFiles.get(fileName).getOrCreateSection(sectionName); - } - else - { - return getGameSpecificFile() - .getOrCreateSection(SettingsFile.mapSectionNameFromIni(sectionName)); - } - } - public boolean isGameSpecific() { return !TextUtils.isEmpty(mGameId); @@ -101,9 +70,9 @@ public class Settings implements Closeable return isGameSpecific() ? NativeConfig.LAYER_LOCAL_GAME : NativeConfig.LAYER_BASE_OR_CURRENT; } - public boolean isEmpty() + public boolean areSettingsLoaded() { - return mIniFiles.isEmpty(); + return mSettingsLoaded; } public void loadSettings() @@ -115,43 +84,20 @@ public class Settings implements Closeable public void loadSettings(SettingsActivityView view, boolean isWii) { mIsWii = isWii; + mSettingsLoaded = true; - mIniFiles = new HashMap<>(); - - if (!isGameSpecific()) - { - loadDolphinSettings(view); - } - else + if (isGameSpecific()) { // Loading game INIs while the core is running will mess with the game INIs loaded by the core if (NativeLibrary.IsRunning()) throw new IllegalStateException("Attempted to load game INI while emulating"); NativeConfig.loadGameInis(mGameId, mRevision); - loadCustomGameSettings(mGameId, view); } mLoadedRecursiveIsoPathsValue = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(this); } - private void loadDolphinSettings(SettingsActivityView view) - { - for (String fileName : configFiles) - { - IniFile ini = new IniFile(); - SettingsFile.readFile(fileName, ini, view); - mIniFiles.put(fileName, ini); - } - } - - private void loadCustomGameSettings(String gameId, SettingsActivityView view) - { - IniFile ini = new IniFile(); - SettingsFile.readCustomGameSettings(gameId, ini, view); - mIniFiles.put(GAME_SETTINGS_PLACEHOLDER_FILE_NAME, ini); - } - public void loadSettings(SettingsActivityView view, String gameId, int revision, boolean isWii) { mGameId = gameId; @@ -166,22 +112,10 @@ public class Settings implements Closeable if (context != null) Toast.makeText(context, R.string.settings_saved, Toast.LENGTH_SHORT).show(); - for (Map.Entry entry : mIniFiles.entrySet()) - { - SettingsFile.saveFile(entry.getKey(), entry.getValue(), view); - } - MappingCommon.save(); NativeConfig.save(NativeConfig.LAYER_BASE); - if (!NativeLibrary.IsRunning()) - { - // Notify the native code of the changes to legacy settings - NativeLibrary.ReloadConfig(); - } - - // LogManager does use the new config system, but doesn't pick up on changes automatically NativeLibrary.ReloadLoggerConfig(); NativeLibrary.UpdateGCAdapterScanThread(); @@ -201,18 +135,13 @@ public class Settings implements Closeable Toast.LENGTH_SHORT).show(); } - SettingsFile.saveCustomGameSettings(mGameId, getGameSpecificFile()); - NativeConfig.save(NativeConfig.LAYER_LOCAL_GAME); } } - public void clearSettings() + public void clearGameSettings() { - for (String fileName : mIniFiles.keySet()) - { - mIniFiles.put(fileName, new IniFile()); - } + NativeConfig.deleteAllKeys(NativeConfig.LAYER_LOCAL_GAME); } public boolean gameIniContainsJunk() @@ -238,7 +167,8 @@ public class Settings implements Closeable if (!isGameSpecific()) return false; - return getSection(Settings.FILE_DOLPHIN, SECTION_INI_INTERFACE).exists("ThemeName"); + return NativeConfig.exists(NativeConfig.LAYER_LOCAL_GAME, FILE_DOLPHIN, SECTION_INI_INTERFACE, + "ThemeName"); } @Override 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 127852c640..88b37dbbd9 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 @@ -67,10 +67,7 @@ public enum StringSetting implements AbstractStringSetting @Override public boolean isOverridden(@NonNull Settings settings) { - if (settings.isGameSpecific() && !NativeConfig.isSettingSaveable(mFile, mSection, mKey)) - return settings.getSection(mFile, mSection).exists(mKey); - else - return NativeConfig.isOverridden(mFile, mSection, mKey); + return NativeConfig.isOverridden(mFile, mSection, mKey); } @Override @@ -88,41 +85,25 @@ public enum StringSetting implements AbstractStringSetting @Override public boolean delete(@NonNull Settings settings) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) - { - return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey); - } - else - { - return settings.getSection(mFile, mSection).delete(mKey); - } + return NativeConfig.deleteKey(settings.getWriteLayer(), mFile, mSection, mKey); } @NonNull @Override public String getString(@NonNull Settings settings) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) + if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) { - return NativeConfig.getString(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, - mDefaultValue); - } - else - { - return settings.getSection(mFile, mSection).getString(mKey, mDefaultValue); + throw new UnsupportedOperationException( + "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey); } + + return NativeConfig.getString(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); } @Override public void setString(@NonNull Settings settings, @NonNull String newValue) { - if (NativeConfig.isSettingSaveable(mFile, mSection, mKey)) - { - NativeConfig.setString(settings.getWriteLayer(), mFile, mSection, mKey, newValue); - } - else - { - settings.getSection(mFile, mSection).setString(mKey, newValue); - } + NativeConfig.setString(settings.getWriteLayer(), mFile, mSection, mKey, newValue); } public String getStringGlobal() diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java index bce24c1c46..4f1e4bdf45 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java @@ -276,7 +276,7 @@ public final class SettingsActivity extends AppCompatActivity implements Setting new MaterialAlertDialogBuilder(this) .setTitle(getString(R.string.game_ini_junk_title)) .setMessage(getString(R.string.game_ini_junk_question)) - .setPositiveButton(R.string.yes, (dialogInterface, i) -> mPresenter.clearSettings()) + .setPositiveButton(R.string.yes, (dialogInterface, i) -> mPresenter.clearGameSettings()) .setNegativeButton(R.string.no, null) .show(); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java index cc235b9863..1b50754fdd 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java @@ -66,7 +66,7 @@ public final class SettingsActivityPresenter { mView.hideLoading(); - if (mSettings.isEmpty()) + if (!mSettings.areSettingsLoaded()) { if (!TextUtils.isEmpty(mGameId)) { @@ -99,9 +99,9 @@ public final class SettingsActivityPresenter return mSettings; } - public void clearSettings() + public void clearGameSettings() { - mSettings.clearSettings(); + mSettings.clearGameSettings(); onSettingChanged(); } diff --git a/Source/Android/jni/Config/NativeConfig.cpp b/Source/Android/jni/Config/NativeConfig.cpp index 3c67eb3af4..9681f0ca8e 100644 --- a/Source/Android/jni/Config/NativeConfig.cpp +++ b/Source/Android/jni/Config/NativeConfig.cpp @@ -138,12 +138,14 @@ Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_unloadGameIn JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_save( JNIEnv*, jclass, jint layer) { - const std::shared_ptr layer_ptr = GetLayer(layer, {}); + return GetLayer(layer, {})->Save(); +} - // Workaround for the Settings class carrying around a legacy map of settings it always saves - layer_ptr->MarkAsDirty(); - - return layer_ptr->Save(); +JNIEXPORT void JNICALL +Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_deleteAllKeys(JNIEnv*, jclass, + jint layer) +{ + return GetLayer(layer, {})->DeleteAllKeys(); } JNIEXPORT jboolean JNICALL @@ -166,6 +168,16 @@ Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_deleteKey( return static_cast(had_value); } +JNIEXPORT jboolean JNICALL +Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_exists(JNIEnv* env, jclass, + jint layer, jstring file, + jstring section, + jstring key) +{ + const Config::Location location = GetLocation(env, file, section, key); + return static_cast(GetLayer(layer, location)->Exists(location)); +} + JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_getString( JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key, From 58fc347f8dd78535beaf9d792bba4f0c6624a7a5 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 11 Mar 2023 18:10:48 +0100 Subject: [PATCH 3/5] Android: Don't require Settings object for reading a setting Made unnecessary by the previous commit. --- .../activities/EmulationActivity.java | 50 ++++++++-------- .../ui/SettingDisabledWarningFragment.kt | 4 +- .../model/ControlGroupEnabledSetting.java | 10 ++-- .../model/InputMappingBooleanSetting.java | 10 ++-- .../model/InputMappingDoubleSetting.java | 10 ++-- .../input/model/InputMappingIntSetting.java | 10 ++-- .../input/model/view/InputDeviceSetting.java | 4 +- .../model/AbstractBooleanSetting.java | 2 +- .../settings/model/AbstractFloatSetting.java | 2 +- .../settings/model/AbstractIntSetting.java | 2 +- .../settings/model/AbstractSetting.java | 2 +- .../settings/model/AbstractStringSetting.java | 2 +- .../settings/model/AdHocBooleanSetting.java | 4 +- .../settings/model/AdHocStringSetting.java | 4 +- .../settings/model/BooleanSetting.java | 4 +- .../features/settings/model/FloatSetting.java | 4 +- .../features/settings/model/IntSetting.java | 4 +- .../settings/model/ScaledIntSetting.kt | 8 +-- .../features/settings/model/Settings.java | 4 +- .../settings/model/StringSetting.java | 4 +- .../model/view/DateTimeChoiceSetting.kt | 4 +- .../settings/model/view/FilePicker.java | 4 +- .../model/view/FloatSliderSetting.java | 4 +- .../model/view/InputStringSetting.java | 4 +- .../settings/model/view/IntSliderSetting.java | 4 +- .../model/view/InvertedSwitchSetting.java | 4 +- .../model/view/PercentSliderSetting.java | 4 +- .../settings/model/view/SettingsItem.java | 4 +- .../model/view/SingleChoiceSetting.java | 4 +- ...ingleChoiceSettingDynamicDescriptions.java | 4 +- .../settings/model/view/SliderSetting.java | 2 +- .../model/view/StringSingleChoiceSetting.java | 12 ++-- .../settings/model/view/SwitchSetting.java | 4 +- .../features/settings/ui/SettingsAdapter.java | 31 +++++----- .../ui/SettingsFragmentPresenter.java | 58 +++++++++---------- .../viewholder/DateTimeSettingViewHolder.kt | 2 +- .../ui/viewholder/FilePickerViewHolder.java | 2 +- .../InputStringSettingViewHolder.java | 2 +- .../ui/viewholder/SettingViewHolder.java | 2 +- .../ui/viewholder/SingleChoiceViewHolder.java | 20 +++---- .../ui/viewholder/SliderViewHolder.java | 5 +- .../viewholder/SwitchSettingViewHolder.java | 13 +---- .../fragments/EmulationFragment.java | 24 ++++---- .../dolphinemu/overlay/InputOverlay.java | 39 ++++++------- 44 files changed, 197 insertions(+), 203 deletions(-) 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 9aebeb1ded..d798a25393 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 @@ -400,7 +400,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP WindowManager.LayoutParams attributes = getWindow().getAttributes(); attributes.layoutInDisplayCutoutMode = - BooleanSetting.MAIN_EXPAND_TO_CUTOUT_AREA.getBoolean(mSettings) ? + BooleanSetting.MAIN_EXPAND_TO_CUTOUT_AREA.getBoolean() ? WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES : WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER; @@ -437,7 +437,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP setTitle(NativeLibrary.GetCurrentTitleDescription()); - mEmulationFragment.refreshInputOverlay(mSettings); + mEmulationFragment.refreshInputOverlay(); } @Override @@ -521,7 +521,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP private void updateOrientation() { - setRequestedOrientation(IntSetting.MAIN_EMULATION_ORIENTATION.getInt(mSettings)); + setRequestedOrientation(IntSetting.MAIN_EMULATION_ORIENTATION.getInt()); } private boolean closeSubmenu() @@ -589,11 +589,11 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP // Populate the switch value for joystick center on touch menu.findItem(R.id.menu_emulation_joystick_rel_center) - .setChecked(BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBoolean(mSettings)); + .setChecked(BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBoolean()); if (wii) { menu.findItem(R.id.menu_emulation_ir_recenter) - .setChecked(BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean(mSettings)); + .setChecked(BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean()); } popup.setOnMenuItemClickListener(this::onOptionsItemSelected); @@ -794,7 +794,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP private void toggleRecenter(boolean state) { BooleanSetting.MAIN_IR_ALWAYS_RECENTER.setBoolean(mSettings, state); - mEmulationFragment.refreshOverlayPointer(mSettings); + mEmulationFragment.refreshOverlayPointer(); } private void editControlsPlacement() @@ -831,7 +831,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this) .setTitle(R.string.emulation_toggle_controls); - int currentController = InputOverlay.getConfiguredControllerType(mSettings); + int currentController = InputOverlay.getConfiguredControllerType(); if (currentController == InputOverlay.OVERLAY_GAMECUBE) { @@ -840,7 +840,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP for (int i = 0; i < gcEnabledButtons.length; i++) { - gcEnabledButtons[i] = BooleanSetting.valueOf(gcSettingBase + i).getBoolean(mSettings); + gcEnabledButtons[i] = BooleanSetting.valueOf(gcSettingBase + i).getBoolean(); } builder.setMultiChoiceItems(R.array.gcpadButtons, gcEnabledButtons, (dialog, indexSelected, isChecked) -> BooleanSetting @@ -854,7 +854,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP for (int i = 0; i < wiiClassicEnabledButtons.length; i++) { wiiClassicEnabledButtons[i] = - BooleanSetting.valueOf(classicSettingBase + i).getBoolean(mSettings); + BooleanSetting.valueOf(classicSettingBase + i).getBoolean(); } builder.setMultiChoiceItems(R.array.classicButtons, wiiClassicEnabledButtons, (dialog, indexSelected, isChecked) -> BooleanSetting @@ -868,7 +868,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP for (int i = 0; i < wiiEnabledButtons.length; i++) { - wiiEnabledButtons[i] = BooleanSetting.valueOf(wiiSettingBase + i).getBoolean(mSettings); + wiiEnabledButtons[i] = BooleanSetting.valueOf(wiiSettingBase + i).getBoolean(); } if (currentController == InputOverlay.OVERLAY_WIIMOTE_NUNCHUK) { @@ -887,15 +887,15 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP builder.setNeutralButton(R.string.emulation_toggle_all, (dialogInterface, i) -> mEmulationFragment.toggleInputOverlayVisibility(mSettings)) .setPositiveButton(R.string.ok, (dialogInterface, i) -> - mEmulationFragment.refreshInputOverlay(mSettings)) + mEmulationFragment.refreshInputOverlay()) .show(); } public void chooseDoubleTapButton() { - int currentValue = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getInt(mSettings); + int currentValue = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getInt(); - int buttonList = InputOverlay.getConfiguredControllerType(mSettings) == + int buttonList = InputOverlay.getConfiguredControllerType() == InputOverlay.OVERLAY_WIIMOTE_CLASSIC ? R.array.doubleTapWithClassic : R.array.doubleTap; int checkedItem = -1; @@ -914,7 +914,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP (DialogInterface dialog, int which) -> IntSetting.MAIN_DOUBLE_TAP_BUTTON.setInt( mSettings, InputOverlayPointer.DOUBLE_TAP_OPTIONS.get(which))) .setPositiveButton(R.string.ok, - (dialogInterface, i) -> mEmulationFragment.initInputPointer(mSettings)) + (dialogInterface, i) -> mEmulationFragment.initInputPointer()) .show(); } @@ -925,7 +925,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP final Slider scaleSlider = dialogBinding.inputScaleSlider; final TextView scaleValue = dialogBinding.inputScaleValue; scaleSlider.setValueTo(150); - scaleSlider.setValue(IntSetting.MAIN_CONTROL_SCALE.getInt(mSettings)); + scaleSlider.setValue(IntSetting.MAIN_CONTROL_SCALE.getInt()); scaleSlider.setStepSize(1); scaleSlider.addOnChangeListener( (slider, progress, fromUser) -> scaleValue.setText(((int) progress + 50) + "%")); @@ -935,7 +935,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP final Slider sliderOpacity = dialogBinding.inputOpacitySlider; final TextView valueOpacity = dialogBinding.inputOpacityValue; sliderOpacity.setValueTo(100); - sliderOpacity.setValue(IntSetting.MAIN_CONTROL_OPACITY.getInt(mSettings)); + sliderOpacity.setValue(IntSetting.MAIN_CONTROL_OPACITY.getInt()); sliderOpacity.setStepSize(1); sliderOpacity.addOnChangeListener( (slider, progress, fromUser) -> valueOpacity.setText(((int) progress) + "%")); @@ -948,13 +948,13 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP { IntSetting.MAIN_CONTROL_SCALE.setInt(mSettings, (int) scaleSlider.getValue()); IntSetting.MAIN_CONTROL_OPACITY.setInt(mSettings, (int) sliderOpacity.getValue()); - mEmulationFragment.refreshInputOverlay(mSettings); + mEmulationFragment.refreshInputOverlay(); }) .setNeutralButton(R.string.default_values, (dialog, which) -> { IntSetting.MAIN_CONTROL_SCALE.delete(mSettings); IntSetting.MAIN_CONTROL_OPACITY.delete(mSettings); - mEmulationFragment.refreshInputOverlay(mSettings); + mEmulationFragment.refreshInputOverlay(); }) .show(); } @@ -962,7 +962,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP private void addControllerIfNotNone(List entries, List values, IntSetting controller, int entry, int value) { - if (controller.getInt(mSettings) != 0) + if (controller.getInt() != 0) { entries.add(getString(entry)); values.add(value); @@ -992,7 +992,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP IntSetting controllerSetting = NativeLibrary.IsEmulatingWii() ? IntSetting.MAIN_OVERLAY_WII_CONTROLLER : IntSetting.MAIN_OVERLAY_GC_CONTROLLER; - int currentValue = controllerSetting.getInt(mSettings); + int currentValue = controllerSetting.getInt(); int checkedItem = -1; for (int i = 0; i < values.size(); i++) @@ -1013,7 +1013,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP .setPositiveButton(R.string.ok, (dialogInterface, i) -> { editor.apply(); - mEmulationFragment.refreshInputOverlay(mSettings); + mEmulationFragment.refreshInputOverlay(); }) .setNeutralButton(R.string.emulation_more_controller_settings, (dialogInterface, i) -> SettingsActivity.launch(this, MenuTag.SETTINGS)) @@ -1025,11 +1025,11 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP new MaterialAlertDialogBuilder(this) .setTitle(R.string.emulation_ir_mode) .setSingleChoiceItems(R.array.irModeEntries, - IntSetting.MAIN_IR_MODE.getInt(mSettings), + IntSetting.MAIN_IR_MODE.getInt(), (dialog, indexSelected) -> IntSetting.MAIN_IR_MODE.setInt(mSettings, indexSelected)) .setPositiveButton(R.string.ok, (dialogInterface, i) -> - mEmulationFragment.refreshOverlayPointer(mSettings)) + mEmulationFragment.refreshOverlayPointer()) .show(); } @@ -1065,7 +1065,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP new MaterialAlertDialogBuilder(this) .setTitle(getString(R.string.emulation_touch_overlay_reset)) .setPositiveButton(R.string.yes, - (dialogInterface, i) -> mEmulationFragment.resetInputOverlay(mSettings)) + (dialogInterface, i) -> mEmulationFragment.resetInputOverlay()) .setNegativeButton(R.string.cancel, null) .show(); } @@ -1160,7 +1160,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP public void initInputPointer() { - mEmulationFragment.initInputPointer(mSettings); + mEmulationFragment.initInputPointer(); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/SettingDisabledWarningFragment.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/SettingDisabledWarningFragment.kt index f67b0f3862..737a931a85 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/SettingDisabledWarningFragment.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/SettingDisabledWarningFragment.kt @@ -42,8 +42,8 @@ abstract class SettingDisabledWarningFragment( override fun onResume() { super.onResume() val activity = requireActivity() as CheatsActivity - activity.loadGameSpecificSettings().use { settings -> - val cheatsEnabled = setting.getBoolean(settings) + activity.loadGameSpecificSettings().use { + val cheatsEnabled = setting.getBoolean() requireView().visibility = if (cheatsEnabled) View.GONE else View.VISIBLE } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControlGroupEnabledSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControlGroupEnabledSetting.java index 95aa080429..2e22ce84aa 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControlGroupEnabledSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControlGroupEnabledSetting.java @@ -2,6 +2,8 @@ package org.dolphinemu.dolphinemu.features.input.model; +import androidx.annotation.NonNull; + import org.dolphinemu.dolphinemu.features.input.model.controlleremu.ControlGroup; import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; @@ -16,19 +18,19 @@ public class ControlGroupEnabledSetting implements AbstractBooleanSetting } @Override - public boolean getBoolean(Settings settings) + public boolean getBoolean() { return mControlGroup.getEnabled(); } @Override - public void setBoolean(Settings settings, boolean newValue) + public void setBoolean(@NonNull Settings settings, boolean newValue) { mControlGroup.setEnabled(newValue); } @Override - public boolean isOverridden(Settings settings) + public boolean isOverridden() { return false; } @@ -40,7 +42,7 @@ public class ControlGroupEnabledSetting implements AbstractBooleanSetting } @Override - public boolean delete(Settings settings) + public boolean delete(@NonNull Settings settings) { boolean newValue = mControlGroup.getDefaultEnabledValue() != ControlGroup.DEFAULT_ENABLED_NO; mControlGroup.setEnabled(newValue); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingBooleanSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingBooleanSetting.java index 7241d6e125..6e80fef6dd 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingBooleanSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingBooleanSetting.java @@ -2,6 +2,8 @@ package org.dolphinemu.dolphinemu.features.input.model; +import androidx.annotation.NonNull; + import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; @@ -16,19 +18,19 @@ public class InputMappingBooleanSetting implements AbstractBooleanSetting } @Override - public boolean getBoolean(Settings settings) + public boolean getBoolean() { return mNumericSetting.getBooleanValue(); } @Override - public void setBoolean(Settings settings, boolean newValue) + public void setBoolean(@NonNull Settings settings, boolean newValue) { mNumericSetting.setBooleanValue(newValue); } @Override - public boolean isOverridden(Settings settings) + public boolean isOverridden() { return false; } @@ -40,7 +42,7 @@ public class InputMappingBooleanSetting implements AbstractBooleanSetting } @Override - public boolean delete(Settings settings) + public boolean delete(@NonNull Settings settings) { mNumericSetting.setBooleanValue(mNumericSetting.getBooleanDefaultValue()); return true; diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.java index e84b61a045..0311e6d2b3 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.java @@ -2,6 +2,8 @@ package org.dolphinemu.dolphinemu.features.input.model; +import androidx.annotation.NonNull; + import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; @@ -17,19 +19,19 @@ public class InputMappingDoubleSetting implements AbstractFloatSetting } @Override - public float getFloat(Settings settings) + public float getFloat() { return (float) mNumericSetting.getDoubleValue(); } @Override - public void setFloat(Settings settings, float newValue) + public void setFloat(@NonNull Settings settings, float newValue) { mNumericSetting.setDoubleValue(newValue); } @Override - public boolean isOverridden(Settings settings) + public boolean isOverridden() { return false; } @@ -41,7 +43,7 @@ public class InputMappingDoubleSetting implements AbstractFloatSetting } @Override - public boolean delete(Settings settings) + public boolean delete(@NonNull Settings settings) { mNumericSetting.setDoubleValue(mNumericSetting.getDoubleDefaultValue()); return true; diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingIntSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingIntSetting.java index 989f2b7cde..176346c63a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingIntSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingIntSetting.java @@ -2,6 +2,8 @@ package org.dolphinemu.dolphinemu.features.input.model; +import androidx.annotation.NonNull; + import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting; import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting; import org.dolphinemu.dolphinemu.features.settings.model.Settings; @@ -16,19 +18,19 @@ public class InputMappingIntSetting implements AbstractIntSetting } @Override - public int getInt(Settings settings) + public int getInt() { return mNumericSetting.getIntValue(); } @Override - public void setInt(Settings settings, int newValue) + public void setInt(@NonNull Settings settings, int newValue) { mNumericSetting.setIntValue(newValue); } @Override - public boolean isOverridden(Settings settings) + public boolean isOverridden() { return false; } @@ -40,7 +42,7 @@ public class InputMappingIntSetting implements AbstractIntSetting } @Override - public boolean delete(Settings settings) + public boolean delete(@NonNull Settings settings) { mNumericSetting.setIntValue(mNumericSetting.getIntDefaultValue()); return true; diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/view/InputDeviceSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/view/InputDeviceSetting.java index e27d0f57ae..3ee7112007 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/view/InputDeviceSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/view/InputDeviceSetting.java @@ -24,13 +24,13 @@ public class InputDeviceSetting extends StringSingleChoiceSetting } @Override - public String getSelectedChoice(Settings settings) + public String getSelectedChoice() { return mController.getDefaultDevice(); } @Override - public String getSelectedValue(Settings settings) + public String getSelectedValue() { return mController.getDefaultDevice(); } 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 index 783d03b14c..22d757d4c6 100644 --- 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 @@ -6,7 +6,7 @@ import androidx.annotation.NonNull; public interface AbstractBooleanSetting extends AbstractSetting { - boolean getBoolean(@NonNull Settings settings); + boolean getBoolean(); void setBoolean(@NonNull 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 index aba2013b0f..a432c7139b 100644 --- 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 @@ -6,7 +6,7 @@ import androidx.annotation.NonNull; public interface AbstractFloatSetting extends AbstractSetting { - float getFloat(@NonNull Settings settings); + float getFloat(); void setFloat(@NonNull 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 index c79cfa4a2f..dc868d55d9 100644 --- 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 @@ -6,7 +6,7 @@ import androidx.annotation.NonNull; public interface AbstractIntSetting extends AbstractSetting { - int getInt(@NonNull Settings settings); + int getInt(); void setInt(@NonNull Settings settings, int newValue); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractSetting.java index d5723aeafb..9ffaf20544 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AbstractSetting.java @@ -6,7 +6,7 @@ import androidx.annotation.NonNull; public interface AbstractSetting { - boolean isOverridden(@NonNull Settings settings); + boolean isOverridden(); boolean isRuntimeEditable(); 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 index b440636461..9dd9384090 100644 --- 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 @@ -7,7 +7,7 @@ import androidx.annotation.NonNull; public interface AbstractStringSetting extends AbstractSetting { @NonNull - String getString(@NonNull Settings settings); + String getString(); void setString(@NonNull Settings settings, @NonNull String newValue); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AdHocBooleanSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AdHocBooleanSetting.java index 982fc19eeb..c12bc51ca0 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AdHocBooleanSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AdHocBooleanSetting.java @@ -25,7 +25,7 @@ public class AdHocBooleanSetting implements AbstractBooleanSetting } @Override - public boolean isOverridden(@NonNull Settings settings) + public boolean isOverridden() { return NativeConfig.isOverridden(mFile, mSection, mKey); } @@ -43,7 +43,7 @@ public class AdHocBooleanSetting implements AbstractBooleanSetting } @Override - public boolean getBoolean(@NonNull Settings settings) + public boolean getBoolean() { return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AdHocStringSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AdHocStringSetting.java index d53f4abd6f..fdba08af71 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AdHocStringSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/AdHocStringSetting.java @@ -25,7 +25,7 @@ public class AdHocStringSetting implements AbstractStringSetting } @Override - public boolean isOverridden(@NonNull Settings settings) + public boolean isOverridden() { return NativeConfig.isOverridden(mFile, mSection, mKey); } @@ -43,7 +43,7 @@ public class AdHocStringSetting implements AbstractStringSetting } @NonNull @Override - public String getString(@NonNull Settings settings) + public String getString() { return NativeConfig.getString(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); } 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 ad54b93a61..4f0f53643e 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 @@ -296,7 +296,7 @@ public enum BooleanSetting implements AbstractBooleanSetting } @Override - public boolean isOverridden(@NonNull Settings settings) + public boolean isOverridden() { return NativeConfig.isOverridden(mFile, mSection, mKey); } @@ -329,7 +329,7 @@ public enum BooleanSetting implements AbstractBooleanSetting } @Override - public boolean getBoolean(@NonNull Settings settings) + public boolean getBoolean() { return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); } 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 734839f8ec..726e92f1e7 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 @@ -25,7 +25,7 @@ public enum FloatSetting implements AbstractFloatSetting } @Override - public boolean isOverridden(@NonNull Settings settings) + public boolean isOverridden() { return NativeConfig.isOverridden(mFile, mSection, mKey); } @@ -49,7 +49,7 @@ public enum FloatSetting implements AbstractFloatSetting } @Override - public float getFloat(@NonNull Settings settings) + public float getFloat() { return NativeConfig.getFloat(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); } 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 6c3c565552..f17e96d2fd 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 @@ -121,7 +121,7 @@ public enum IntSetting implements AbstractIntSetting } @Override - public boolean isOverridden(@NonNull Settings settings) + public boolean isOverridden() { return NativeConfig.isOverridden(mFile, mSection, mKey); } @@ -154,7 +154,7 @@ public enum IntSetting implements AbstractIntSetting } @Override - public int getInt(@NonNull Settings settings) + public int getInt() { return NativeConfig.getInt(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/ScaledIntSetting.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/ScaledIntSetting.kt index 0888235f56..91b69b8fc3 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/ScaledIntSetting.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/ScaledIntSetting.kt @@ -6,8 +6,8 @@ class ScaledIntSetting( private val scale: Int, private val setting: AbstractIntSetting ) : AbstractIntSetting { - override fun isOverridden(settings: Settings): Boolean { - return setting.isOverridden(settings) + override fun isOverridden(): Boolean { + return setting.isOverridden() } override fun isRuntimeEditable(): Boolean { @@ -18,8 +18,8 @@ class ScaledIntSetting( return setting.delete(settings) } - override fun getInt(settings: Settings): Int { - return setting.getInt(settings) / scale + override fun getInt(): Int { + return setting.getInt() / scale } override fun setInt(settings: Settings, newValue: Int) { 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 480dee0174..a67dd63acc 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 @@ -95,7 +95,7 @@ public class Settings implements Closeable NativeConfig.loadGameInis(mGameId, mRevision); } - mLoadedRecursiveIsoPathsValue = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(this); + mLoadedRecursiveIsoPathsValue = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(); } public void loadSettings(SettingsActivityView view, String gameId, int revision, boolean isWii) @@ -119,7 +119,7 @@ public class Settings implements Closeable NativeLibrary.ReloadLoggerConfig(); NativeLibrary.UpdateGCAdapterScanThread(); - if (mLoadedRecursiveIsoPathsValue != BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(this)) + if (mLoadedRecursiveIsoPathsValue != BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean()) { // Refresh game library GameFileCacheManager.startRescan(); 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 88b37dbbd9..7b9675b038 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 @@ -65,7 +65,7 @@ public enum StringSetting implements AbstractStringSetting } @Override - public boolean isOverridden(@NonNull Settings settings) + public boolean isOverridden() { return NativeConfig.isOverridden(mFile, mSection, mKey); } @@ -89,7 +89,7 @@ public enum StringSetting implements AbstractStringSetting } @NonNull @Override - public String getString(@NonNull Settings settings) + public String getString() { if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/DateTimeChoiceSetting.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/DateTimeChoiceSetting.kt index 7dcf284901..d1d411f80e 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/DateTimeChoiceSetting.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/DateTimeChoiceSetting.kt @@ -25,7 +25,7 @@ class DateTimeChoiceSetting( setting.setString(settings, selection) } - fun getSelectedValue(settings: Settings): String { - return setting.getString(settings) + fun getSelectedValue(): String { + return setting.getString() } } 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 d5d1951587..4b0ae749a9 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 @@ -25,9 +25,9 @@ public final class FilePicker extends SettingsItem mDefaultPathRelativeToUserDirectory = defaultPathRelativeToUserDirectory; } - public String getSelectedValue(Settings settings) + public String getSelectedValue() { - return mSetting.getString(settings); + return mSetting.getString(); } 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 5b91517f75..29432aaaa7 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 @@ -26,9 +26,9 @@ public class FloatSliderSetting extends SliderSetting mSetting = setting; } - public int getSelectedValue(Settings settings) + public int getSelectedValue() { - return Math.round(mSetting.getFloat(settings)); + return Math.round(mSetting.getFloat()); } public void setSelectedValue(Settings settings, float selection) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InputStringSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InputStringSetting.java index 90773e1762..9cd811b82d 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InputStringSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InputStringSetting.java @@ -43,9 +43,9 @@ public class InputStringSetting extends SettingsItem this(context, setting, titleId, descriptionId, choicesId, valuesId, null); } - public String getSelectedValue(Settings settings) + public String getSelectedValue() { - return mSetting.getString(settings); + return mSetting.getString(); } public MenuTag getMenuTag() 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 b7268dfc7e..e8d19f9059 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 @@ -19,9 +19,9 @@ public final class IntSliderSetting extends SliderSetting mSetting = setting; } - public int getSelectedValue(Settings settings) + public int getSelectedValue() { - return mSetting.getInt(settings); + return mSetting.getInt(); } public void setSelectedValue(Settings settings, int selection) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InvertedSwitchSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InvertedSwitchSetting.java index 95a8237393..621530e980 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InvertedSwitchSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/InvertedSwitchSetting.java @@ -17,9 +17,9 @@ public final class InvertedSwitchSetting extends SwitchSetting } @Override - public boolean isChecked(Settings settings) + public boolean isChecked() { - return !mSetting.getBoolean(settings); + return !mSetting.getBoolean(); } @Override 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 7d79f5a888..834b10e077 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 @@ -17,9 +17,9 @@ public final class PercentSliderSetting extends FloatSliderSetting } @Override - public int getSelectedValue(Settings settings) + public int getSelectedValue() { - return Math.round(mSetting.getFloat(settings) * 100); + return Math.round(mSetting.getFloat() * 100); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.java index 6f06677be3..7d757c3e69 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SettingsItem.java @@ -75,10 +75,10 @@ public abstract class SettingsItem protected abstract AbstractSetting getSetting(); - public boolean isOverridden(Settings settings) + public boolean isOverridden() { AbstractSetting setting = getSetting(); - return setting != null && setting.isOverridden(settings); + return setting != null && setting.isOverridden(); } public boolean isEditable() 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 567f3e88b3..1569785cd3 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 @@ -43,9 +43,9 @@ public final class SingleChoiceSetting extends SettingsItem return mValuesId; } - public int getSelectedValue(Settings settings) + public int getSelectedValue() { - return mSetting.getInt(settings); + return mSetting.getInt(); } 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 73be08cbd0..b59e535f87 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 @@ -60,9 +60,9 @@ public final class SingleChoiceSettingDynamicDescriptions extends SettingsItem return mDescriptionValuesId; } - public int getSelectedValue(Settings settings) + public int getSelectedValue() { - return mSetting.getInt(settings); + return mSetting.getInt(); } public MenuTag getMenuTag() diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SliderSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SliderSetting.java index e63fde3bad..fccbe0a0b1 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SliderSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SliderSetting.java @@ -31,7 +31,7 @@ public abstract class SliderSetting extends SettingsItem mUnits = units; } - public abstract int getSelectedValue(Settings settings); + public abstract int getSelectedValue(); public int getMin() { 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 1a9e237728..e83fe913cd 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 @@ -94,19 +94,19 @@ public class StringSingleChoiceSetting extends SettingsItem return ""; } - public String getSelectedChoice(Settings settings) + public String getSelectedChoice() { - return getChoiceAt(getSelectedValueIndex(settings)); + return getChoiceAt(getSelectedValueIndex()); } - public String getSelectedValue(Settings settings) + public String getSelectedValue() { - return mSetting.getString(settings); + return mSetting.getString(); } - public int getSelectedValueIndex(Settings settings) + public int getSelectedValueIndex() { - String selectedValue = getSelectedValue(settings); + String selectedValue = getSelectedValue(); for (int i = 0; i < mValues.length; i++) { if (mValues[i].equals(selectedValue)) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.java index 3c6679d297..dc7fa44714 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/SwitchSetting.java @@ -26,9 +26,9 @@ public class SwitchSetting extends SettingsItem mSetting = setting; } - public boolean isChecked(Settings settings) + public boolean isChecked() { - return mSetting.getBoolean(settings); + return mSetting.getBoolean(); } public void setChecked(Settings settings, boolean checked) 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 ca405b15fd..e062dd71b2 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 @@ -217,7 +217,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter= Build.VERSION_CODES.O) { - intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, - filePicker.getSelectedValue(mView.getSettings())); + intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, filePicker.getSelectedValue()); } mView.getActivity().startActivityForResult(intent, filePicker.getRequestType()); @@ -441,7 +440,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter 0) @@ -679,7 +678,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter 0) 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 19b3178ac0..452a636c59 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 @@ -368,9 +368,9 @@ public final class SettingsFragmentPresenter AbstractIntSetting appTheme = new AbstractIntSetting() { @Override - public boolean isOverridden(@NonNull Settings settings) + public boolean isOverridden() { - return IntSetting.MAIN_INTERFACE_THEME.isOverridden(settings); + return IntSetting.MAIN_INTERFACE_THEME.isOverridden(); } @Override @@ -388,9 +388,9 @@ public final class SettingsFragmentPresenter } @Override - public int getInt(@NonNull Settings settings) + public int getInt() { - return IntSetting.MAIN_INTERFACE_THEME.getInt(settings); + return IntSetting.MAIN_INTERFACE_THEME.getInt(); } @Override @@ -416,9 +416,9 @@ public final class SettingsFragmentPresenter AbstractIntSetting themeMode = new AbstractIntSetting() { @Override - public boolean isOverridden(@NonNull Settings settings) + public boolean isOverridden() { - return IntSetting.MAIN_INTERFACE_THEME_MODE.isOverridden(settings); + return IntSetting.MAIN_INTERFACE_THEME_MODE.isOverridden(); } @Override @@ -436,9 +436,9 @@ public final class SettingsFragmentPresenter } @Override - public int getInt(@NonNull Settings settings) + public int getInt() { - return IntSetting.MAIN_INTERFACE_THEME_MODE.getInt(settings); + return IntSetting.MAIN_INTERFACE_THEME_MODE.getInt(); } @Override @@ -455,9 +455,9 @@ public final class SettingsFragmentPresenter AbstractBooleanSetting blackBackgrounds = new AbstractBooleanSetting() { @Override - public boolean isOverridden(@NonNull Settings settings) + public boolean isOverridden() { - return BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.isOverridden(settings); + return BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.isOverridden(); } @Override @@ -474,9 +474,9 @@ public final class SettingsFragmentPresenter } @Override - public boolean getBoolean(@NonNull Settings settings) + public boolean getBoolean() { - return BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBoolean(settings); + return BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBoolean(); } @Override @@ -500,15 +500,15 @@ public final class SettingsFragmentPresenter AbstractIntSetting dspEmulationEngine = new AbstractIntSetting() { @Override - public int getInt(@NonNull Settings settings) + public int getInt() { - if (BooleanSetting.MAIN_DSP_HLE.getBoolean(settings)) + if (BooleanSetting.MAIN_DSP_HLE.getBoolean()) { return DSP_HLE; } else { - boolean jit = BooleanSetting.MAIN_DSP_JIT.getBoolean(settings); + boolean jit = BooleanSetting.MAIN_DSP_JIT.getBoolean(); return jit ? DSP_LLE_RECOMPILER : DSP_LLE_INTERPRETER; } } @@ -536,10 +536,10 @@ public final class SettingsFragmentPresenter } @Override - public boolean isOverridden(@NonNull Settings settings) + public boolean isOverridden() { - return BooleanSetting.MAIN_DSP_HLE.isOverridden(settings) || - BooleanSetting.MAIN_DSP_JIT.isOverridden(settings); + return BooleanSetting.MAIN_DSP_HLE.isOverridden() || + BooleanSetting.MAIN_DSP_JIT.isOverridden(); } @Override @@ -681,15 +681,15 @@ public final class SettingsFragmentPresenter AbstractIntSetting synchronizeGpuThread = new AbstractIntSetting() { @Override - public int getInt(@NonNull Settings settings) + public int getInt() { - if (BooleanSetting.MAIN_SYNC_GPU.getBoolean(settings)) + if (BooleanSetting.MAIN_SYNC_GPU.getBoolean()) { return SYNC_GPU_ALWAYS; } else { - boolean syncOnSkipIdle = BooleanSetting.MAIN_SYNC_ON_SKIP_IDLE.getBoolean(settings); + boolean syncOnSkipIdle = BooleanSetting.MAIN_SYNC_ON_SKIP_IDLE.getBoolean(); return syncOnSkipIdle ? SYNC_GPU_ON_IDLE_SKIP : SYNC_GPU_NEVER; } } @@ -717,10 +717,10 @@ public final class SettingsFragmentPresenter } @Override - public boolean isOverridden(@NonNull Settings settings) + public boolean isOverridden() { - return BooleanSetting.MAIN_SYNC_ON_SKIP_IDLE.isOverridden(settings) || - BooleanSetting.MAIN_SYNC_GPU.isOverridden(settings); + return BooleanSetting.MAIN_SYNC_ON_SKIP_IDLE.isOverridden() || + BooleanSetting.MAIN_SYNC_GPU.isOverridden(); } @Override @@ -879,7 +879,7 @@ public final class SettingsFragmentPresenter R.string.texture_filtering, R.string.texture_filtering_description, R.array.textureFilteringEntries, R.array.textureFilteringValues)); - int stereoModeValue = IntSetting.GFX_STEREO_MODE.getInt(mSettings); + int stereoModeValue = IntSetting.GFX_STEREO_MODE.getInt(); final int anaglyphMode = 3; String[] shaderList = stereoModeValue == anaglyphMode ? PostProcessing.getAnaglyphShaderList() : PostProcessing.getShaderList(); @@ -1216,7 +1216,7 @@ public final class SettingsFragmentPresenter sl.add(new SwitchSetting(mContext, new AbstractBooleanSetting() { @Override - public boolean isOverridden(Settings settings) + public boolean isOverridden() { return false; } @@ -1228,20 +1228,20 @@ public final class SettingsFragmentPresenter } @Override - public boolean delete(Settings settings) + public boolean delete(@NonNull Settings settings) { mView.setMappingAllDevices(false); return true; } @Override - public boolean getBoolean(Settings settings) + public boolean getBoolean() { return mView.isMappingAllDevices(); } @Override - public void setBoolean(Settings settings, boolean newValue) + public void setBoolean(@NonNull Settings settings, boolean newValue) { mView.setMappingAllDevices(newValue); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/DateTimeSettingViewHolder.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/DateTimeSettingViewHolder.kt index 79693e9c64..2778a489fc 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/DateTimeSettingViewHolder.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/DateTimeSettingViewHolder.kt @@ -22,7 +22,7 @@ class DateTimeSettingViewHolder( override fun bind(item: SettingsItem) { mItem = item as DateTimeChoiceSetting - val inputTime = mItem!!.getSelectedValue(adapter.settings) + val inputTime = mItem!!.getSelectedValue() binding.textSettingName.text = item.getName() if (!TextUtils.isEmpty(inputTime)) { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java index 87b84bd35c..1b75bb72b2 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/FilePickerViewHolder.java @@ -35,7 +35,7 @@ public final class FilePickerViewHolder extends SettingViewHolder mFilePicker = (FilePicker) item; mItem = item; - String path = mFilePicker.getSelectedValue(getAdapter().getSettings()); + String path = mFilePicker.getSelectedValue(); if (FileBrowserHelper.isPathEmptyOrValid(path)) { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/InputStringSettingViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/InputStringSettingViewHolder.java index 070284d38a..6743808079 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/InputStringSettingViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/InputStringSettingViewHolder.java @@ -31,7 +31,7 @@ public final class InputStringSettingViewHolder extends SettingViewHolder { mInputString = (InputStringSetting) item; - String inputString = mInputString.getSelectedValue(getAdapter().getSettings()); + String inputString = mInputString.getSelectedValue(); mBinding.textSettingName.setText(item.getName()); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java index 18fd466461..5217e4f889 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SettingViewHolder.java @@ -41,7 +41,7 @@ public abstract class SettingViewHolder extends RecyclerView.ViewHolder protected void setStyle(TextView textView, SettingsItem settingsItem) { - boolean overridden = settingsItem.isOverridden(mAdapter.getSettings()); + boolean overridden = settingsItem.isOverridden(); textView.setTypeface(null, overridden ? Typeface.BOLD : Typeface.NORMAL); if (!settingsItem.isEditable()) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java index beb15867c5..15ebaf4e82 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SingleChoiceViewHolder.java @@ -18,7 +18,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoice import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag; import org.dolphinemu.dolphinemu.features.settings.ui.SettingsAdapter; -import java.util.function.Function; +import java.util.function.Supplier; public final class SingleChoiceViewHolder extends SettingViewHolder { @@ -39,9 +39,6 @@ public final class SingleChoiceViewHolder extends SettingViewHolder mBinding.textSettingName.setText(item.getName()); - SettingsAdapter adapter = getAdapter(); - Settings settings = adapter.getSettings(); - if (!TextUtils.isEmpty(item.getDescription())) { mBinding.textSettingDescription.setText(item.getDescription()); @@ -49,7 +46,7 @@ public final class SingleChoiceViewHolder extends SettingViewHolder else if (item instanceof SingleChoiceSetting) { SingleChoiceSetting setting = (SingleChoiceSetting) item; - int selected = setting.getSelectedValue(settings); + int selected = setting.getSelectedValue(); Resources resMgr = mBinding.textSettingDescription.getContext().getResources(); String[] choices = resMgr.getStringArray(setting.getChoicesId()); int[] values = resMgr.getIntArray(setting.getValuesId()); @@ -64,14 +61,14 @@ public final class SingleChoiceViewHolder extends SettingViewHolder else if (item instanceof StringSingleChoiceSetting) { StringSingleChoiceSetting setting = (StringSingleChoiceSetting) item; - String choice = setting.getSelectedChoice(settings); + String choice = setting.getSelectedChoice(); mBinding.textSettingDescription.setText(choice); } else if (item instanceof SingleChoiceSettingDynamicDescriptions) { SingleChoiceSettingDynamicDescriptions setting = (SingleChoiceSettingDynamicDescriptions) item; - int selected = setting.getSelectedValue(settings); + int selected = setting.getSelectedValue(); Resources resMgr = mBinding.textSettingDescription.getContext().getResources(); String[] choices = resMgr.getStringArray(setting.getDescriptionChoicesId()); int[] values = resMgr.getIntArray(setting.getDescriptionValuesId()); @@ -85,7 +82,7 @@ public final class SingleChoiceViewHolder extends SettingViewHolder } MenuTag menuTag = null; - Function getSelectedValue = null; + Supplier getSelectedValue = null; if (item instanceof SingleChoiceSetting) { SingleChoiceSetting setting = (SingleChoiceSetting) item; @@ -99,15 +96,14 @@ public final class SingleChoiceViewHolder extends SettingViewHolder getSelectedValue = setting::getSelectedValueIndex; } - if (menuTag != null && - adapter.hasMenuTagActionForValue(menuTag, getSelectedValue.apply(settings))) + if (menuTag != null && getAdapter().hasMenuTagActionForValue(menuTag, getSelectedValue.get())) { mBinding.buttonMoreSettings.setVisibility(View.VISIBLE); final MenuTag finalMenuTag = menuTag; - final Function finalGetSelectedValue = getSelectedValue; + final Supplier finalGetSelectedValue = getSelectedValue; mBinding.buttonMoreSettings.setOnClickListener((view) -> - adapter.onMenuTagAction(finalMenuTag, finalGetSelectedValue.apply(settings))); + getAdapter().onMenuTagAction(finalMenuTag, finalGetSelectedValue.get())); } else { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java index 1f60a9825a..8d53bb1365 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SliderViewHolder.java @@ -44,9 +44,8 @@ public final class SliderViewHolder extends SettingViewHolder } else { - mBinding.textSettingDescription.setText(mContext - .getString(R.string.slider_setting_value, - mItem.getSelectedValue(getAdapter().getSettings()), mItem.getUnits())); + mBinding.textSettingDescription.setText(mContext.getString(R.string.slider_setting_value, + mItem.getSelectedValue(), mItem.getUnits())); } setStyle(mBinding.textSettingName, mItem); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SwitchSettingViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SwitchSettingViewHolder.java index c4245a9bcd..398711bea2 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SwitchSettingViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/viewholder/SwitchSettingViewHolder.java @@ -38,7 +38,7 @@ public final class SwitchSettingViewHolder extends SettingViewHolder mBinding.textSettingName.setText(item.getName()); mBinding.textSettingDescription.setText(item.getDescription()); - mBinding.settingSwitch.setChecked(mItem.isChecked(getAdapter().getSettings())); + mBinding.settingSwitch.setChecked(mItem.isChecked()); mBinding.settingSwitch.setEnabled(mItem.isEditable()); // Check for IPL to make sure user can skip. @@ -56,14 +56,7 @@ public final class SwitchSettingViewHolder extends SettingViewHolder } } - if (mItem.isChecked(getAdapter().getSettings())) - { - mBinding.settingSwitch.setEnabled(iplExists); - } - else - { - mBinding.settingSwitch.setEnabled(true); - } + mBinding.settingSwitch.setEnabled(iplExists || !mItem.isChecked()); } mBinding.settingSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> @@ -95,7 +88,7 @@ public final class SwitchSettingViewHolder extends SettingViewHolder if (mItem.getSetting() == BooleanSetting.MAIN_SKIP_IPL && !iplExists) { - if (mItem.isChecked(getAdapter().getSettings())) + if (mItem.isChecked()) { showIplNotAvailableError(); return; diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java index 27e425d8b6..2a808f8dc5 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java @@ -115,7 +115,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C { int overlayX = mInputOverlay.getLeft(); int overlayY = mInputOverlay.getTop(); - mInputOverlay.setSurfacePosition(activity.getSettings(), new Rect( + mInputOverlay.setSurfacePosition(new Rect( surfaceView.getLeft() - overlayX, surfaceView.getTop() - overlayY, surfaceView.getRight() - overlayX, surfaceView.getBottom() - overlayY)); }); @@ -135,7 +135,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C super.onResume(); if (mInputOverlay != null && NativeLibrary.IsGameMetadataValid()) - mInputOverlay.refreshControls(activity.getSettings()); + mInputOverlay.refreshControls(); run(activity.isActivityRecreated()); } @@ -171,34 +171,34 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C public void toggleInputOverlayVisibility(Settings settings) { BooleanSetting.MAIN_SHOW_INPUT_OVERLAY - .setBoolean(settings, !BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBoolean(settings)); + .setBoolean(settings, !BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBoolean()); if (mInputOverlay != null) - mInputOverlay.refreshControls(settings); + mInputOverlay.refreshControls(); } - public void initInputPointer(Settings settings) + public void initInputPointer() { if (mInputOverlay != null) - mInputOverlay.initTouchPointer(settings); + mInputOverlay.initTouchPointer(); } - public void refreshInputOverlay(Settings settings) + public void refreshInputOverlay() { if (mInputOverlay != null) - mInputOverlay.refreshControls(settings); + mInputOverlay.refreshControls(); } - public void refreshOverlayPointer(Settings settings) + public void refreshOverlayPointer() { if (mInputOverlay != null) - mInputOverlay.refreshOverlayPointer(settings); + mInputOverlay.refreshOverlayPointer(); } - public void resetInputOverlay(Settings settings) + public void resetInputOverlay() { if (mInputOverlay != null) - mInputOverlay.resetButtonPlacement(settings); + mInputOverlay.resetButtonPlacement(); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java index f0a212248f..1a6a751ffd 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java @@ -36,7 +36,6 @@ import org.dolphinemu.dolphinemu.features.input.model.controlleremu.EmulatedCont import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting; import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; import org.dolphinemu.dolphinemu.features.settings.model.IntSetting; -import org.dolphinemu.dolphinemu.features.settings.model.Settings; import java.util.ArrayList; import java.util.Arrays; @@ -145,13 +144,13 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener requestFocus(); } - public void setSurfacePosition(Settings settings, Rect rect) + public void setSurfacePosition(Rect rect) { mSurfacePosition = rect; - initTouchPointer(settings); + initTouchPointer(); } - public void initTouchPointer(Settings settings) + public void initTouchPointer() { // Check if we have all the data we need yet boolean aspectRatioAvailable = NativeLibrary.IsRunningAndStarted(); @@ -164,7 +163,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener int doubleTapButton = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getIntGlobal(); - if (getConfiguredControllerType(settings) != InputOverlay.OVERLAY_WIIMOTE_CLASSIC && + if (getConfiguredControllerType() != InputOverlay.OVERLAY_WIIMOTE_CLASSIC && doubleTapButton == ButtonType.CLASSIC_BUTTON_A) { doubleTapButton = ButtonType.WIIMOTE_BUTTON_A; @@ -792,7 +791,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener } } - public void refreshControls(Settings settings) + public void refreshControls() { unregisterControllers(); @@ -805,11 +804,11 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? "-Portrait" : ""; - mControllerType = getConfiguredControllerType(settings); + mControllerType = getConfiguredControllerType(); IntSetting controllerSetting = NativeLibrary.IsEmulatingWii() ? IntSetting.MAIN_OVERLAY_WII_CONTROLLER : IntSetting.MAIN_OVERLAY_GC_CONTROLLER; - int controllerIndex = controllerSetting.getInt(settings); + int controllerIndex = controllerSetting.getInt(); if (BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBooleanGlobal()) { @@ -817,7 +816,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener switch (mControllerType) { case OVERLAY_GAMECUBE: - if (IntSetting.getSettingForSIDevice(controllerIndex).getInt(settings) == + if (IntSetting.getSettingForSIDevice(controllerIndex).getInt() == DISABLED_GAMECUBE_CONTROLLER && mIsFirstRun) { Toast.makeText(getContext(), R.string.disabled_gc_overlay_notice, Toast.LENGTH_SHORT) @@ -866,21 +865,21 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener invalidate(); } - public void refreshOverlayPointer(Settings settings) + public void refreshOverlayPointer() { if (overlayPointer != null) { - overlayPointer.setMode(IntSetting.MAIN_IR_MODE.getInt(settings)); - overlayPointer.setRecenter(BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean(settings)); + overlayPointer.setMode(IntSetting.MAIN_IR_MODE.getInt()); + overlayPointer.setRecenter(BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean()); } } - public void resetButtonPlacement(Settings settings) + public void resetButtonPlacement() { boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; - final int controller = getConfiguredControllerType(settings); + final int controller = getConfiguredControllerType(); if (controller == OVERLAY_GAMECUBE) { if (isLandscape) @@ -908,26 +907,26 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener wiiOnlyPortraitDefaultOverlay(); } } - refreshControls(settings); + refreshControls(); } - public static int getConfiguredControllerType(Settings settings) + public static int getConfiguredControllerType() { IntSetting controllerSetting = NativeLibrary.IsEmulatingWii() ? IntSetting.MAIN_OVERLAY_WII_CONTROLLER : IntSetting.MAIN_OVERLAY_GC_CONTROLLER; - int controllerIndex = controllerSetting.getInt(settings); + int controllerIndex = controllerSetting.getInt(); if (controllerIndex >= 0 && controllerIndex < 4) { // GameCube controller - if (IntSetting.getSettingForSIDevice(controllerIndex).getInt(settings) == 6) + if (IntSetting.getSettingForSIDevice(controllerIndex).getInt() == 6) return OVERLAY_GAMECUBE; } else if (controllerIndex >= 4 && controllerIndex < 8) { // Wii Remote int wiimoteIndex = controllerIndex - 4; - if (IntSetting.getSettingForWiimoteSource(wiimoteIndex).getInt(settings) == 1) + if (IntSetting.getSettingForWiimoteSource(wiimoteIndex).getInt() == 1) { int attachmentIndex = EmulatedController.getSelectedWiimoteAttachment(wiimoteIndex); switch (attachmentIndex) @@ -939,7 +938,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener } NumericSetting sidewaysSetting = EmulatedController.getSidewaysWiimoteSetting(wiimoteIndex); - boolean sideways = new InputMappingBooleanSetting(sidewaysSetting).getBoolean(settings); + boolean sideways = new InputMappingBooleanSetting(sidewaysSetting).getBoolean(); return sideways ? OVERLAY_WIIMOTE_SIDEWAYS : OVERLAY_WIIMOTE; } From 99600ef781932a3ec291c479d9122e9c29e20343 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 11 Mar 2023 18:23:55 +0100 Subject: [PATCH 4/5] Android: Rework the "global" settings functions getXGlobal() is now identical to getX(), and setXGlobal(int, X) is now identical to setX(int, X) in the cases where setX(int, X) exists. We can remove/rename them. --- .../dolphinemu/adapters/GameAdapter.kt | 2 +- .../riivolution/ui/RiivolutionBootActivity.kt | 2 +- .../settings/model/BooleanSetting.java | 18 +--- .../features/settings/model/FloatSetting.java | 7 +- .../features/settings/model/IntSetting.java | 7 +- .../settings/model/StringSetting.java | 7 +- .../fragments/GridOptionDialogFragment.kt | 13 ++- .../dolphinemu/fragments/MenuFragment.java | 6 +- .../dolphinemu/model/GameFileCache.java | 2 +- .../dolphinemu/overlay/InputOverlay.java | 92 +++++++++---------- .../overlay/InputOverlayDrawableJoystick.java | 2 +- .../dolphinemu/ui/main/MainActivity.java | 4 +- .../dolphinemu/ui/main/MainPresenter.java | 2 +- .../dolphinemu/dolphinemu/utils/Analytics.kt | 2 +- .../dolphinemu/dolphinemu/utils/CoilUtils.kt | 6 +- .../utils/DirectoryInitialization.java | 13 ++- .../dolphinemu/utils/FileBrowserHelper.java | 2 +- 17 files changed, 77 insertions(+), 110 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.kt index 919ded6fef..0f7ec20811 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.kt @@ -59,7 +59,7 @@ class GameAdapter(private val mActivity: FragmentActivity) : RecyclerView.Adapte val gameFile = mGameFiles[position] holder.apply { - if (BooleanSetting.MAIN_SHOW_GAME_TITLES.booleanGlobal) { + if (BooleanSetting.MAIN_SHOW_GAME_TITLES.boolean) { binding.textGameTitle.text = gameFile.title binding.textGameTitle.visibility = View.VISIBLE binding.textGameTitleInner.visibility = View.GONE diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/ui/RiivolutionBootActivity.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/ui/RiivolutionBootActivity.kt index a4d33badab..f98af62592 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/ui/RiivolutionBootActivity.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/ui/RiivolutionBootActivity.kt @@ -44,7 +44,7 @@ class RiivolutionBootActivity : AppCompatActivity() { val revision = intent.getIntExtra(ARG_REVISION, -1) val discNumber = intent.getIntExtra(ARG_DISC_NUMBER, -1) - var loadPath = StringSetting.MAIN_LOAD_PATH.stringGlobal + var loadPath = StringSetting.MAIN_LOAD_PATH.string if (loadPath.isEmpty()) loadPath = DirectoryInitialization.getUserDirectory() + "/Load" binding.textSdRoot.text = getString(R.string.riivolution_sd_root, "$loadPath/Riivolution") 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 4f0f53643e..581a7a9aab 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 @@ -346,23 +346,7 @@ public enum BooleanSetting implements AbstractBooleanSetting NativeConfig.setBoolean(settings.getWriteLayer(), mFile, mSection, mKey, newValue); } - public void setBoolean(int layerType, boolean newValue) - { - if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) - { - throw new UnsupportedOperationException( - "Unsupported setting: " + mFile + ", " + mSection + ", " + mKey); - } - - NativeConfig.setBoolean(layerType, mFile, mSection, mKey, newValue); - } - - public boolean getBooleanGlobal() - { - return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); - } - - public void setBooleanGlobal(int layer, boolean newValue) + public void setBoolean(int layer, boolean newValue) { if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) { 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 726e92f1e7..99d15957c4 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 @@ -66,12 +66,7 @@ public enum FloatSetting implements AbstractFloatSetting NativeConfig.setFloat(settings.getWriteLayer(), mFile, mSection, mKey, newValue); } - public float getFloatGlobal() - { - return NativeConfig.getFloat(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); - } - - public void setFloatGlobal(int layer, float newValue) + public void setFloat(int layer, float newValue) { NativeConfig.setFloat(layer, mFile, mSection, 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 f17e96d2fd..df562c6998 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 @@ -171,12 +171,7 @@ public enum IntSetting implements AbstractIntSetting NativeConfig.setInt(settings.getWriteLayer(), mFile, mSection, mKey, newValue); } - public int getIntGlobal() - { - return NativeConfig.getInt(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); - } - - public void setIntGlobal(int layer, int newValue) + public void setInt(int layer, int newValue) { if (!NativeConfig.isSettingSaveable(mFile, mSection, mKey)) { 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 7b9675b038..c72f26aa0f 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 @@ -106,12 +106,7 @@ public enum StringSetting implements AbstractStringSetting NativeConfig.setString(settings.getWriteLayer(), mFile, mSection, mKey, newValue); } - public String getStringGlobal() - { - return NativeConfig.getString(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue); - } - - public void setStringGlobal(int layer, String newValue) + public void setString(int layer, String newValue) { NativeConfig.setString(layer, mFile, mSection, mKey, newValue); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/GridOptionDialogFragment.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/GridOptionDialogFragment.kt index 186e8f88d0..16a526bb2a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/GridOptionDialogFragment.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/GridOptionDialogFragment.kt @@ -65,13 +65,12 @@ class GridOptionDialogFragment : BottomSheetDialogFragment() { } private fun setUpCoverButtons() { - mBindingMobile.switchDownloadCovers.isChecked = - BooleanSetting.MAIN_USE_GAME_COVERS.booleanGlobal + mBindingMobile.switchDownloadCovers.isChecked = BooleanSetting.MAIN_USE_GAME_COVERS.boolean mBindingMobile.rootDownloadCovers.setOnClickListener { mBindingMobile.switchDownloadCovers.isChecked = !mBindingMobile.switchDownloadCovers.isChecked } mBindingMobile.switchDownloadCovers.setOnCheckedChangeListener { _: CompoundButton, _: Boolean -> - BooleanSetting.MAIN_USE_GAME_COVERS.setBooleanGlobal( + BooleanSetting.MAIN_USE_GAME_COVERS.setBoolean( NativeConfig.LAYER_BASE, mBindingMobile.switchDownloadCovers.isChecked ) @@ -80,12 +79,12 @@ class GridOptionDialogFragment : BottomSheetDialogFragment() { } private fun setUpTitleButtons() { - mBindingMobile.switchShowTitles.isChecked = BooleanSetting.MAIN_SHOW_GAME_TITLES.booleanGlobal + mBindingMobile.switchShowTitles.isChecked = BooleanSetting.MAIN_SHOW_GAME_TITLES.boolean mBindingMobile.rootShowTitles.setOnClickListener { mBindingMobile.switchShowTitles.isChecked = !mBindingMobile.switchShowTitles.isChecked } mBindingMobile.switchShowTitles.setOnCheckedChangeListener { _: CompoundButton, _: Boolean -> - BooleanSetting.MAIN_SHOW_GAME_TITLES.setBooleanGlobal( + BooleanSetting.MAIN_SHOW_GAME_TITLES.setBoolean( NativeConfig.LAYER_BASE, mBindingMobile.switchShowTitles.isChecked ) @@ -96,12 +95,12 @@ class GridOptionDialogFragment : BottomSheetDialogFragment() { // TODO: Remove this when leanback is removed private fun setUpCoverButtonsTv() { mBindingTv.switchDownloadCovers.isChecked = - BooleanSetting.MAIN_USE_GAME_COVERS.booleanGlobal + BooleanSetting.MAIN_USE_GAME_COVERS.boolean mBindingTv.rootDownloadCovers.setOnClickListener { mBindingTv.switchDownloadCovers.isChecked = !mBindingTv.switchDownloadCovers.isChecked } mBindingTv.switchDownloadCovers.setOnCheckedChangeListener { _: CompoundButton, _: Boolean -> - BooleanSetting.MAIN_USE_GAME_COVERS.setBooleanGlobal( + BooleanSetting.MAIN_USE_GAME_COVERS.setBoolean( NativeConfig.LAYER_BASE, mBindingTv.switchDownloadCovers.isChecked ) 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 fc3ba9dac0..b30ba94b37 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 @@ -92,7 +92,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - if (IntSetting.MAIN_INTERFACE_THEME.getIntGlobal() != ThemeHelper.DEFAULT) + if (IntSetting.MAIN_INTERFACE_THEME.getInt() != ThemeHelper.DEFAULT) { @ColorInt int color = new ElevationOverlayProvider(view.getContext()).compositeOverlay( MaterialColors.getColor(view, R.attr.colorSurface), @@ -114,7 +114,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener mBinding.menuSkylanders.setVisibility(View.GONE); } - if (!BooleanSetting.MAIN_EMULATE_SKYLANDER_PORTAL.getBooleanGlobal()) + if (!BooleanSetting.MAIN_EMULATE_SKYLANDER_PORTAL.getBoolean()) { mBinding.menuSkylanders.setVisibility(View.GONE); } @@ -176,7 +176,7 @@ public final class MenuFragment extends Fragment implements View.OnClickListener { super.onResume(); - boolean savestatesEnabled = BooleanSetting.MAIN_ENABLE_SAVESTATES.getBooleanGlobal(); + boolean savestatesEnabled = BooleanSetting.MAIN_ENABLE_SAVESTATES.getBoolean(); int savestateVisibility = savestatesEnabled ? View.VISIBLE : View.GONE; mBinding.menuQuicksave.setVisibility(savestateVisibility); mBinding.menuQuickload.setVisibility(savestateVisibility); 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 7b29370c53..59c8893dcf 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 @@ -98,7 +98,7 @@ public class GameFileCache public static String[] getAllGamePaths() { - boolean recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBooleanGlobal(); + boolean recursiveScan = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(); LinkedHashSet folderPathsSet = getPathSet(true); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java index 1a6a751ffd..d44acc2786 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java @@ -161,7 +161,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener if (!NativeLibrary.IsEmulatingWii()) return; - int doubleTapButton = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getIntGlobal(); + int doubleTapButton = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getInt(); if (getConfiguredControllerType() != InputOverlay.OVERLAY_WIIMOTE_CLASSIC && doubleTapButton == ButtonType.CLASSIC_BUTTON_A) @@ -184,8 +184,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener } overlayPointer = new InputOverlayPointer(mSurfacePosition, doubleTapControl, - IntSetting.MAIN_IR_MODE.getIntGlobal(), - BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBooleanGlobal(), mControllerIndex); + IntSetting.MAIN_IR_MODE.getInt(), BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean(), + mControllerIndex); } @Override @@ -552,55 +552,55 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener private void addGameCubeOverlayControls(String orientation) { - if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_0.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_0.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_a, R.drawable.gcpad_a_pressed, ButtonType.BUTTON_A, ControlId.GCPAD_A_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_1.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_1.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_b, R.drawable.gcpad_b_pressed, ButtonType.BUTTON_B, ControlId.GCPAD_B_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_2.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_2.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_x, R.drawable.gcpad_x_pressed, ButtonType.BUTTON_X, ControlId.GCPAD_X_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_3.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_3.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_y, R.drawable.gcpad_y_pressed, ButtonType.BUTTON_Y, ControlId.GCPAD_Y_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_4.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_4.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_z, R.drawable.gcpad_z_pressed, ButtonType.BUTTON_Z, ControlId.GCPAD_Z_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_5.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_5.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_start, R.drawable.gcpad_start_pressed, ButtonType.BUTTON_START, ControlId.GCPAD_START_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_6.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_6.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_l, R.drawable.gcpad_l_pressed, ButtonType.TRIGGER_L, ControlId.GCPAD_L_DIGITAL, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_7.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_7.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_r, R.drawable.gcpad_r_pressed, ButtonType.TRIGGER_R, ControlId.GCPAD_R_DIGITAL, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_8.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_8.getBoolean()) { overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad, R.drawable.gcwii_dpad_pressed_one_direction, @@ -608,13 +608,13 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener ButtonType.BUTTON_UP, ControlId.GCPAD_DPAD_UP, ControlId.GCPAD_DPAD_DOWN, ControlId.GCPAD_DPAD_LEFT, ControlId.GCPAD_DPAD_RIGHT, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_9.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_9.getBoolean()) { overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range, R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed, ButtonType.STICK_MAIN, ControlId.GCPAD_MAIN_STICK_X, ControlId.GCPAD_MAIN_STICK_Y, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_10.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_10.getBoolean()) { overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range, R.drawable.gcpad_c, R.drawable.gcpad_c_pressed, ButtonType.STICK_C, @@ -624,49 +624,49 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener private void addWiimoteOverlayControls(String orientation) { - if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_0.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_0.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_a, R.drawable.wiimote_a_pressed, ButtonType.WIIMOTE_BUTTON_A, ControlId.WIIMOTE_A_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_1.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_1.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_b, R.drawable.wiimote_b_pressed, ButtonType.WIIMOTE_BUTTON_B, ControlId.WIIMOTE_B_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_2.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_2.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_one, R.drawable.wiimote_one_pressed, ButtonType.WIIMOTE_BUTTON_1, ControlId.WIIMOTE_ONE_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_3.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_3.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_two, R.drawable.wiimote_two_pressed, ButtonType.WIIMOTE_BUTTON_2, ControlId.WIIMOTE_TWO_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_4.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_4.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_plus, R.drawable.wiimote_plus_pressed, ButtonType.WIIMOTE_BUTTON_PLUS, ControlId.WIIMOTE_PLUS_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_5.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_5.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_minus, R.drawable.wiimote_minus_pressed, ButtonType.WIIMOTE_BUTTON_MINUS, ControlId.WIIMOTE_MINUS_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_6.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_6.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_home, R.drawable.wiimote_home_pressed, ButtonType.WIIMOTE_BUTTON_HOME, ControlId.WIIMOTE_HOME_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_7.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_7.getBoolean()) { overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad, R.drawable.gcwii_dpad_pressed_one_direction, @@ -678,19 +678,19 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener private void addNunchukOverlayControls(String orientation) { - if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_8.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_8.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_c, R.drawable.nunchuk_c_pressed, ButtonType.NUNCHUK_BUTTON_C, ControlId.NUNCHUK_C_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_9.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_9.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_z, R.drawable.nunchuk_z_pressed, ButtonType.NUNCHUK_BUTTON_Z, ControlId.NUNCHUK_Z_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_10.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_10.getBoolean()) { overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range, R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed, @@ -701,73 +701,73 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener private void addClassicOverlayControls(String orientation) { - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_0.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_0.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_a, R.drawable.classic_a_pressed, ButtonType.CLASSIC_BUTTON_A, ControlId.CLASSIC_A_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_1.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_1.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_b, R.drawable.classic_b_pressed, ButtonType.CLASSIC_BUTTON_B, ControlId.CLASSIC_B_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_2.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_2.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_x, R.drawable.classic_x_pressed, ButtonType.CLASSIC_BUTTON_X, ControlId.CLASSIC_X_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_3.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_3.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_y, R.drawable.classic_y_pressed, ButtonType.CLASSIC_BUTTON_Y, ControlId.CLASSIC_Y_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_4.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_4.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_plus, R.drawable.wiimote_plus_pressed, ButtonType.CLASSIC_BUTTON_PLUS, ControlId.CLASSIC_PLUS_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_5.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_5.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_minus, R.drawable.wiimote_minus_pressed, ButtonType.CLASSIC_BUTTON_MINUS, ControlId.CLASSIC_MINUS_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_6.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_6.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_home, R.drawable.wiimote_home_pressed, ButtonType.CLASSIC_BUTTON_HOME, ControlId.CLASSIC_HOME_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_7.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_7.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_l, R.drawable.classic_l_pressed, ButtonType.CLASSIC_TRIGGER_L, ControlId.CLASSIC_L_DIGITAL, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_8.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_8.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_r, R.drawable.classic_r_pressed, ButtonType.CLASSIC_TRIGGER_R, ControlId.CLASSIC_R_DIGITAL, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_9.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_9.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_zl, R.drawable.classic_zl_pressed, ButtonType.CLASSIC_BUTTON_ZL, ControlId.CLASSIC_ZL_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_10.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_10.getBoolean()) { overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_zr, R.drawable.classic_zr_pressed, ButtonType.CLASSIC_BUTTON_ZR, ControlId.CLASSIC_ZR_BUTTON, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_11.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_11.getBoolean()) { overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad, R.drawable.gcwii_dpad_pressed_one_direction, @@ -775,14 +775,14 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener ButtonType.CLASSIC_DPAD_UP, ControlId.CLASSIC_DPAD_UP, ControlId.CLASSIC_DPAD_DOWN, ControlId.CLASSIC_DPAD_LEFT, ControlId.CLASSIC_DPAD_RIGHT, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_12.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_12.getBoolean()) { overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range, R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed, ButtonType.CLASSIC_STICK_LEFT, ControlId.CLASSIC_LEFT_STICK_X, ControlId.CLASSIC_LEFT_STICK_Y, orientation)); } - if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_13.getBooleanGlobal()) + if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_13.getBoolean()) { overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range, R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed, @@ -810,7 +810,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener IntSetting.MAIN_OVERLAY_WII_CONTROLLER : IntSetting.MAIN_OVERLAY_GC_CONTROLLER; int controllerIndex = controllerSetting.getInt(); - if (BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBooleanGlobal()) + if (BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBoolean()) { // Add all the enabled overlay items back to the HashSet. switch (mControllerType) @@ -1070,7 +1070,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener break; } - scale *= (IntSetting.MAIN_CONTROL_SCALE.getIntGlobal() + 50); + scale *= (IntSetting.MAIN_CONTROL_SCALE.getInt() + 50); scale /= 100; // Initialize the InputOverlayDrawableButton. @@ -1096,7 +1096,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener // Need to set the image's position overlayDrawable.setPosition(drawableX, drawableY); - overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getIntGlobal() * 255 / 100); + overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getInt() * 255 / 100); return overlayDrawable; } @@ -1151,7 +1151,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener break; } - scale *= (IntSetting.MAIN_CONTROL_SCALE.getIntGlobal() + 50); + scale *= (IntSetting.MAIN_CONTROL_SCALE.getInt() + 50); scale /= 100; // Initialize the InputOverlayDrawableDpad. @@ -1182,7 +1182,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener // Need to set the image's position overlayDrawable.setPosition(drawableX, drawableY); - overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getIntGlobal() * 255 / 100); + overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getInt() * 255 / 100); return overlayDrawable; } @@ -1211,7 +1211,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener // Decide scale based on user preference float scale = 0.275f; - scale *= (IntSetting.MAIN_CONTROL_SCALE.getIntGlobal() + 50); + scale *= (IntSetting.MAIN_CONTROL_SCALE.getInt() + 50); scale /= 100; // Initialize the InputOverlayDrawableJoystick. @@ -1251,7 +1251,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener // Need to set the image's position overlayDrawable.setPosition(drawableX, drawableY); - overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getIntGlobal() * 255 / 100); + overlayDrawable.setOpacity(IntSetting.MAIN_CONTROL_OPACITY.getInt() * 255 / 100); return overlayDrawable; } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableJoystick.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableJoystick.java index ee8c852610..6ebe731341 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableJoystick.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlayDrawableJoystick.java @@ -102,7 +102,7 @@ public final class InputOverlayDrawableJoystick public boolean TrackEvent(MotionEvent event) { - boolean reCenter = BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBooleanGlobal(); + boolean reCenter = BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBoolean(); int action = event.getActionMasked(); boolean firstPointer = action != MotionEvent.ACTION_POINTER_DOWN && action != MotionEvent.ACTION_POINTER_UP; 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 464c2a2c89..1b0ff8cc32 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 @@ -378,7 +378,7 @@ public final class MainActivity extends AppCompatActivity public void onTabSelected(@NonNull TabLayout.Tab tab) { super.onTabSelected(tab); - IntSetting.MAIN_LAST_PLATFORM_TAB.setIntGlobal(NativeConfig.LAYER_BASE, + IntSetting.MAIN_LAST_PLATFORM_TAB.setInt(NativeConfig.LAYER_BASE, tab.getPosition()); } }); @@ -388,7 +388,7 @@ public final class MainActivity extends AppCompatActivity mBinding.tabsPlatforms.getTabAt(i).setIcon(PlatformPagerAdapter.TAB_ICONS[i]); } - mBinding.pagerPlatforms.setCurrentItem(IntSetting.MAIN_LAST_PLATFORM_TAB.getIntGlobal()); + mBinding.pagerPlatforms.setCurrentItem(IntSetting.MAIN_LAST_PLATFORM_TAB.getInt()); showGames(); GameFileCacheManager.startLoad(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java index b36a9ced2b..e136864faa 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java @@ -175,7 +175,7 @@ public final class MainPresenter { Uri uri = result.getData(); - boolean recursive = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBooleanGlobal(); + boolean recursive = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(); String[] childNames = ContentHandler.getChildNames(uri, recursive); if (Arrays.stream(childNames).noneMatch((name) -> FileBrowserHelper.GAME_EXTENSIONS.contains( FileBrowserHelper.getExtension(name, false)))) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.kt index 83c0168bec..ffa117ffab 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.kt @@ -21,7 +21,7 @@ object Analytics { @JvmStatic fun checkAnalyticsInit(activity: FragmentActivity) { AfterDirectoryInitializationRunner().runWithoutLifecycle { - if (!BooleanSetting.MAIN_ANALYTICS_PERMISSION_ASKED.booleanGlobal) { + if (!BooleanSetting.MAIN_ANALYTICS_PERMISSION_ASKED.boolean) { AnalyticsDialog().show(activity.supportFragmentManager, AnalyticsDialog.TAG) } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/CoilUtils.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/CoilUtils.kt index 233f620d23..dd2e2e68fb 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/CoilUtils.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/CoilUtils.kt @@ -37,7 +37,7 @@ object CoilUtils { } ) } - } else if (BooleanSetting.MAIN_USE_GAME_COVERS.booleanGlobal) { + } else if (BooleanSetting.MAIN_USE_GAME_COVERS.boolean) { imageView.load(CoverHelper.buildGameTDBUrl(gameFile, CoverHelper.getRegion(gameFile))) { error(R.drawable.no_banner) target( @@ -58,13 +58,13 @@ object CoilUtils { } private fun enableInnerTitle(gameViewHolder: GameViewHolder?) { - if (gameViewHolder != null && !BooleanSetting.MAIN_SHOW_GAME_TITLES.booleanGlobal) { + if (gameViewHolder != null && !BooleanSetting.MAIN_SHOW_GAME_TITLES.boolean) { gameViewHolder.binding.textGameTitleInner.visibility = View.VISIBLE } } private fun disableInnerTitle(gameViewHolder: GameViewHolder?) { - if (gameViewHolder != null && !BooleanSetting.MAIN_SHOW_GAME_TITLES.booleanGlobal) { + if (gameViewHolder != null && !BooleanSetting.MAIN_SHOW_GAME_TITLES.boolean) { gameViewHolder.binding.textGameTitleInner.visibility = View.GONE } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/DirectoryInitialization.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/DirectoryInitialization.java index bb2f45de43..41685efd4b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/DirectoryInitialization.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/DirectoryInitialization.java @@ -356,30 +356,29 @@ public final class DirectoryInitialization private static void checkThemeSettings(Context context) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - if (IntSetting.MAIN_INTERFACE_THEME.getIntGlobal() != + if (IntSetting.MAIN_INTERFACE_THEME.getInt() != preferences.getInt(ThemeHelper.CURRENT_THEME, ThemeHelper.DEFAULT)) { preferences.edit() - .putInt(ThemeHelper.CURRENT_THEME, IntSetting.MAIN_INTERFACE_THEME.getIntGlobal()) + .putInt(ThemeHelper.CURRENT_THEME, IntSetting.MAIN_INTERFACE_THEME.getInt()) .apply(); } - if (IntSetting.MAIN_INTERFACE_THEME_MODE.getIntGlobal() != + if (IntSetting.MAIN_INTERFACE_THEME_MODE.getInt() != preferences.getInt(ThemeHelper.CURRENT_THEME_MODE, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)) { preferences.edit() - .putInt(ThemeHelper.CURRENT_THEME_MODE, - IntSetting.MAIN_INTERFACE_THEME_MODE.getIntGlobal()) + .putInt(ThemeHelper.CURRENT_THEME_MODE, IntSetting.MAIN_INTERFACE_THEME_MODE.getInt()) .apply(); } - if (BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBooleanGlobal() != + if (BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBoolean() != preferences.getBoolean(ThemeHelper.USE_BLACK_BACKGROUNDS, false)) { preferences.edit() .putBoolean(ThemeHelper.USE_BLACK_BACKGROUNDS, - BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBooleanGlobal()) + BooleanSetting.MAIN_USE_BLACK_BACKGROUNDS.getBoolean()) .apply(); } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/FileBrowserHelper.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/FileBrowserHelper.java index f1cb504d8a..c7401c2bc5 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/FileBrowserHelper.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/FileBrowserHelper.java @@ -79,7 +79,7 @@ public final class FileBrowserHelper public static boolean isPathEmptyOrValid(StringSetting path) { - return isPathEmptyOrValid(path.getStringGlobal()); + return isPathEmptyOrValid(path.getString()); } /** From 08334015f91a42a233bc35823de2af89e49e0b59 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 11 Mar 2023 18:36:38 +0100 Subject: [PATCH 5/5] Android: Remove SettingsActivityView parameters from Settings No longer used for anything. --- .../dolphinemu/activities/EmulationActivity.java | 2 +- .../dolphinemu/dialogs/GamePropertiesDialog.java | 2 +- .../dolphinemu/features/cheats/ui/CheatsActivity.kt | 2 +- .../dolphinemu/features/settings/model/Settings.java | 11 +++++------ .../settings/ui/SettingsActivityPresenter.java | 6 +++--- .../java/org/dolphinemu/dolphinemu/utils/Analytics.kt | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) 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 d798a25393..b9a9eab46e 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 @@ -423,7 +423,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP protected void onStop() { super.onStop(); - mSettings.saveSettings(null, null); + mSettings.saveSettings(null); } public void onTitleChanged() 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 339434e8e3..fa185b7afd 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 @@ -92,7 +92,7 @@ public class GamePropertiesDialog extends DialogFragment { settings.loadSettings(); StringSetting.MAIN_DEFAULT_ISO.setString(settings, path); - settings.saveSettings(null, getContext()); + settings.saveSettings(getContext()); } }); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsActivity.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsActivity.kt index 11278360cf..d22431752b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsActivity.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsActivity.kt @@ -160,7 +160,7 @@ class CheatsActivity : AppCompatActivity(), PanelSlideListener { fun loadGameSpecificSettings(): Settings { val settings = Settings() - settings.loadSettings(null, gameId, revision, isWii) + settings.loadSettings(gameId, revision, isWii) return settings } 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 a67dd63acc..0bb935f3df 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 @@ -9,7 +9,6 @@ import android.widget.Toast; import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.input.model.MappingCommon; -import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivityView; import org.dolphinemu.dolphinemu.services.GameFileCacheManager; import java.io.Closeable; @@ -78,10 +77,10 @@ public class Settings implements Closeable public void loadSettings() { // The value of isWii doesn't matter if we don't have any SettingsActivity - loadSettings(null, true); + loadSettings(true); } - public void loadSettings(SettingsActivityView view, boolean isWii) + public void loadSettings(boolean isWii) { mIsWii = isWii; mSettingsLoaded = true; @@ -98,14 +97,14 @@ public class Settings implements Closeable mLoadedRecursiveIsoPathsValue = BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(); } - public void loadSettings(SettingsActivityView view, String gameId, int revision, boolean isWii) + public void loadSettings(String gameId, int revision, boolean isWii) { mGameId = gameId; mRevision = revision; - loadSettings(view, isWii); + loadSettings(isWii); } - public void saveSettings(SettingsActivityView view, Context context) + public void saveSettings(Context context) { if (!isGameSpecific()) { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java index 1b50754fdd..00561daffb 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java @@ -70,7 +70,7 @@ public final class SettingsActivityPresenter { if (!TextUtils.isEmpty(mGameId)) { - mSettings.loadSettings(mView, mGameId, mRevision, mIsWii); + mSettings.loadSettings(mGameId, mRevision, mIsWii); if (mSettings.gameIniContainsJunk()) { @@ -79,7 +79,7 @@ public final class SettingsActivityPresenter } else { - mSettings.loadSettings(mView, mIsWii); + mSettings.loadSettings(mIsWii); } } @@ -110,7 +110,7 @@ public final class SettingsActivityPresenter if (mSettings != null && finishing && mShouldSave) { Log.debug("[SettingsActivity] Settings activity stopping. Saving settings to INI..."); - mSettings.saveSettings(mView, mActivity); + mSettings.saveSettings(mActivity); } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.kt index ffa117ffab..c8aa483d58 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.kt @@ -34,7 +34,7 @@ object Analytics { BooleanSetting.MAIN_ANALYTICS_PERMISSION_ASKED.setBoolean(settings, true) // Context is set to null to avoid toasts - settings.saveSettings(null, null) + settings.saveSettings(null) } }