forked from MeloNX/MeloNX
add more options, fix vsync option
This commit is contained in:
parent
7b1ce437ef
commit
e9c7564a03
@ -91,7 +91,13 @@ class GameHost(context: Context?, val controller: GameController, val mainViewMo
|
||||
|
||||
var surface = surfaceHolder.surface;
|
||||
|
||||
var success = _nativeRyujinx.graphicsInitialize(GraphicsConfiguration())
|
||||
var settings = QuickSettings(mainViewModel.activity)
|
||||
|
||||
var success = _nativeRyujinx.graphicsInitialize(GraphicsConfiguration().apply {
|
||||
EnableShaderCache = settings.enableShaderCache
|
||||
EnableTextureRecompression = settings.enableTextureRecompression
|
||||
ResScale = settings.resScale
|
||||
})
|
||||
|
||||
|
||||
var nativeHelpers = NativeHelpers()
|
||||
@ -108,7 +114,6 @@ class GameHost(context: Context?, val controller: GameController, val mainViewMo
|
||||
window
|
||||
)
|
||||
|
||||
var settings = QuickSettings(mainViewModel.activity)
|
||||
|
||||
success = _nativeRyujinx.deviceInitialize(
|
||||
settings.isHostMapped,
|
||||
@ -135,12 +140,6 @@ class GameHost(context: Context?, val controller: GameController, val mainViewMo
|
||||
);
|
||||
|
||||
_guestThread = thread(start = true) {
|
||||
runBlocking {
|
||||
this.launch {
|
||||
delay(5000)
|
||||
_nativeRyujinx.graphicsRendererSetVsync(false);
|
||||
}
|
||||
}
|
||||
runGame()
|
||||
}
|
||||
_isStarted = success;
|
||||
|
@ -11,6 +11,9 @@ class QuickSettings(val activity: MainActivity) {
|
||||
var enableVsync: Boolean
|
||||
var useNce: Boolean
|
||||
var isHostMapped: Boolean
|
||||
var enableShaderCache: Boolean
|
||||
var enableTextureRecompression: Boolean
|
||||
var resScale : Float
|
||||
|
||||
private var sharedPref: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
|
||||
@ -21,5 +24,8 @@ class QuickSettings(val activity: MainActivity) {
|
||||
enableDocked = sharedPref.getBoolean("enableDocked", true)
|
||||
enablePtc = sharedPref.getBoolean("enablePtc", true)
|
||||
ignoreMissingServices = sharedPref.getBoolean("ignoreMissingServices", false)
|
||||
enableShaderCache = sharedPref.getBoolean("enableShaderCache", true)
|
||||
enableTextureRecompression = sharedPref.getBoolean("enableTextureRecompression", false)
|
||||
resScale = sharedPref.getFloat("resScale", 1f)
|
||||
}
|
||||
}
|
@ -17,12 +17,17 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
||||
return PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
}
|
||||
|
||||
fun initializeState(isHostMapped : MutableState<Boolean>,
|
||||
useNce : MutableState<Boolean>,
|
||||
enableVsync : MutableState<Boolean>,
|
||||
enableDocked : MutableState<Boolean>,
|
||||
enablePtc : MutableState<Boolean>,
|
||||
ignoreMissingServices : MutableState<Boolean>)
|
||||
fun initializeState(
|
||||
isHostMapped: MutableState<Boolean>,
|
||||
useNce: MutableState<Boolean>,
|
||||
enableVsync: MutableState<Boolean>,
|
||||
enableDocked: MutableState<Boolean>,
|
||||
enablePtc: MutableState<Boolean>,
|
||||
ignoreMissingServices: MutableState<Boolean>,
|
||||
enableShaderCache: MutableState<Boolean>,
|
||||
enableTextureRecompression: MutableState<Boolean>,
|
||||
resScale: MutableState<Float>
|
||||
)
|
||||
{
|
||||
|
||||
isHostMapped.value = sharedPref.getBoolean("isHostMapped", true)
|
||||
@ -31,14 +36,22 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
||||
enableDocked.value = sharedPref.getBoolean("enableDocked", true)
|
||||
enablePtc.value = sharedPref.getBoolean("enablePtc", true)
|
||||
ignoreMissingServices.value = sharedPref.getBoolean("ignoreMissingServices", false)
|
||||
enableShaderCache.value = sharedPref.getBoolean("enableShaderCache", true)
|
||||
enableTextureRecompression.value = sharedPref.getBoolean("enableTextureRecompression", false)
|
||||
resScale.value = sharedPref.getFloat("resScale", 1f)
|
||||
}
|
||||
|
||||
fun save(isHostMapped : MutableState<Boolean>,
|
||||
useNce : MutableState<Boolean>,
|
||||
enableVsync : MutableState<Boolean>,
|
||||
enableDocked : MutableState<Boolean>,
|
||||
enablePtc : MutableState<Boolean>,
|
||||
ignoreMissingServices : MutableState<Boolean>){
|
||||
fun save(
|
||||
isHostMapped: MutableState<Boolean>,
|
||||
useNce: MutableState<Boolean>,
|
||||
enableVsync: MutableState<Boolean>,
|
||||
enableDocked: MutableState<Boolean>,
|
||||
enablePtc: MutableState<Boolean>,
|
||||
ignoreMissingServices: MutableState<Boolean>,
|
||||
enableShaderCache: MutableState<Boolean>,
|
||||
enableTextureRecompression: MutableState<Boolean>,
|
||||
resScale: MutableState<Float>
|
||||
){
|
||||
var editor = sharedPref.edit()
|
||||
|
||||
editor.putBoolean("isHostMapped", isHostMapped?.value ?: true)
|
||||
@ -47,6 +60,9 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
||||
editor.putBoolean("enableDocked", enableDocked?.value ?: true)
|
||||
editor.putBoolean("enablePtc", enablePtc?.value ?: true)
|
||||
editor.putBoolean("ignoreMissingServices", ignoreMissingServices?.value ?: false)
|
||||
editor.putBoolean("enableShaderCache", enableShaderCache?.value ?: true)
|
||||
editor.putBoolean("enableTextureRecompression", enableTextureRecompression?.value ?: false)
|
||||
editor.putFloat("resScale", resScale?.value ?: 1f)
|
||||
|
||||
editor.apply()
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package org.ryujinx.android.views
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.animateColor
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.MutableTransitionState
|
||||
import androidx.compose.animation.core.animateDp
|
||||
@ -15,13 +14,10 @@ import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.shrinkVertically
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
@ -32,9 +28,9 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Slider
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
@ -76,12 +72,24 @@ class SettingViews {
|
||||
var ignoreMissingServices = remember {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
var enableShaderCache = remember {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
var enableTextureRecompression = remember {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
var resScale = remember {
|
||||
mutableStateOf(1f)
|
||||
}
|
||||
|
||||
if (!loaded.value) {
|
||||
settingsViewModel.initializeState(
|
||||
isHostMapped,
|
||||
useNce,
|
||||
enableVsync, enableDocked, enablePtc, ignoreMissingServices
|
||||
enableVsync, enableDocked, enablePtc, ignoreMissingServices,
|
||||
enableShaderCache,
|
||||
enableTextureRecompression,
|
||||
resScale
|
||||
)
|
||||
loaded.value = true
|
||||
}
|
||||
@ -99,7 +107,10 @@ class SettingViews {
|
||||
enableVsync,
|
||||
enableDocked,
|
||||
enablePtc,
|
||||
ignoreMissingServices
|
||||
ignoreMissingServices,
|
||||
enableShaderCache,
|
||||
enableTextureRecompression,
|
||||
resScale
|
||||
)
|
||||
settingsViewModel.navController.popBackStack()
|
||||
}) {
|
||||
@ -111,7 +122,10 @@ class SettingViews {
|
||||
BackHandler {
|
||||
settingsViewModel.save(
|
||||
isHostMapped,
|
||||
useNce, enableVsync, enableDocked, enablePtc, ignoreMissingServices
|
||||
useNce, enableVsync, enableDocked, enablePtc, ignoreMissingServices,
|
||||
enableShaderCache,
|
||||
enableTextureRecompression,
|
||||
resScale
|
||||
)
|
||||
}
|
||||
ExpandableView(onCardArrowClick = { }, title = "System") {
|
||||
@ -208,6 +222,59 @@ class SettingViews {
|
||||
}
|
||||
}
|
||||
}
|
||||
ExpandableView(onCardArrowClick = { }, title = "Graphics") {
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(8.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = "Enable Shader Cache",
|
||||
modifier = Modifier.align(Alignment.CenterVertically)
|
||||
)
|
||||
Switch(checked = enableShaderCache.value, onCheckedChange = {
|
||||
enableShaderCache.value = !enableShaderCache.value
|
||||
})
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(8.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = "Resolution Scale",
|
||||
modifier = Modifier.align(Alignment.CenterVertically)
|
||||
)
|
||||
Text(text = resScale.value.toString() +"x")
|
||||
}
|
||||
Slider(value = resScale.value,
|
||||
valueRange = 0.5f..4f,
|
||||
steps = 6,
|
||||
onValueChange = { it ->
|
||||
resScale.value = it
|
||||
} )
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(8.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = "Enable Texture Recompression",
|
||||
modifier = Modifier.align(Alignment.CenterVertically)
|
||||
)
|
||||
Switch(checked = enableTextureRecompression.value, onCheckedChange = {
|
||||
enableTextureRecompression.value = !enableTextureRecompression.value
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -293,7 +360,9 @@ class SettingViews {
|
||||
Icon(
|
||||
Icons.Filled.KeyboardArrowUp,
|
||||
contentDescription = "Expandable Arrow",
|
||||
modifier = Modifier.padding(8.dp).rotate(degrees),
|
||||
modifier = Modifier
|
||||
.padding(8.dp)
|
||||
.rotate(degrees),
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user