diff options
Diffstat (limited to 'src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt')
-rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt index d094f891e..ed1742ac6 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt @@ -3,27 +3,26 @@ package org.yuzu.yuzu_emu.features.settings.model.view +import org.yuzu.yuzu_emu.features.settings.model.AbstractIntSetting import org.yuzu.yuzu_emu.features.settings.model.IntSetting -import org.yuzu.yuzu_emu.features.settings.model.Setting class SingleChoiceSetting( - key: String, - section: String, - setting: Setting?, + setting: AbstractIntSetting?, titleId: Int, descriptionId: Int, val choicesId: Int, val valuesId: Int, - private val defaultValue: Int, -) : SettingsItem(key, section, setting, titleId, descriptionId) { + val key: String? = null, + val defaultValue: Int? = null +) : SettingsItem(setting, titleId, descriptionId) { override val type = TYPE_SINGLE_CHOICE val selectedValue: Int get() = if (setting != null) { val setting = setting as IntSetting - setting.value + setting.int } else { - defaultValue + defaultValue!! } /** @@ -31,17 +30,11 @@ class SingleChoiceSetting( * initializes a new one and returns it, so it can be added to the Hashmap. * * @param selection New value of the int. - * @return null if overwritten successfully otherwise; a newly created IntSetting. + * @return the existing setting with the new value applied. */ - fun setSelectedValue(selection: Int): IntSetting? { - return if (setting == null) { - val newSetting = IntSetting(key!!, section!!, selection) - setting = newSetting - newSetting - } else { - val newSetting = setting as IntSetting - newSetting.value = selection - null - } + fun setSelectedValue(selection: Int): AbstractIntSetting { + val intSetting = setting as AbstractIntSetting + intSetting.int = selection + return intSetting } } |