diff options
author | t895 <clombardo169@gmail.com> | 2023-12-12 20:53:37 +0100 |
---|---|---|
committer | t895 <clombardo169@gmail.com> | 2023-12-12 23:25:37 +0100 |
commit | 6ae4177b2520e0b48399615de5e964495fc2115d (patch) | |
tree | 170fc314c895053eec1bcc17829dabc70b0ec12f /src | |
parent | android: Pre-select custom config in game launch dialog (diff) | |
download | yuzu-6ae4177b2520e0b48399615de5e964495fc2115d.tar yuzu-6ae4177b2520e0b48399615de5e964495fc2115d.tar.gz yuzu-6ae4177b2520e0b48399615de5e964495fc2115d.tar.bz2 yuzu-6ae4177b2520e0b48399615de5e964495fc2115d.tar.lz yuzu-6ae4177b2520e0b48399615de5e964495fc2115d.tar.xz yuzu-6ae4177b2520e0b48399615de5e964495fc2115d.tar.zst yuzu-6ae4177b2520e0b48399615de5e964495fc2115d.zip |
Diffstat (limited to 'src')
4 files changed, 23 insertions, 0 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/AbstractSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/AbstractSetting.kt index e384c78c2..3b78c7cf0 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/AbstractSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/AbstractSetting.kt @@ -22,6 +22,9 @@ interface AbstractSetting { get() = NativeConfig.usingGlobal(key) set(value) = NativeConfig.setGlobal(key, value) + val isSaveable: Boolean + get() = NativeConfig.getIsSaveable(key) + fun getValueAsString(needsGlobal: Boolean = false): String fun reset() diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt index 28d8dea60..2e97aee2c 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt @@ -30,6 +30,11 @@ abstract class SettingsItem( val isEditable: Boolean get() { + // Can't edit settings that aren't saveable in per-game config even if they are switchable + if (NativeConfig.isPerGameConfigLoaded() && !setting.isSaveable) { + return false + } + if (!NativeLibrary.isRunning()) return true // Prevent editing settings that were modified in per-game config while editing global @@ -37,6 +42,7 @@ abstract class SettingsItem( if (!NativeConfig.isPerGameConfigLoaded() && !setting.global) { return false } + return setting.isRuntimeModifiable } @@ -59,6 +65,7 @@ abstract class SettingsItem( val emptySetting = object : AbstractSetting { override val key: String = "" override val defaultValue: Any = false + override val isSaveable = true override fun getValueAsString(needsGlobal: Boolean): String = "" override fun reset() {} } @@ -303,6 +310,8 @@ abstract class SettingsItem( BooleanSetting.FASTMEM_EXCLUSIVES.global = value } + override val isSaveable = true + override fun getValueAsString(needsGlobal: Boolean): String = getBoolean().toString() diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/NativeConfig.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/NativeConfig.kt index 2d3d8ec79..7512d5eed 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/NativeConfig.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/NativeConfig.kt @@ -110,6 +110,8 @@ object NativeConfig { @Synchronized external fun setGlobal(key: String, global: Boolean) + external fun getIsSaveable(key: String): Boolean + external fun getDefaultToString(key: String): String /** diff --git a/src/android/app/src/main/jni/native_config.cpp b/src/android/app/src/main/jni/native_config.cpp index 9e0a33c0f..324d9e9cd 100644 --- a/src/android/app/src/main/jni/native_config.cpp +++ b/src/android/app/src/main/jni/native_config.cpp @@ -249,6 +249,15 @@ void Java_org_yuzu_yuzu_1emu_utils_NativeConfig_setGlobal(JNIEnv* env, jobject o } } +jboolean Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getIsSaveable(JNIEnv* env, jobject obj, + jstring jkey) { + auto setting = getSetting<std::string>(env, jkey); + if (setting != nullptr) { + return setting->Save(); + } + return false; +} + jstring Java_org_yuzu_yuzu_1emu_utils_NativeConfig_getDefaultToString(JNIEnv* env, jobject obj, jstring jkey) { auto setting = getSetting<std::string>(env, jkey); |