@ -6,16 +6,18 @@ package org.yuzu.yuzu_emu.features.settings.ui
import android.content.SharedPreferences
import android.os.Build
import android.text.TextUtils
import android.widget.Toast
import androidx.preference.PreferenceManager
import org.yuzu.yuzu_emu.R
import org.yuzu.yuzu_emu.YuzuApplication
import org.yuzu.yuzu_emu.features.settings.model.AbstractBooleanSetting
import org.yuzu.yuzu_emu.features.settings.model.AbstractIntSetting
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.ByteSetting
import org.yuzu.yuzu_emu.features.settings.model.IntSetting
import org.yuzu.yuzu_emu.features.settings.model.LongSetting
import org.yuzu.yuzu_emu.features.settings.model.Settings
import org.yuzu.yuzu_emu.features.settings.model.S tring Setting
import org.yuzu.yuzu_emu.features.settings.model.S hort Setting
import org.yuzu.yuzu_emu.features.settings.model.view.*
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
import org.yuzu.yuzu_emu.fragments.ResetSettingsDialogFragment
@ -27,7 +29,6 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
private var settingsList : ArrayList < SettingsItem > ? = null
private val settingsActivity get ( ) = fragmentView . activityView as SettingsActivity
private val settings get ( ) = fragmentView . activityView !! . settings
private lateinit var preferences : SharedPreferences
@ -41,17 +42,6 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
loadSettingsList ( )
}
fun putSetting ( setting : AbstractSetting ) {
if ( setting . section == null || setting . key == null ) {
return
}
val section = settings . getSection ( setting . section !! ) !!
if ( section . getSetting ( setting . key !! ) == null ) {
section . putSetting ( setting )
}
}
fun loadSettingsList ( ) {
if ( ! TextUtils . isEmpty ( gameId ) ) {
settingsActivity . setToolbarTitle ( " Game Settings: $gameId " )
@ -69,7 +59,12 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
Settings . SECTION _THEME -> addThemeSettings ( sl )
Settings . SECTION _DEBUG -> addDebugSettings ( sl )
else -> {
fragmentView . showToastMessage ( " Unimplemented menu " , false )
val context = YuzuApplication . appContext
Toast . makeText (
context ,
context . getString ( R . string . unimplemented _menu ) ,
Toast . LENGTH _SHORT
) . show ( )
return
}
}
@ -135,23 +130,23 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
sl . apply {
add (
SwitchSetting (
Int Setting. RENDERER _USE _SPEED _LIMIT ,
Boolean Setting. RENDERER _USE _SPEED _LIMIT ,
R . string . frame _limit _enable ,
R . string . frame _limit _enable _description ,
Int Setting. RENDERER_USE_SPEED_LIMIT . key ,
Int Setting. RENDERER_USE_SPEED_LIMIT . defaultValue
Boolean Setting. RENDERER_USE_SPEED_LIMIT . key ,
Boolean Setting. RENDERER_USE_SPEED_LIMIT . defaultValue
)
)
add (
SliderSetting (
In tSetting. RENDERER _SPEED _LIMIT ,
Shor tSetting. RENDERER _SPEED _LIMIT ,
R . string . frame _limit _slider ,
R . string . frame _limit _slider _description ,
1 ,
200 ,
" % " ,
In tSetting. RENDERER_SPEED_LIMIT . key ,
In tSetting. RENDERER_SPEED_LIMIT . defaultValue
Shor tSetting. RENDERER_SPEED_LIMIT . key ,
Shor tSetting. RENDERER_SPEED_LIMIT . defaultValue
)
)
add (
@ -182,11 +177,11 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
sl . apply {
add (
SwitchSetting (
Int Setting. USE _DOCKED _MODE ,
Boolean Setting. USE _DOCKED _MODE ,
R . string . use _docked _mode ,
R . string . use _docked _mode _description ,
Int Setting. USE_DOCKED_MODE . key ,
Int Setting. USE_DOCKED_MODE . defaultValue
Boolean Setting. USE_DOCKED_MODE . key ,
Boolean Setting. USE_DOCKED_MODE . defaultValue
)
)
add (
@ -222,11 +217,11 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
)
add (
DateTimeSetting (
Stri ngSetting. CUSTOM _RTC ,
Lo ngSetting. CUSTOM _RTC ,
R . string . set _custom _rtc ,
0 ,
Stri ngSetting. CUSTOM_RTC . key ,
Stri ngSetting. CUSTOM_RTC . defaultValue
Lo ngSetting. CUSTOM_RTC . key ,
Lo ngSetting. CUSTOM_RTC . defaultValue
)
)
}
@ -314,38 +309,38 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
)
add (
SwitchSetting (
Int Setting. RENDERER _USE _DISK _SHADER _CACHE ,
Boolean Setting. RENDERER _USE _DISK _SHADER _CACHE ,
R . string . use _disk _shader _cache ,
R . string . use _disk _shader _cache _description ,
Int Setting. RENDERER_USE_DISK_SHADER_CACHE . key ,
Int Setting. RENDERER_USE_DISK_SHADER_CACHE . defaultValue
Boolean Setting. RENDERER_USE_DISK_SHADER_CACHE . key ,
Boolean Setting. RENDERER_USE_DISK_SHADER_CACHE . defaultValue
)
)
add (
SwitchSetting (
Int Setting. RENDERER _FORCE _MAX _CLOCK ,
Boolean Setting. RENDERER _FORCE _MAX _CLOCK ,
R . string . renderer _force _max _clock ,
R . string . renderer _force _max _clock _description ,
Int Setting. RENDERER_FORCE_MAX_CLOCK . key ,
Int Setting. RENDERER_FORCE_MAX_CLOCK . defaultValue
Boolean Setting. RENDERER_FORCE_MAX_CLOCK . key ,
Boolean Setting. RENDERER_FORCE_MAX_CLOCK . defaultValue
)
)
add (
SwitchSetting (
Int Setting. RENDERER _ASYNCHRONOUS _SHADERS ,
Boolean Setting. RENDERER _ASYNCHRONOUS _SHADERS ,
R . string . renderer _asynchronous _shaders ,
R . string . renderer _asynchronous _shaders _description ,
Int Setting. RENDERER_ASYNCHRONOUS_SHADERS . key ,
Int Setting. RENDERER_ASYNCHRONOUS_SHADERS . defaultValue
Boolean Setting. RENDERER_ASYNCHRONOUS_SHADERS . key ,
Boolean Setting. RENDERER_ASYNCHRONOUS_SHADERS . defaultValue
)
)
add (
SwitchSetting (
Int Setting. RENDERER _REACTIVE _FLUSHING ,
Boolean Setting. RENDERER _REACTIVE _FLUSHING ,
R . string . renderer _reactive _flushing ,
R . string . renderer _reactive _flushing _description ,
Int Setting. RENDERER_REACTIVE_FLUSHING . key ,
Int Setting. RENDERER_REACTIVE_FLUSHING . defaultValue
Boolean Setting. RENDERER_REACTIVE_FLUSHING . key ,
Boolean Setting. RENDERER_REACTIVE_FLUSHING . defaultValue
)
)
}
@ -355,26 +350,26 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
settingsActivity . setToolbarTitle ( settingsActivity . getString ( R . string . preferences _audio ) )
sl . apply {
add (
S tringS ingleChoiceSetting(
String Setting. AUDIO _OUTPUT _ENGINE ,
S ingleChoiceSetting(
Int Setting. AUDIO _OUTPUT _ENGINE ,
R . string . audio _output _engine ,
0 ,
settingsActivity . resources . getStringArray ( R . array . outputEngineEntries ) ,
settingsActivity . resources . getStringArray ( R . array . outputEngineValues ) ,
String Setting. AUDIO_OUTPUT_ENGINE . key ,
String Setting. AUDIO_OUTPUT_ENGINE . defaultValue
R . array . outputEngineEntries ,
R . array . outputEngineValues ,
Int Setting. AUDIO_OUTPUT_ENGINE . key ,
Int Setting. AUDIO_OUTPUT_ENGINE . defaultValue
)
)
add (
SliderSetting (
Int Setting. AUDIO _VOLUME ,
Byte Setting. AUDIO _VOLUME ,
R . string . audio _volume ,
R . string . audio _volume _description ,
0 ,
100 ,
" % " ,
Int Setting. AUDIO_VOLUME . key ,
Int Setting. AUDIO_VOLUME . defaultValue
Byte Setting. AUDIO_VOLUME . key ,
Byte Setting. AUDIO_VOLUME . defaultValue
)
)
}
@ -384,19 +379,19 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
settingsActivity . setToolbarTitle ( settingsActivity . getString ( R . string . preferences _theme ) )
sl . apply {
val theme : AbstractIntSetting = object : AbstractIntSetting {
override va r int : Int
override va l int : Int
get ( ) = preferences . getInt ( Settings . PREF _THEME , 0 )
set ( value ) {
override fun setInt ( value : Int ) {
preferences . edit ( )
. putInt ( Settings . PREF _THEME , value )
. apply ( )
settingsActivity . recreate ( )
}
override val key : String ? = null
override val section : String ? = null
override val isRuntimeEditable : Boolean = false
override val valueAsString : String
get ( ) = preferences . getInt ( Settings . PREF _THEME , 0 ) . toString ( )
override val category = Settings . Category . UiGeneral
override val isRuntimeModifiable : Boolean = false
override val defaultValue : Any = 0
}
@ -423,19 +418,19 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
}
val themeMode : AbstractIntSetting = object : AbstractIntSetting {
override va r int : Int
override va l int : Int
get ( ) = preferences . getInt ( Settings . PREF _THEME _MODE , - 1 )
set ( value ) {
override fun setInt ( value : Int ) {
preferences . edit ( )
. putInt ( Settings . PREF _THEME _MODE , value )
. apply ( )
ThemeHelper . setThemeMode ( settingsActivity )
}
override val key : String ? = null
override val section : String ? = null
override val isRuntimeEditable : Boolean = false
override val valueAsString : String
get ( ) = preferences . getInt ( Settings . PREF _THEME _MODE , - 1 ) . toString ( )
override val category = Settings . Category . UiGeneral
override val isRuntimeModifiable : Boolean = false
override val defaultValue : Any = - 1
}
@ -450,20 +445,19 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
)
val blackBackgrounds : AbstractBooleanSetting = object : AbstractBooleanSetting {
override va r boolean : Boolean
override va l boolean : Boolean
get ( ) = preferences . getBoolean ( Settings . PREF _BLACK _BACKGROUNDS , false )
set ( value ) {
override fun setBoolean ( value : Boolean ) {
preferences . edit ( )
. putBoolean ( Settings . PREF _BLACK _BACKGROUNDS , value )
. apply ( )
settingsActivity . recreate ( )
}
override val key : String ? = null
override val section : String ? = null
override val isRuntimeEditable : Boolean = false
override val valueAsString : String
get ( ) = preferences . getBoolean ( Settings . PREF _BLACK _BACKGROUNDS , false )
. toString ( )
override val category = Settings . Category . UiGeneral
override val isRuntimeModifiable : Boolean = false
override val defaultValue : Any = false
}
@ -494,11 +488,11 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
)
add (
SwitchSetting (
Int Setting. RENDERER _DEBUG ,
Boolean Setting. RENDERER _DEBUG ,
R . string . renderer _debug ,
R . string . renderer _debug _description ,
Int Setting. RENDERER_DEBUG . key ,
Int Setting. RENDERER_DEBUG . defaultValue
Boolean Setting. RENDERER_DEBUG . key ,
Boolean Setting. RENDERER_DEBUG . defaultValue
)
)
@ -514,17 +508,18 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
)
val fastmem = object : AbstractBooleanSetting {
override va r boolean : Boolean
override va l boolean : Boolean
get ( ) =
BooleanSetting . FASTMEM . boolean && BooleanSetting . FASTMEM_EXCLUSIVES . boolean
set ( value ) {
BooleanSetting . FASTMEM . boolean = value
BooleanSetting . FASTMEM_EXCLUSIVES . boolean = value
override fun setBoolean ( value : Boolean ) {
BooleanSetting . FASTMEM . setBoolean ( value )
BooleanSetting . FASTMEM_EXCLUSIVES . setBoolean ( value )
}
override val key : String ? = null
override val section : String = Settings . SECTION _CPU
override val isRuntimeEditable : Boolean = false
override val valueAsString : String = " "
override val category = Settings . Category . Cpu
override val isRuntimeModifiable : Boolean = false
override val defaultValue : Any = true
}
add (