mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
feat: Start without Steam, a per-game switch for games that close right away
A game that closes as soon as it starts can be tripped by Proton's Steam setup (steam.exe, the Steam registry entries, the Steam client bridge). The Games page of the session drawer gets a per-game Start without Steam switch, stored as DROIDDECK_NO_STEAM=1 in the game's environment and listed in its profile summary. droiddeck-game-env acts on it for a game launch only: a Proton with umu's launch (GE-Proton, Proton-CachyOS, DroidDeck-Proton) gets UMU_ID, so it runs umu.exe in place of steam.exe and still sets up the prefix; a Steam game keeps its protonfixes under its own id, an added game gets 0. Any other Proton runs the game straight in the prefix (runinprefix).
This commit is contained in:
1 parent
1ceb1b87b7
commit
0cfb994924
9 files changed
+144
-2
No files matched your search
@@ -259,6 +259,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
private val drawerGameInventory = GameProfileInventoryCache<Library.SteamGame>()
|
||||
private var drawerGameInventoryRevision = 0L
|
||||
private var drawerGameFexPresetSaving by mutableStateOf(false)
|
||||
private var drawerGameNoSteamSaving by mutableStateOf(false)
|
||||
private val drawerGameProfileFollowState = GameProfileFollowState()
|
||||
private data class DrawerGameProfileRefresh(
|
||||
val followsSteam: Boolean,
|
||||
@@ -727,6 +728,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
onSelectedGameProfileRefresh = ::refreshDrawerGameProfile,
|
||||
gameFexPresetSaving = drawerGameFexPresetSaving,
|
||||
onGameFexPreset = ::setDrawerGameFexPreset,
|
||||
gameNoSteamSaving = drawerGameNoSteamSaving,
|
||||
onGameNoSteam = ::setDrawerGameNoSteam,
|
||||
onComponentSwap = { pid, comp, value -> swapDrawerComponent(pid, comp, value) },
|
||||
onGameComponent = ::setDrawerGameComponent,
|
||||
))
|
||||
@@ -984,6 +987,26 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}, "drawer-game-fex-preset").start()
|
||||
}
|
||||
|
||||
private fun setDrawerGameNoSteam(appId: Long, on: Boolean) {
|
||||
if (drawerGameNoSteamSaving) return
|
||||
drawerGameNoSteamSaving = true
|
||||
val name = drawerGameProfileRefresh.data?.profiles?.firstOrNull { it.first == appId }?.second ?: appId.toString()
|
||||
Thread({
|
||||
val message = try {
|
||||
GameEnvironmentStore.setGameNoSteam(this, appId.toString(), on)
|
||||
getString(R.string.comp_game_saved_next, name)
|
||||
} catch (error: Exception) {
|
||||
Log.w(TAG, "Could not save Start without Steam for $appId", error)
|
||||
getString(R.string.session_profile_save_failed, error.message ?: error.javaClass.simpleName)
|
||||
}
|
||||
uiHandler.post {
|
||||
drawerGameNoSteamSaving = false
|
||||
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
|
||||
refreshDrawerGameProfile()
|
||||
}
|
||||
}, "drawer-game-no-steam").start()
|
||||
}
|
||||
|
||||
/** The session this screen is bringing up: the live one when re-attached, else the intent's. */
|
||||
private fun loadingMode(): String =
|
||||
if (SessionState.running) SessionState.mode
|
||||
|
||||
@@ -44,6 +44,20 @@ object GameEnvironment {
|
||||
|
||||
const val FORCE_SSBS = "DROIDDECK_FORCE_SSBS"
|
||||
|
||||
/**
|
||||
* A game's Start without Steam: droiddeck-game-env launches it without Proton's steam.exe (umu's
|
||||
* launch where the Proton has it, else runinprefix), for games that close right away.
|
||||
*/
|
||||
const val NO_STEAM = "DROIDDECK_NO_STEAM"
|
||||
|
||||
fun gameNoSteam(config: Config, scope: String): Boolean =
|
||||
scope.isNotEmpty() && config.games[scope]?.get(NO_STEAM)?.lowercase() in setOf("1", "on", "true", "yes")
|
||||
|
||||
fun withGameNoSteam(config: Config, scope: String, on: Boolean): Config {
|
||||
require(scope.isNotEmpty() && validScope(scope))
|
||||
return withScopeValue(config, scope, NO_STEAM, if (on) "1" else null)
|
||||
}
|
||||
|
||||
fun effective(config: Config, preset: String, scope: String, forceSsbs: Boolean = false): Map<String, String?> =
|
||||
defaults(preset, forceSsbs) + config.shared + if (scope.isEmpty()) emptyMap() else config.games[scope].orEmpty()
|
||||
|
||||
|
||||
@@ -65,6 +65,13 @@ object GameEnvironmentStore {
|
||||
return config
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun setGameNoSteam(context: Context, scope: String, on: Boolean): GameEnvironment.Config {
|
||||
val config = GameEnvironment.withGameNoSteam(read(context), scope, on)
|
||||
save(context, config)
|
||||
return config
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun publish(context: Context, config: GameEnvironment.Config = read(context)) {
|
||||
val resolved = config.copy(shared = GameEnvironment.defaults(SessionPrefs.fexPreset(context), SessionPrefs.forceSsbs(context)) + config.shared)
|
||||
|
||||
@@ -16,13 +16,16 @@ data class SelectedGameProfile(
|
||||
val componentFiles: Map<String, String>,
|
||||
val environmentOverrides: Int,
|
||||
val windowsComponentNames: List<String>,
|
||||
/** Start without Steam (GameEnvironment.NO_STEAM) is on for this game. */
|
||||
val startWithoutSteam: Boolean = false,
|
||||
) {
|
||||
val hasOverrides: Boolean
|
||||
get() = !fexPreset.inherited ||
|
||||
!proton.inherited ||
|
||||
components.values.any { !it.inherited } ||
|
||||
environmentOverrides > 0 ||
|
||||
windowsComponentNames.isNotEmpty()
|
||||
windowsComponentNames.isNotEmpty() ||
|
||||
startWithoutSteam
|
||||
|
||||
companion object {
|
||||
fun resolve(
|
||||
@@ -50,7 +53,9 @@ data class SelectedGameProfile(
|
||||
inherited = override == null,
|
||||
)
|
||||
}
|
||||
val otherEnvironment = environment.games[game.profileKey].orEmpty().keys - FexPreset.environmentKeys
|
||||
// Start without Steam is a switch of its own on the Games page, listed by name.
|
||||
val otherEnvironment = environment.games[game.profileKey].orEmpty().keys - FexPreset.environmentKeys -
|
||||
GameEnvironment.NO_STEAM
|
||||
return SelectedGameProfile(
|
||||
appId = selectedAppId,
|
||||
name = game.name,
|
||||
@@ -64,6 +69,7 @@ data class SelectedGameProfile(
|
||||
componentFiles = gameComponents,
|
||||
environmentOverrides = otherEnvironment.size,
|
||||
windowsComponentNames = gameWindowsComponents.map(WinComponentNames::of),
|
||||
startWithoutSteam = GameEnvironment.gameNoSteam(environment, game.profileKey),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,6 +273,9 @@ class DrawerActions(
|
||||
val onSelectedGameProfileRefresh: () -> Unit = {},
|
||||
val gameFexPresetSaving: Boolean = false,
|
||||
val onGameFexPreset: (Long, String?) -> Unit = { _, _ -> },
|
||||
/** Saves the selected game's Start without Steam (GameEnvironment.NO_STEAM). */
|
||||
val gameNoSteamSaving: Boolean = false,
|
||||
val onGameNoSteam: (Long, Boolean) -> Unit = { _, _ -> },
|
||||
/** Swaps [value] ("orig:<build>" or a stored package file) into a Proton's component. */
|
||||
val onComponentSwap: (protonId: String, comp: String, value: String) -> Unit = { _, _, _ -> },
|
||||
/** Saves a stored package for a game, or null to inherit that component from the Default profile. */
|
||||
@@ -515,6 +518,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
TextureFilteringGroup(host, a) { key -> focus.track(page, key) }
|
||||
if (a.steam) SettingsGroup(stringResource(R.string.game_settings_title)) {
|
||||
DrawerFexPresetRow(host, a, focus.track(page, "fex"))
|
||||
DrawerNoSteamRow(host, a, focus.track(page, "no-steam"))
|
||||
GameEnvironmentRow(
|
||||
modifier = focus.track(page, "game-env"),
|
||||
showHint = false,
|
||||
@@ -940,6 +944,17 @@ private fun DrawerFexPresetRow(host: MenuHost, a: DrawerActions, modifier: Modif
|
||||
}
|
||||
}
|
||||
|
||||
/** A game's Start without Steam; only with a game selected - the Default profile has no such switch. */
|
||||
@Composable
|
||||
private fun DrawerNoSteamRow(host: MenuHost, a: DrawerActions, modifier: Modifier) {
|
||||
val appId = a.selectedGameProfileId ?: return
|
||||
val profile = a.selectedGameProfile?.takeIf { it.appId == appId } ?: return
|
||||
ToggleRow(
|
||||
host, "no-steam", stringResource(R.string.game_no_steam_title), stringResource(R.string.game_no_steam_detail),
|
||||
profile.startWithoutSteam, enabled = !a.gameNoSteamSaving, chipModifier = modifier,
|
||||
) { on -> a.onGameNoSteam(appId, on) }
|
||||
}
|
||||
|
||||
/** Texture filtering on the Games page: DXVK options for the next DirectX 9-11 launch. */
|
||||
@Composable
|
||||
private fun TextureFilteringGroup(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
|
||||
@@ -1028,6 +1043,9 @@ private fun SelectedGameProfileGroup(host: MenuHost, a: DrawerActions, track: (S
|
||||
ProfileSummaryRow(ComponentsManager.LABEL.getValue(component), profileValueLabel(value))
|
||||
}
|
||||
}
|
||||
if (profile.startWithoutSteam) {
|
||||
ProfileSummaryRow(stringResource(R.string.game_no_steam_title), stringResource(R.string.game_no_steam_on))
|
||||
}
|
||||
if (profile.environmentOverrides > 0) {
|
||||
ProfileSummaryRow(
|
||||
stringResource(R.string.game_env_title),
|
||||
|
||||
Reference in new issue
Block a user