Skip to content

Commit

Permalink
Add CUT3 and allow changing HD mode quality via settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Swordfish90 committed Jul 29, 2024
1 parent 51081c9 commit 6efc13a
Show file tree
Hide file tree
Showing 16 changed files with 276 additions and 263 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object deps {
const val serialization = "1.2.2"
const val fragment = "1.5.1"
const val activity = "1.7.2"
const val libretrodroid = "0.11.1"
const val libretrodroid = "c36b44fbd7"
const val radialgamepad = "2.0.0"
const val composeBom = "2024.02.02"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.content.SharedPreferences
import com.fredporciuncula.flow.preferences.FlowSharedPreferences
import com.swordfish.lemuroid.R
import com.swordfish.lemuroid.app.shared.settings.HDModeQuality
import com.swordfish.lemuroid.common.math.Fraction
import com.swordfish.lemuroid.lib.storage.cache.CacheCleaner
import dagger.Lazy
Expand Down Expand Up @@ -31,7 +32,7 @@ class SettingsManager(private val context: Context, sharedPreferences: Lazy<Shar

suspend fun hdMode() = booleanPreference(R.string.pref_key_hd_mode, false)

suspend fun forceLegacyHdMode() = booleanPreference(R.string.pref_key_legacy_hd_mode, false)
suspend fun hdModeQuality() = HDModeQuality.parse(intPreference(R.string.pref_key_hd_mode_quality, 1))

suspend fun tiltSensitivity() = floatPreference(R.string.pref_key_tilt_sensitivity_index, 10, 6)

Expand Down Expand Up @@ -94,4 +95,14 @@ class SettingsManager(private val context: Context, sharedPreferences: Lazy<Shar
.map { Fraction(it, denominator).floatValue }
.first()
}

private suspend fun intPreference(
keyId: Int,
default: Int,
): Int =
withContext(Dispatchers.IO) {
sharedPreferences.getInt(getString(keyId), default)
.asFlow()
.first()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import com.alorma.compose.settings.storage.disk.rememberPreferenceIntSettingState
import com.swordfish.lemuroid.R
import com.swordfish.lemuroid.app.mobile.feature.main.MainRoute
import com.swordfish.lemuroid.app.utils.android.settings.LemuroidCardSettingsGroup
Expand All @@ -24,6 +23,7 @@ import com.swordfish.lemuroid.app.utils.android.settings.LemuroidSettingsSlider
import com.swordfish.lemuroid.app.utils.android.settings.LemuroidSettingsSwitch
import com.swordfish.lemuroid.app.utils.android.settings.booleanPreferenceState
import com.swordfish.lemuroid.app.utils.android.settings.indexPreferenceState
import com.swordfish.lemuroid.app.utils.android.settings.intPreferenceState

@Composable
fun AdvancedSettingsScreen(
Expand Down Expand Up @@ -67,12 +67,13 @@ private fun InputSettings() {
)
LemuroidSettingsSlider(
state =
rememberPreferenceIntSettingState(
intPreferenceState(
key = stringResource(id = R.string.pref_key_tilt_sensitivity_index),
defaultValue = 6,
default = 6,
),
steps = 10,
valueRange = 0f..10f,
enabled = true,
title = { Text(text = stringResource(R.string.settings_title_tilt_sensitivity)) },
)
}
Expand Down Expand Up @@ -109,11 +110,6 @@ private fun GeneralSettings(
title = { Text(text = stringResource(id = R.string.settings_title_direct_game_load)) },
subtitle = { Text(text = stringResource(id = R.string.settings_description_direct_game_load)) },
)
LemuroidSettingsSwitch(
state = booleanPreferenceState(R.string.pref_key_legacy_hd_mode, false),
title = { Text(text = stringResource(id = R.string.settings_title_legacy_hd_mode)) },
subtitle = { Text(text = stringResource(id = R.string.settings_description_legacy_hd_mode)) },
)
LemuroidSettingsMenuLink(
title = { Text(text = stringResource(id = R.string.settings_title_reset_settings)) },
subtitle = { Text(text = stringResource(id = R.string.settings_description_reset_settings)) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import com.swordfish.lemuroid.app.utils.android.settings.LemuroidCardSettingsGro
import com.swordfish.lemuroid.app.utils.android.settings.LemuroidSettingsList
import com.swordfish.lemuroid.app.utils.android.settings.LemuroidSettingsMenuLink
import com.swordfish.lemuroid.app.utils.android.settings.LemuroidSettingsPage
import com.swordfish.lemuroid.app.utils.android.settings.LemuroidSettingsSlider
import com.swordfish.lemuroid.app.utils.android.settings.LemuroidSettingsSwitch
import com.swordfish.lemuroid.app.utils.android.settings.booleanPreferenceState
import com.swordfish.lemuroid.app.utils.android.settings.indexPreferenceState
import com.swordfish.lemuroid.app.utils.android.settings.intPreferenceState
import com.swordfish.lemuroid.app.utils.android.stringListResource

@Composable
Expand Down Expand Up @@ -141,12 +143,25 @@ private fun GeneralSettings() {
LemuroidSettingsSwitch(
state = booleanPreferenceState(R.string.pref_key_autosave, true),
title = { Text(text = stringResource(id = R.string.settings_title_enable_autosave)) },
subtitle = { Text(text = stringResource(id = R.string.settings_description_enable_autosave)) },
)
LemuroidSettingsSwitch(
state = hdMode,
title = { Text(text = stringResource(id = R.string.settings_title_hd_mode)) },
subtitle = { Text(text = stringResource(id = R.string.settings_description_hd_mode)) },
)
LemuroidSettingsSlider(
enabled = hdMode.value,
state =
intPreferenceState(
key = stringResource(id = R.string.pref_key_hd_mode_quality),
default = 1,
),
steps = 1,
valueRange = 0f..2f,
title = { Text(text = stringResource(R.string.settings_title_hd_quality)) },
subtitle = { Text(text = stringResource(id = R.string.settings_description_hd_quality)) }
)
LemuroidSettingsList(
enabled = !hdMode.value,
state =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.swordfish.lemuroid.app.shared.input.InputKey
import com.swordfish.lemuroid.app.shared.input.inputclass.getInputClass
import com.swordfish.lemuroid.app.shared.rumble.RumbleManager
import com.swordfish.lemuroid.app.shared.settings.ControllerConfigsManager
import com.swordfish.lemuroid.app.shared.settings.HDModeQuality
import com.swordfish.lemuroid.app.tv.game.TVGameActivity
import com.swordfish.lemuroid.common.animationDuration
import com.swordfish.lemuroid.common.coroutines.MutableStateProperty
Expand Down Expand Up @@ -331,7 +332,7 @@ abstract class BaseGameActivity : ImmersiveActivity() {
private fun initializeRetroGameView(
gameData: GameLoader.GameData,
hdMode: Boolean,
forceLegacyHdMode: Boolean,
hdModeQuality: HDModeQuality,
screenFilter: String,
lowLatencyAudio: Boolean,
enableRumble: Boolean,
Expand Down Expand Up @@ -359,7 +360,7 @@ abstract class BaseGameActivity : ImmersiveActivity() {
ShaderChooser.getShaderForSystem(
applicationContext,
hdMode,
forceLegacyHdMode,
hdModeQuality,
screenFilter,
system,
)
Expand Down Expand Up @@ -1019,7 +1020,7 @@ abstract class BaseGameActivity : ImmersiveActivity() {
val autoSaveEnabled = settingsManager.autoSave()
val filter = settingsManager.screenFilter()
val hdMode = settingsManager.hdMode()
val forceLegacyHdMode = settingsManager.forceLegacyHdMode()
val hdModeQuality = settingsManager.hdModeQuality()
val lowLatencyAudio = settingsManager.lowLatencyAudio()
val enableRumble = settingsManager.enableRumble()
val directLoad = settingsManager.allowDirectGameLoad()
Expand All @@ -1045,7 +1046,7 @@ abstract class BaseGameActivity : ImmersiveActivity() {
initializeRetroGameView(
loadingState.gameData,
hdMode,
forceLegacyHdMode,
hdModeQuality,
filter,
lowLatencyAudio,
systemCoreConfig.rumbleSupported && enableRumble,
Expand Down
Loading

0 comments on commit 6efc13a

Please sign in to comment.