@ -6,7 +6,9 @@ package org.yuzu.yuzu_emu.features.settings.ui
import android.text.TextUtils
import android.text.TextUtils
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import org.yuzu.yuzu_emu.R
import org.yuzu.yuzu_emu.R
import org.yuzu.yuzu_emu.features.settings.model.Setting
import org.yuzu.yuzu_emu.features.settings.model.AbstractSetting
import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting
import org.yuzu.yuzu_emu.features.settings.model.IntSetting
import org.yuzu.yuzu_emu.features.settings.model.Settings
import org.yuzu.yuzu_emu.features.settings.model.Settings
import org.yuzu.yuzu_emu.features.settings.model.view.*
import org.yuzu.yuzu_emu.features.settings.model.view.*
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
@ -28,8 +30,11 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
loadSettingsList ( )
loadSettingsList ( )
}
}
fun putSetting ( setting : Setting ) {
fun putSetting ( setting : AbstractSetting ) {
settings . getSection ( setting . section ) !! . putSetting ( setting )
val section = settings . getSection ( setting . section !! ) !!
if ( section . getSetting ( setting . key !! ) == null ) {
section . putSetting ( setting )
}
}
}
fun loadSettingsList ( ) {
fun loadSettingsList ( ) {
@ -60,7 +65,6 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
sl . apply {
sl . apply {
add (
add (
SubmenuSetting (
SubmenuSetting (
null ,
null ,
null ,
R . string . preferences _general ,
R . string . preferences _general ,
0 ,
0 ,
@ -69,7 +73,6 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
)
)
add (
add (
SubmenuSetting (
SubmenuSetting (
null ,
null ,
null ,
R . string . preferences _system ,
R . string . preferences _system ,
0 ,
0 ,
@ -78,7 +81,6 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
)
)
add (
add (
SubmenuSetting (
SubmenuSetting (
null ,
null ,
null ,
R . string . preferences _graphics ,
R . string . preferences _graphics ,
0 ,
0 ,
@ -87,7 +89,6 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
)
)
add (
add (
SubmenuSetting (
SubmenuSetting (
null ,
null ,
null ,
R . string . preferences _audio ,
R . string . preferences _audio ,
0 ,
0 ,
@ -99,45 +100,36 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
private fun addGeneralSettings ( sl : ArrayList < SettingsItem > ) {
private fun addGeneralSettings ( sl : ArrayList < SettingsItem > ) {
settingsActivity . setTitle ( R . string . preferences _general )
settingsActivity . setTitle ( R . string . preferences _general )
val rendererSection = settings . getSection ( Settings . SECTION _RENDERER )
val frameLimitEnable =
rendererSection !! . getSetting ( SettingsFile . KEY _RENDERER _USE _SPEED _LIMIT )
val frameLimitValue = rendererSection . getSetting ( SettingsFile . KEY _RENDERER _SPEED _LIMIT )
val cpuSection = settings . getSection ( Settings . SECTION _CPU )
val cpuAccuracy = cpuSection !! . getSetting ( SettingsFile . KEY _CPU _ACCURACY )
sl . apply {
sl . apply {
add (
add (
SwitchSetting (
SwitchSetting (
SettingsFile . KEY _RENDERER _USE _SPEED _LIMIT ,
IntSetting . RENDERER _USE _SPEED _LIMIT ,
Settings . SECTION _RENDERER ,
frameLimitEnable ,
R . string . frame _limit _enable ,
R . string . frame _limit _enable ,
R . string . frame _limit _enable _description ,
R . string . frame _limit _enable _description ,
IntSetting . RENDERER_USE_SPEED_LIMIT . key ,
true
true
)
)
)
)
add (
add (
SliderSetting (
SliderSetting (
SettingsFile . KEY _RENDERER _SPEED _LIMIT ,
IntSetting . RENDERER _SPEED _LIMIT ,
Settings . SECTION _RENDERER ,
frameLimitValue ,
R . string . frame _limit _slider ,
R . string . frame _limit _slider ,
R . string . frame _limit _slider _description ,
R . string . frame _limit _slider _description ,
1 ,
1 ,
200 ,
200 ,
" % " ,
" % " ,
IntSetting . RENDERER_SPEED_LIMIT . key ,
100
100
)
)
)
)
add (
add (
SingleChoiceSetting (
SingleChoiceSetting (
SettingsFile . KEY _CPU _ACCURACY ,
IntSetting . CPU _ACCURACY ,
Settings . SECTION _CPU ,
cpuAccuracy ,
R . string . cpu _accuracy ,
R . string . cpu _accuracy ,
0 ,
0 ,
R . array . cpuAccuracyNames ,
R . array . cpuAccuracyNames ,
R . array . cpuAccuracyValues ,
R . array . cpuAccuracyValues ,
IntSetting . CPU_ACCURACY . key ,
0
0
)
)
)
)
@ -146,42 +138,35 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
private fun addSystemSettings ( sl : ArrayList < SettingsItem > ) {
private fun addSystemSettings ( sl : ArrayList < SettingsItem > ) {
settingsActivity . setTitle ( R . string . preferences _system )
settingsActivity . setTitle ( R . string . preferences _system )
val systemSection = settings . getSection ( Settings . SECTION _SYSTEM )
val dockedMode = systemSection !! . getSetting ( SettingsFile . KEY _USE _DOCKED _MODE )
val region = systemSection . getSetting ( SettingsFile . KEY _REGION _INDEX )
val language = systemSection . getSetting ( SettingsFile . KEY _LANGUAGE _INDEX )
sl . apply {
sl . apply {
add (
add (
SwitchSetting (
SwitchSetting (
SettingsFile . KEY _USE _DOCKED _MODE ,
IntSetting . USE _DOCKED _MODE ,
Settings . SECTION _SYSTEM ,
dockedMode ,
R . string . use _docked _mode ,
R . string . use _docked _mode ,
R . string . use _docked _mode _description ,
R . string . use _docked _mode _description ,
false ,
IntSetting . USE_DOCKED_MODE . key ,
false
)
)
)
)
add (
add (
SingleChoiceSetting (
SingleChoiceSetting (
SettingsFile . KEY _REGION _INDEX ,
IntSetting . REGION _INDEX ,
Settings . SECTION _SYSTEM ,
region ,
R . string . emulated _region ,
R . string . emulated _region ,
0 ,
0 ,
R . array . regionNames ,
R . array . regionNames ,
R . array . regionValues ,
R . array . regionValues ,
IntSetting . REGION_INDEX . key ,
- 1
- 1
)
)
)
)
add (
add (
SingleChoiceSetting (
SingleChoiceSetting (
SettingsFile . KEY _LANGUAGE _INDEX ,
IntSetting . LANGUAGE _INDEX ,
Settings . SECTION _SYSTEM ,
language ,
R . string . emulated _language ,
R . string . emulated _language ,
0 ,
0 ,
R . array . languageNames ,
R . array . languageNames ,
R . array . languageValues ,
R . array . languageValues ,
IntSetting . LANGUAGE_INDEX . key ,
1
1
)
)
)
)
@ -190,133 +175,106 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
private fun addGraphicsSettings ( sl : ArrayList < SettingsItem > ) {
private fun addGraphicsSettings ( sl : ArrayList < SettingsItem > ) {
settingsActivity . setTitle ( R . string . preferences _graphics )
settingsActivity . setTitle ( R . string . preferences _graphics )
val rendererSection = settings . getSection ( Settings . SECTION _RENDERER )
val rendererBackend = rendererSection !! . getSetting ( SettingsFile . KEY _RENDERER _BACKEND )
val rendererAccuracy = rendererSection . getSetting ( SettingsFile . KEY _RENDERER _ACCURACY )
val rendererResolution = rendererSection . getSetting ( SettingsFile . KEY _RENDERER _RESOLUTION )
val rendererScalingFilter =
rendererSection . getSetting ( SettingsFile . KEY _RENDERER _SCALING _FILTER )
val rendererAntiAliasing =
rendererSection . getSetting ( SettingsFile . KEY _RENDERER _ANTI _ALIASING )
val rendererAspectRatio =
rendererSection . getSetting ( SettingsFile . KEY _RENDERER _ASPECT _RATIO )
val rendererUseDiskShaderCache =
rendererSection . getSetting ( SettingsFile . KEY _RENDERER _USE _DISK _SHADER _CACHE )
val rendererForceMaxClocks =
rendererSection . getSetting ( SettingsFile . KEY _RENDERER _FORCE _MAX _CLOCK )
val rendererAsynchronousShaders =
rendererSection . getSetting ( SettingsFile . KEY _RENDERER _ASYNCHRONOUS _SHADERS )
val rendererDebug = rendererSection . getSetting ( SettingsFile . KEY _RENDERER _DEBUG )
sl . apply {
sl . apply {
add (
add (
SingleChoiceSetting (
SingleChoiceSetting (
SettingsFile . KEY _RENDERER _BACKEND ,
IntSetting . RENDERER _BACKEND ,
Settings . SECTION _RENDERER ,
rendererBackend ,
R . string . renderer _api ,
R . string . renderer _api ,
0 ,
0 ,
R . array . rendererApiNames ,
R . array . rendererApiNames ,
R . array . rendererApiValues ,
R . array . rendererApiValues ,
IntSetting . RENDERER_BACKEND . key ,
1
1
)
)
)
)
add (
add (
SingleChoiceSetting (
SingleChoiceSetting (
SettingsFile . KEY _RENDERER _ACCURACY ,
IntSetting . RENDERER _ACCURACY ,
Settings . SECTION _RENDERER ,
rendererAccuracy ,
R . string . renderer _accuracy ,
R . string . renderer _accuracy ,
0 ,
0 ,
R . array . rendererAccuracyNames ,
R . array . rendererAccuracyNames ,
R . array . rendererAccuracyValues ,
R . array . rendererAccuracyValues ,
IntSetting . RENDERER_ACCURACY . key ,
0
0
)
)
)
)
add (
add (
SingleChoiceSetting (
SingleChoiceSetting (
SettingsFile . KEY _RENDERER _RESOLUTION ,
IntSetting . RENDERER _RESOLUTION ,
Settings . SECTION _RENDERER ,
rendererResolution ,
R . string . renderer _resolution ,
R . string . renderer _resolution ,
0 ,
0 ,
R . array . rendererResolutionNames ,
R . array . rendererResolutionNames ,
R . array . rendererResolutionValues ,
R . array . rendererResolutionValues ,
IntSetting . RENDERER_RESOLUTION . key ,
2
2
)
)
)
)
add (
add (
SingleChoiceSetting (
SingleChoiceSetting (
SettingsFile . KEY _RENDERER _SCALING _FILTER ,
IntSetting . RENDERER _SCALING _FILTER ,
Settings . SECTION _RENDERER ,
rendererScalingFilter ,
R . string . renderer _scaling _filter ,
R . string . renderer _scaling _filter ,
0 ,
0 ,
R . array . rendererScalingFilterNames ,
R . array . rendererScalingFilterNames ,
R . array . rendererScalingFilterValues ,
R . array . rendererScalingFilterValues ,
IntSetting . RENDERER_SCALING_FILTER . key ,
1
1
)
)
)
)
add (
add (
SingleChoiceSetting (
SingleChoiceSetting (
SettingsFile . KEY _RENDERER _ANTI _ALIASING ,
IntSetting . RENDERER _ANTI _ALIASING ,
Settings . SECTION _RENDERER ,
rendererAntiAliasing ,
R . string . renderer _anti _aliasing ,
R . string . renderer _anti _aliasing ,
0 ,
0 ,
R . array . rendererAntiAliasingNames ,
R . array . rendererAntiAliasingNames ,
R . array . rendererAntiAliasingValues ,
R . array . rendererAntiAliasingValues ,
IntSetting . RENDERER_ANTI_ALIASING . key ,
0
0
)
)
)
)
add (
add (
SingleChoiceSetting (
SingleChoiceSetting (
SettingsFile . KEY _RENDERER _ASPECT _RATIO ,
IntSetting . RENDERER _ASPECT _RATIO ,
Settings . SECTION _RENDERER ,
rendererAspectRatio ,
R . string . renderer _aspect _ratio ,
R . string . renderer _aspect _ratio ,
0 ,
0 ,
R . array . rendererAspectRatioNames ,
R . array . rendererAspectRatioNames ,
R . array . rendererAspectRatioValues ,
R . array . rendererAspectRatioValues ,
IntSetting . RENDERER_ASPECT_RATIO . key ,
0
0
)
)
)
)
add (
add (
SwitchSetting (
SwitchSetting (
SettingsFile . KEY _RENDERER _USE _DISK _SHADER _CACHE ,
IntSetting . RENDERER _USE _DISK _SHADER _CACHE ,
Settings . SECTION _RENDERER ,
rendererUseDiskShaderCache ,
R . string . use _disk _shader _cache ,
R . string . use _disk _shader _cache ,
R . string . use _disk _shader _cache _description ,
R . string . use _disk _shader _cache _description ,
IntSetting . RENDERER_USE_DISK_SHADER_CACHE . key ,
true
true
)
)
)
)
add (
add (
SwitchSetting (
SwitchSetting (
SettingsFile . KEY _RENDERER _FORCE _MAX _CLOCK ,
IntSetting . RENDERER _FORCE _MAX _CLOCK ,
Settings . SECTION _RENDERER ,
rendererForceMaxClocks ,
R . string . renderer _force _max _clock ,
R . string . renderer _force _max _clock ,
R . string . renderer _force _max _clock _description ,
R . string . renderer _force _max _clock _description ,
IntSetting . RENDERER_FORCE_MAX_CLOCK . key ,
true
true
)
)
)
)
add (
add (
SwitchSetting (
SwitchSetting (
SettingsFile . KEY _RENDERER _ASYNCHRONOUS _SHADERS ,
IntSetting . RENDERER _ASYNCHRONOUS _SHADERS ,
Settings . SECTION _RENDERER ,
rendererAsynchronousShaders ,
R . string . renderer _asynchronous _shaders ,
R . string . renderer _asynchronous _shaders ,
R . string . renderer _asynchronous _shaders _description ,
R . string . renderer _asynchronous _shaders _description ,
IntSetting . RENDERER_ASYNCHRONOUS_SHADERS . key ,
false
false
)
)
)
)
add (
add (
SwitchSetting (
SwitchSetting (
SettingsFile . KEY _RENDERER _DEBUG ,
IntSetting . RENDERER _DEBUG ,
Settings . SECTION _RENDERER ,
rendererDebug ,
R . string . renderer _debug ,
R . string . renderer _debug ,
R . string . renderer _debug _description ,
R . string . renderer _debug _description ,
IntSetting . RENDERER_DEBUG . key ,
false
false
)
)
)
)
@ -325,18 +283,15 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
private fun addAudioSettings ( sl : ArrayList < SettingsItem > ) {
private fun addAudioSettings ( sl : ArrayList < SettingsItem > ) {
settingsActivity . setTitle ( R . string . preferences _audio )
settingsActivity . setTitle ( R . string . preferences _audio )
val audioSection = settings . getSection ( Settings . SECTION _AUDIO )
val audioVolume = audioSection !! . getSetting ( SettingsFile . KEY _AUDIO _VOLUME )
sl . add (
sl . add (
SliderSetting (
SliderSetting (
SettingsFile . KEY _AUDIO _VOLUME ,
IntSetting . AUDIO _VOLUME ,
Settings . SECTION _AUDIO ,
audioVolume ,
R . string . audio _volume ,
R . string . audio _volume ,
R . string . audio _volume _description ,
R . string . audio _volume _description ,
0 ,
0 ,
100 ,
100 ,
" % " ,
" % " ,
IntSetting . AUDIO_VOLUME . key ,
100
100
)
)
)
)