mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-06-02 13:05:00 -06:00
Added code in arrays.xml to display the buttons.
This code has the buttons display but clicking on them crashes the app. Will debug further. Also replaced setSelectedValues with add and remove SelectedValue for clarity purposes.
This commit is contained in:
parent
334f9385ba
commit
db04f2c29d
@ -220,6 +220,8 @@ class Settings {
|
|||||||
R.string.turbo_limit_hotkey
|
R.string.turbo_limit_hotkey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val comboSelection = mutableSetOf<String>()
|
||||||
|
|
||||||
const val PREF_FIRST_APP_LAUNCH = "FirstApplicationLaunch"
|
const val PREF_FIRST_APP_LAUNCH = "FirstApplicationLaunch"
|
||||||
const val PREF_MATERIAL_YOU = "MaterialYouTheme"
|
const val PREF_MATERIAL_YOU = "MaterialYouTheme"
|
||||||
const val PREF_THEME_MODE = "ThemeMode"
|
const val PREF_THEME_MODE = "ThemeMode"
|
||||||
|
|||||||
@ -44,21 +44,32 @@ class MultiChoiceSetting(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a value to the backing int. If that int was previously null,
|
* Add values to multi choice backing mutable sets.
|
||||||
* initializes a new one and returns it, so it can be added to the Hashmap.
|
|
||||||
*
|
*
|
||||||
* @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 added.
|
||||||
*/
|
*/
|
||||||
fun setSelectedValues(selection: Int): AbstractMultiIntSetting {
|
fun addSelectedValue(selection: Int): AbstractMultiIntSetting {
|
||||||
val intSetting = setting as AbstractMultiIntSetting
|
val intSetting = setting as AbstractMultiIntSetting
|
||||||
intSetting.ints.add(selection)
|
intSetting.ints.add(selection)
|
||||||
return intSetting
|
return intSetting
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setSelectedValues(selection: Short): AbstractMultiShortSetting {
|
fun addSelectedValue(selection: Short): AbstractMultiShortSetting {
|
||||||
val shortSetting = setting as AbstractMultiShortSetting
|
val shortSetting = setting as AbstractMultiShortSetting
|
||||||
shortSetting.shorts.add(selection)
|
shortSetting.shorts.add(selection)
|
||||||
return shortSetting
|
return shortSetting
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun removeSelectedValue(selection: Int): AbstractMultiIntSetting {
|
||||||
|
val intSetting = setting as AbstractMultiIntSetting
|
||||||
|
intSetting.ints.remove(selection)
|
||||||
|
return intSetting
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeSelectedValue(selection: Short): AbstractMultiShortSetting {
|
||||||
|
val shortSetting = setting as AbstractMultiShortSetting
|
||||||
|
shortSetting.shorts.remove(selection)
|
||||||
|
return shortSetting
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,21 +72,32 @@ class StringMultiChoiceSetting(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a value to the backing int. If that int was previously null,
|
* Add values to multi choice through the backing mutable sets.
|
||||||
* initializes a new one and returns it, so it can be added to the Hashmap.
|
|
||||||
*
|
*
|
||||||
* @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 added.
|
||||||
*/
|
*/
|
||||||
fun setSelectedValues(selection: String): AbstractMultiStringSetting {
|
fun addSelectedValue(selection: String): AbstractMultiStringSetting {
|
||||||
val stringSetting = setting as AbstractMultiStringSetting
|
val stringSetting = setting as AbstractMultiStringSetting
|
||||||
stringSetting.strings.add(selection)
|
stringSetting.strings.add(selection)
|
||||||
return stringSetting
|
return stringSetting
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setSelectedValues(selection: Short): AbstractMultiShortSetting {
|
fun addSelectedValue(selection: Short): AbstractMultiShortSetting {
|
||||||
val shortSetting = setting as AbstractMultiShortSetting
|
val shortSetting = setting as AbstractMultiShortSetting
|
||||||
shortSetting.shorts.add(selection)
|
shortSetting.shorts.add(selection)
|
||||||
return shortSetting
|
return shortSetting
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun removeSelectedValue(selection: String): AbstractMultiStringSetting {
|
||||||
|
val stringSetting = setting as AbstractMultiStringSetting
|
||||||
|
stringSetting.strings.remove(selection)
|
||||||
|
return stringSetting
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeSelectedValue(selection: Short): AbstractMultiShortSetting {
|
||||||
|
val shortSetting = setting as AbstractMultiShortSetting
|
||||||
|
shortSetting.shorts.remove(selection)
|
||||||
|
return shortSetting
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -716,22 +716,26 @@ class SettingsAdapter(
|
|||||||
is AbstractMultiIntSetting -> {
|
is AbstractMultiIntSetting -> {
|
||||||
val value = getValueForMultiChoiceSelection(it, which, is_checked)
|
val value = getValueForMultiChoiceSelection(it, which, is_checked)
|
||||||
if (value !in it.selectedValues) {
|
if (value !in it.selectedValues) {
|
||||||
|
it.removeSelectedValue(value)
|
||||||
fragmentView?.onSettingChanged()
|
fragmentView?.onSettingChanged()
|
||||||
|
} else {
|
||||||
|
it.addSelectedValue(value)
|
||||||
}
|
}
|
||||||
it.setSelectedValues(value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is AbstractMultiShortSetting -> {
|
is AbstractMultiShortSetting -> {
|
||||||
val value = getValueForMultiChoiceSelection(it, which, is_checked).toShort()
|
val value = getValueForMultiChoiceSelection(it, which, is_checked).toShort()
|
||||||
if (value !in it.selectedValues.map { it.toShort() }) {
|
if (value !in it.selectedValues.map { it.toShort() }) {
|
||||||
|
it.removeSelectedValue(value)
|
||||||
fragmentView?.onSettingChanged()
|
fragmentView?.onSettingChanged()
|
||||||
|
} else {
|
||||||
|
it.addSelectedValue(value)
|
||||||
}
|
}
|
||||||
it.setSelectedValues(value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> throw IllegalStateException("Unrecognized type used for MultiChoiceSetting!")
|
else -> throw IllegalStateException("Unrecognized type used for MultiChoiceSetting!")
|
||||||
}
|
}
|
||||||
fragmentView?.putSetting(setting)
|
fragmentView?.putSetting(setting as AbstractSetting)
|
||||||
fragmentView.loadSettingsList()
|
fragmentView.loadSettingsList()
|
||||||
closeDialog()
|
closeDialog()
|
||||||
}
|
}
|
||||||
@ -743,19 +747,27 @@ class SettingsAdapter(
|
|||||||
val setting = when (it.setting) {
|
val setting = when (it.setting) {
|
||||||
is AbstractMultiStringSetting -> {
|
is AbstractMultiStringSetting -> {
|
||||||
val value = it.getValueAt(which)
|
val value = it.getValueAt(which)
|
||||||
if (value !in it.selectedValues ) fragmentView?.onSettingChanged()
|
if (value !in it.selectedValues ) {
|
||||||
it.setSelectedValues(value ?: "")
|
it.removeSelectedValue(value ?: "")
|
||||||
|
fragmentView?.onSettingChanged()
|
||||||
|
} else {
|
||||||
|
it.addSelectedValue(value ?: "")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is AbstractMultiShortSetting -> {
|
is AbstractMultiShortSetting -> {
|
||||||
if (is_checked != it.selectValueIndices[which]) fragmentView?.onSettingChanged()
|
if (is_checked != it.selectValueIndices[which]) {
|
||||||
it.setSelectedValues(it.getValueAt(which)?.toShort() ?: 1)
|
it.removeSelectedValue(it.getValueAt(which)?.toShort() ?: 1)
|
||||||
|
fragmentView?.onSettingChanged()
|
||||||
|
} else {
|
||||||
|
it.addSelectedValue(it.getValueAt(which)?.toShort() ?: 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> throw IllegalStateException("Unrecognized type used for StringMultiChoiceSetting!")
|
else -> throw IllegalStateException("Unrecognized type used for StringMultiChoiceSetting!")
|
||||||
}
|
}
|
||||||
|
|
||||||
fragmentView?.putSetting(setting)
|
fragmentView?.putSetting(setting as AbstractSetting)
|
||||||
fragmentView.loadSettingsList()
|
fragmentView.loadSettingsList()
|
||||||
closeDialog()
|
closeDialog()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import org.citra.citra_emu.display.PortraitScreenLayout
|
|||||||
import org.citra.citra_emu.display.ScreenLayout
|
import org.citra.citra_emu.display.ScreenLayout
|
||||||
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.AbstractIntSetting
|
import org.citra.citra_emu.features.settings.model.AbstractIntSetting
|
||||||
|
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.AbstractShortSetting
|
import org.citra.citra_emu.features.settings.model.AbstractShortSetting
|
||||||
import org.citra.citra_emu.features.settings.model.AbstractStringSetting
|
import org.citra.citra_emu.features.settings.model.AbstractStringSetting
|
||||||
@ -38,6 +39,7 @@ import org.citra.citra_emu.features.settings.model.view.SettingsItem
|
|||||||
import org.citra.citra_emu.features.settings.model.view.SingleChoiceSetting
|
import org.citra.citra_emu.features.settings.model.view.SingleChoiceSetting
|
||||||
import org.citra.citra_emu.features.settings.model.view.SliderSetting
|
import org.citra.citra_emu.features.settings.model.view.SliderSetting
|
||||||
import org.citra.citra_emu.features.settings.model.view.StringInputSetting
|
import org.citra.citra_emu.features.settings.model.view.StringInputSetting
|
||||||
|
import org.citra.citra_emu.features.settings.model.view.StringMultiChoiceSetting
|
||||||
import org.citra.citra_emu.features.settings.model.view.StringSingleChoiceSetting
|
import org.citra.citra_emu.features.settings.model.view.StringSingleChoiceSetting
|
||||||
import org.citra.citra_emu.features.settings.model.view.SubmenuSetting
|
import org.citra.citra_emu.features.settings.model.view.SubmenuSetting
|
||||||
import org.citra.citra_emu.features.settings.model.view.SwitchSetting
|
import org.citra.citra_emu.features.settings.model.view.SwitchSetting
|
||||||
@ -809,6 +811,26 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
|||||||
|
|
||||||
private fun addComboButtonSettings(sl: ArrayList<SettingsItem>) {
|
private fun addComboButtonSettings(sl: ArrayList<SettingsItem>) {
|
||||||
settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.combo_key))
|
settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.combo_key))
|
||||||
|
val comboSetting = object : AbstractMultiStringSetting {
|
||||||
|
override var strings: MutableSet<String>
|
||||||
|
get() {
|
||||||
|
return Settings.comboSelection
|
||||||
|
}
|
||||||
|
set(values) {
|
||||||
|
for (item in values) {
|
||||||
|
Settings.comboSelection.add(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
override val key = null
|
||||||
|
override val section = null
|
||||||
|
override val isRuntimeEditable = false
|
||||||
|
override val valueAsString get() = ""
|
||||||
|
override val defaultValue = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
val buttons = settingsActivity.resources.getStringArray(R.array.n3dsButtons).take(10).toTypedArray()
|
||||||
|
val combo_values = settingsActivity.resources.getStringArray(R.array.combovalues)
|
||||||
|
|
||||||
sl.apply {
|
sl.apply {
|
||||||
add(
|
add(
|
||||||
SwitchSetting(
|
SwitchSetting(
|
||||||
@ -819,20 +841,15 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
|||||||
BooleanSetting.ENABLE_COMBO_KEY.defaultValue,
|
BooleanSetting.ENABLE_COMBO_KEY.defaultValue,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
add(HeaderSetting(R.string.combo_key_options))
|
|
||||||
// TODO: Implement displaying selectable buttons
|
|
||||||
/*
|
|
||||||
add(
|
add(
|
||||||
StringSingleChoiceSetting(
|
StringMultiChoiceSetting(
|
||||||
comboSetting,
|
comboSetting,
|
||||||
R.string.emulated_language,
|
R.string.combo_key_options,
|
||||||
0,
|
0,
|
||||||
R.array.n3dsButtons,
|
buttons,
|
||||||
R.array.
|
combo_values
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -169,6 +169,20 @@
|
|||||||
<item>@string/button_turbo</item>
|
<item>@string/button_turbo</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<integer-array name="combovalues">
|
||||||
|
<item>0</item>
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
<item>3</item>
|
||||||
|
<item>4</item>
|
||||||
|
<item>5</item>
|
||||||
|
<item>6</item>
|
||||||
|
<item>7</item>
|
||||||
|
<item>8</item>
|
||||||
|
<item>9</item>
|
||||||
|
<item>10</item>
|
||||||
|
</integer-array>
|
||||||
|
|
||||||
<string-array name="cameraImageSourceNames">
|
<string-array name="cameraImageSourceNames">
|
||||||
<item>@string/blank</item>
|
<item>@string/blank</item>
|
||||||
<item>@string/still_image</item>
|
<item>@string/still_image</item>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user