mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-06-04 06:05:00 -06:00
Change List<> in Multi Files to be MutableSet<> to allow adds while prevent potential duplicates. Finished primary multi choice backend impl.
This commit is contained in:
parent
bfcafccb8e
commit
eaf9baee93
@ -5,5 +5,5 @@
|
|||||||
package org.citra.citra_emu.features.settings.model
|
package org.citra.citra_emu.features.settings.model
|
||||||
|
|
||||||
interface AbstractMultiBooleanSetting : AbstractSetting {
|
interface AbstractMultiBooleanSetting : AbstractSetting {
|
||||||
var booleans: List<Boolean>
|
var booleans: MutableSet<Boolean>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,5 +5,5 @@
|
|||||||
package org.citra.citra_emu.features.settings.model
|
package org.citra.citra_emu.features.settings.model
|
||||||
|
|
||||||
interface AbstractMultiFloatSetting : AbstractSetting {
|
interface AbstractMultiFloatSetting : AbstractSetting {
|
||||||
var floats: List<Float>
|
var floats: MutableSet<Float>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,5 +5,5 @@
|
|||||||
package org.citra.citra_emu.features.settings.model
|
package org.citra.citra_emu.features.settings.model
|
||||||
|
|
||||||
interface AbstractMultiIntSetting : AbstractSetting {
|
interface AbstractMultiIntSetting : AbstractSetting {
|
||||||
var ints: List<Int>
|
var ints: MutableSet<Int>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,5 +5,5 @@
|
|||||||
package org.citra.citra_emu.features.settings.model
|
package org.citra.citra_emu.features.settings.model
|
||||||
|
|
||||||
interface AbstractMultiShortSetting : AbstractSetting {
|
interface AbstractMultiShortSetting : AbstractSetting {
|
||||||
var shorts: List<Short>
|
var shorts: MutableSet<Short>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,5 +5,5 @@
|
|||||||
package org.citra.citra_emu.features.settings.model
|
package org.citra.citra_emu.features.settings.model
|
||||||
|
|
||||||
interface AbstractMultiStringSetting : AbstractSetting {
|
interface AbstractMultiStringSetting : AbstractSetting {
|
||||||
var strings: List<String>
|
var strings: MutableSet<String>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,8 @@ package org.citra.citra_emu.features.settings.model.view
|
|||||||
import org.citra.citra_emu.features.settings.model.AbstractMultiIntSetting
|
import org.citra.citra_emu.features.settings.model.AbstractMultiIntSetting
|
||||||
import org.citra.citra_emu.features.settings.model.AbstractSetting
|
import org.citra.citra_emu.features.settings.model.AbstractSetting
|
||||||
import org.citra.citra_emu.features.settings.model.AbstractMultiShortSetting
|
import org.citra.citra_emu.features.settings.model.AbstractMultiShortSetting
|
||||||
|
import org.citra.citra_emu.features.settings.model.AbstractIntSetting
|
||||||
|
import org.citra.citra_emu.features.settings.model.AbstractShortSetting
|
||||||
|
|
||||||
class MultiChoiceSetting(
|
class MultiChoiceSetting(
|
||||||
setting: AbstractSetting?,
|
setting: AbstractSetting?,
|
||||||
@ -28,7 +30,7 @@ class MultiChoiceSetting(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
val setting = setting as AbstractMultiIntSetting
|
val setting = setting as AbstractMultiIntSetting
|
||||||
return setting.ints
|
return setting.ints.toList()
|
||||||
} catch (_: ClassCastException) {
|
} catch (_: ClassCastException) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,15 +50,15 @@ class MultiChoiceSetting(
|
|||||||
* @param selection New value of the int.
|
* @param selection New value of the int.
|
||||||
* @return the existing setting with the new value applied.
|
* @return the existing setting with the new value applied.
|
||||||
*/
|
*/
|
||||||
fun setSelectedValues(selection: List<Int>): AbstractMultiIntSetting {
|
fun setSelectedValues(selection: Int): AbstractMultiIntSetting {
|
||||||
val intSetting = setting as AbstractMultiIntSetting
|
val intSetting = setting as AbstractMultiIntSetting
|
||||||
intSetting.ints = selection
|
intSetting.ints.add(selection)
|
||||||
return intSetting
|
return intSetting
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setSelectedValues(selection: List<Short>): AbstractMultiShortSetting {
|
fun setSelectedValues(selection: Short): AbstractMultiShortSetting {
|
||||||
val shortSetting = setting as AbstractMultiShortSetting
|
val shortSetting = setting as AbstractMultiShortSetting
|
||||||
shortSetting.shorts = selection
|
shortSetting.shorts.add(selection)
|
||||||
return shortSetting
|
return shortSetting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ class StringMultiChoiceSetting(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
val setting = setting as AbstractMultiStringSetting
|
val setting = setting as AbstractMultiStringSetting
|
||||||
return setting.strings
|
return setting.strings.toList()
|
||||||
} catch (_: ClassCastException) {
|
} catch (_: ClassCastException) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,15 +78,15 @@ class StringMultiChoiceSetting(
|
|||||||
* @param selection New value of the int.
|
* @param selection New value of the int.
|
||||||
* @return the existing setting with the new value applied.
|
* @return the existing setting with the new value applied.
|
||||||
*/
|
*/
|
||||||
fun setSelectedValues(selection: List<String>): AbstractMultiStringSetting {
|
fun setSelectedValues(selection: String): AbstractMultiStringSetting {
|
||||||
val stringSetting = setting as AbstractMultiStringSetting
|
val stringSetting = setting as AbstractMultiStringSetting
|
||||||
stringSetting.strings = selection
|
stringSetting.strings.add(selection)
|
||||||
return stringSetting
|
return stringSetting
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setSelectedValues(selection: List<Short>): AbstractMultiShortSetting {
|
fun setSelectedValues(selection: Short): AbstractMultiShortSetting {
|
||||||
val shortSetting = setting as AbstractMultiShortSetting
|
val shortSetting = setting as AbstractMultiShortSetting
|
||||||
shortSetting.shorts = selection
|
shortSetting.shorts.add(selection)
|
||||||
return shortSetting
|
return shortSetting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,6 +38,9 @@ import org.citra.citra_emu.databinding.ListItemSettingsHeaderBinding
|
|||||||
import org.citra.citra_emu.features.settings.model.AbstractBooleanSetting
|
import org.citra.citra_emu.features.settings.model.AbstractBooleanSetting
|
||||||
import org.citra.citra_emu.features.settings.model.AbstractFloatSetting
|
import org.citra.citra_emu.features.settings.model.AbstractFloatSetting
|
||||||
import org.citra.citra_emu.features.settings.model.AbstractIntSetting
|
import org.citra.citra_emu.features.settings.model.AbstractIntSetting
|
||||||
|
import org.citra.citra_emu.features.settings.model.AbstractMultiIntSetting
|
||||||
|
import org.citra.citra_emu.features.settings.model.AbstractMultiShortSetting
|
||||||
|
import org.citra.citra_emu.features.settings.model.AbstractMultiStringSetting
|
||||||
import org.citra.citra_emu.features.settings.model.AbstractSetting
|
import org.citra.citra_emu.features.settings.model.AbstractSetting
|
||||||
import org.citra.citra_emu.features.settings.model.AbstractStringSetting
|
import org.citra.citra_emu.features.settings.model.AbstractStringSetting
|
||||||
import org.citra.citra_emu.features.settings.model.FloatSetting
|
import org.citra.citra_emu.features.settings.model.FloatSetting
|
||||||
@ -663,6 +666,17 @@ class SettingsAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getValueForMultiChoiceSelection(item: MultiChoiceSetting, which: Int, is_checked: Boolean): Int {
|
||||||
|
val valuesId = item.valuesId
|
||||||
|
if (valuesId > 0) {
|
||||||
|
val valuesArray = context.resources.getIntArray(valuesId)
|
||||||
|
if (is_checked) {
|
||||||
|
return valuesArray[which]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return which
|
||||||
|
}
|
||||||
|
|
||||||
private fun onMultiChoiceClick(item: MultiChoiceSetting) {
|
private fun onMultiChoiceClick(item: MultiChoiceSetting) {
|
||||||
clickedItem = item
|
clickedItem = item
|
||||||
val values = getSelectionForMultiChoiceValues(item)
|
val values = getSelectionForMultiChoiceValues(item)
|
||||||
@ -695,27 +709,27 @@ class SettingsAdapter(
|
|||||||
//TODO: REFACTOR TO BE MULTICHOICE
|
//TODO: REFACTOR TO BE MULTICHOICE
|
||||||
override fun onClick(dialog: DialogInterface?, which: Int, is_checked: Boolean) {
|
override fun onClick(dialog: DialogInterface?, which: Int, is_checked: Boolean) {
|
||||||
when (clickedItem) {
|
when (clickedItem) {
|
||||||
is SingleChoiceSetting -> {
|
is MultiChoiceSetting -> {
|
||||||
val scSetting = clickedItem as? SingleChoiceSetting
|
val scSetting = clickedItem as? MultiChoiceSetting
|
||||||
scSetting?.let {
|
scSetting?.let {
|
||||||
val setting = when (it.setting) {
|
val setting = when (it.setting) {
|
||||||
is AbstractIntSetting -> {
|
is AbstractMultiIntSetting -> {
|
||||||
val value = getValueForSingleChoiceSelection(it, which)
|
val value = getValueForMultiChoiceSelection(it, which, is_checked)
|
||||||
if (it.selectedValue != value) {
|
if (value !in it.selectedValues) {
|
||||||
fragmentView?.onSettingChanged()
|
fragmentView?.onSettingChanged()
|
||||||
}
|
}
|
||||||
it.setSelectedValue(value)
|
it.setSelectedValues(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is AbstractShortSetting -> {
|
is AbstractMultiShortSetting -> {
|
||||||
val value = getValueForSingleChoiceSelection(it, which).toShort()
|
val value = getValueForMultiChoiceSelection(it, which, is_checked).toShort()
|
||||||
if (it.selectedValue.toShort() != value) {
|
if (value !in it.selectedValues.map { it.toShort() }) {
|
||||||
fragmentView?.onSettingChanged()
|
fragmentView?.onSettingChanged()
|
||||||
}
|
}
|
||||||
it.setSelectedValue(value)
|
it.setSelectedValues(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> throw IllegalStateException("Unrecognized type used for SingleChoiceSetting!")
|
else -> throw IllegalStateException("Unrecognized type used for MultiChoiceSetting!")
|
||||||
}
|
}
|
||||||
fragmentView?.putSetting(setting)
|
fragmentView?.putSetting(setting)
|
||||||
fragmentView.loadSettingsList()
|
fragmentView.loadSettingsList()
|
||||||
@ -723,22 +737,22 @@ class SettingsAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is StringSingleChoiceSetting -> {
|
is StringMultiChoiceSetting -> {
|
||||||
val scSetting = clickedItem as? StringSingleChoiceSetting
|
val scSetting = clickedItem as? StringMultiChoiceSetting
|
||||||
scSetting?.let {
|
scSetting?.let {
|
||||||
val setting = when (it.setting) {
|
val setting = when (it.setting) {
|
||||||
is AbstractStringSetting -> {
|
is AbstractMultiStringSetting -> {
|
||||||
val value = it.getValueAt(which)
|
val value = it.getValueAt(which)
|
||||||
if (it.selectedValue != value) fragmentView?.onSettingChanged()
|
if (value !in it.selectedValues ) fragmentView?.onSettingChanged()
|
||||||
it.setSelectedValue(value ?: "")
|
it.setSelectedValues(value ?: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
is AbstractShortSetting -> {
|
is AbstractMultiShortSetting -> {
|
||||||
if (it.selectValueIndex != which) fragmentView?.onSettingChanged()
|
if (is_checked != it.selectValueIndices[which]) fragmentView?.onSettingChanged()
|
||||||
it.setSelectedValue(it.getValueAt(which)?.toShort() ?: 1)
|
it.setSelectedValues(it.getValueAt(which)?.toShort() ?: 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> throw IllegalStateException("Unrecognized type used for StringSingleChoiceSetting!")
|
else -> throw IllegalStateException("Unrecognized type used for StringMultiChoiceSetting!")
|
||||||
}
|
}
|
||||||
|
|
||||||
fragmentView?.putSetting(setting)
|
fragmentView?.putSetting(setting)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user