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