Feat:Add per-game frame generation profiles (#2473)

This commit is contained in:
LunaDL authored and GitHub committed 2026-11-12 14:36:55 -05:00
1 parent b1b6ab7931
commit b52ce7e4c5
46 files changed
+598 -43

No files matched your search

@@ -13,6 +13,9 @@ internal fun FrameGenMenu(
host: MenuHost, mode: FrameGen.Mode, lossless: Lossless.State,
onPick: (FrameGen.Mode) -> Unit,
onImportLossless: () -> Unit,
gameProfileId: String? = null,
hasGameOverride: Boolean = false,
onResetGame: () -> Unit = {},
) {
val context = LocalContext.current
AnchoredMenu(host.open == "fg", onDismiss = { if (host.open == "fg") host.open = null }, title = stringResource(R.string.frame_gen_title)) { firstItemFocus ->
@@ -27,6 +30,12 @@ internal fun FrameGenMenu(
onPick(m); host.open = null
}
item(FrameGen.Mode.OFF, focus = firstItemFocus)
if (gameProfileId != null) {
MenuItem(stringResource(R.string.comp_game_use_general), checked = !hasGameOverride) {
onResetGame()
host.open = null
}
}
for (m in 2..4) item(FrameGen.Mode(FrameGen.ENGINE_DDFG, m))
val lsfg = (2..4).map { FrameGen.Mode(FrameGen.ENGINE_LSFG, it) } +
FrameGen.ADAPTIVE_TARGETS.map { FrameGen.Mode(FrameGen.ENGINE_LSFG, target = it) }
@@ -749,6 +749,17 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost
val context = androidx.compose.ui.platform.LocalContext.current
val inputMode = androidx.compose.ui.platform.LocalInputModeManager.current
val wincompKey = game?.takeIf { it.library == com.droiddeck.launcher.frontend.Library.ADDED || it.appId > 0 }?.profileKey
val frameGenProfileKey = game?.profileKey?.takeIf { it.isNotBlank() }
var gameFrameGenMode by remember(frameGenProfileKey) {
mutableStateOf(frameGenProfileKey?.let {
com.droiddeck.launcher.gpu.FrameGen.mode(context, it)
} ?: s.frameGen)
}
var gameFrameGenOverride by remember(frameGenProfileKey) {
mutableStateOf(frameGenProfileKey?.let {
com.droiddeck.launcher.gpu.FrameGen.hasGameOverride(context, it)
} ?: false)
}
var wincompOpen by remember(wincompKey) { mutableStateOf<Boolean?>(null) }
val wincompPicks = remember(wincompKey, wincompOpen) { wincompKey?.let { com.droiddeck.launcher.session.WinComponents.picks(context, it) }.orEmpty() }
val steamScope = game?.let { com.droiddeck.launcher.session.NoSteamLaunch.scope(it) }
@@ -767,10 +778,42 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost
}
add { m ->
Box(m) {
SettingCard(stringResource(R.string.frame_gen_title), s.frameGenLabel, "card:fg", Modifier.fillMaxSize()) {
SettingCard(
stringResource(R.string.frame_gen_title),
if (frameGenProfileKey != null)
com.droiddeck.launcher.gpu.FrameGen.label(context, gameFrameGenMode)
else s.frameGenLabel,
"card:fg", Modifier.fillMaxSize()
) {
host.open = if (host.open == "fg") null else "fg"
}
FrameGenMenu(s, a, host)
FrameGenMenu(
host = host,
mode = if (frameGenProfileKey != null) gameFrameGenMode else s.frameGen,
lossless = s.lossless,
onPick = { mode ->
val key = frameGenProfileKey
if (key == null) {
a.onFrameGenPick(mode)
} else {
com.droiddeck.launcher.gpu.FrameGen.setForGame(context, key, mode)
gameFrameGenMode = mode
gameFrameGenOverride = true
}
},
onImportLossless = a.onImportLossless,
gameProfileId = frameGenProfileKey,
hasGameOverride = gameFrameGenOverride,
onResetGame = {
val key = frameGenProfileKey
if (key != null) {
com.droiddeck.launcher.gpu.FrameGen.clearGame(context, key)
gameFrameGenMode =
com.droiddeck.launcher.gpu.FrameGen.mode(context)
gameFrameGenOverride = false
}
}
)
}
}
if (controller != null) add { m -> SettingCard(stringResource(R.string.setup_card_controls), stringResource(R.string.setup_card_controls_hint), "card:controls", m, controller.onMapping) }
@@ -220,6 +220,9 @@ class DrawerActions(
val hudOn: Boolean,
val hudConfig: Map<String, String> = emptyMap(),
val frameGen: FrameGen.Mode,
val frameGenTargetGameId: String? = null,
val frameGenTargetGameName: String? = null,
val hasGameOverride: Boolean = false,
val lossless: Lossless.State,
val oscMode: String,
val suspendPolicy: String,
@@ -262,6 +265,7 @@ class DrawerActions(
val onHudReset: () -> Unit = {},
val onHudExport: () -> Unit = {},
val onFrameGenPick: (FrameGen.Mode) -> Unit,
val onFrameGenReset: () -> Unit = {},
val fpsLimit: Int = 0,
val onFpsLimit: (Int) -> Unit = {},
val onImportLossless: () -> Unit,
@@ -569,10 +573,21 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
val fgOpen = host.open == "fg"
val offLabel = stringResource(R.string.frame_gen_off)
val fgLabel = FrameGen.label(LocalContext.current, a.frameGen)
SettingsRow(stringResource(R.string.frame_gen_title), null, highlighted = fgOpen) {
SettingsRow(
stringResource(R.string.frame_gen_title),
if (a.frameGenTargetGameId != null)
"${stringResource(R.string.frame_gen_scope_game)} · ${a.frameGenTargetGameName ?: "ID ${a.frameGenTargetGameId}"}"
else stringResource(R.string.frame_gen_scope_global),
highlighted = fgOpen
) {
Box {
ValueChip(fgLabel, fgOpen, modifier = focus.track(page, "fg")) { host.open = if (fgOpen) null else "fg" }
FrameGenMenu(host, a.frameGen, a.lossless, a.onFrameGenPick, a.onImportLossless)
FrameGenMenu(
host, a.frameGen, a.lossless, a.onFrameGenPick, a.onImportLossless,
gameProfileId = a.frameGenTargetGameId,
hasGameOverride = a.hasGameOverride,
onResetGame = a.onFrameGenReset,
)
}
}
if (a.direct) SliderRow(
@@ -1352,6 +1367,12 @@ private fun SelectedGameProfileGroup(host: MenuHost, a: DrawerActions, track: (S
if (!profile.fexPreset.inherited) {
ProfileSummaryRow(stringResource(R.string.comp_game_fex), fexProfileLabel(profile.fexPreset))
}
if (!profile.frameGenInherited) {
ProfileSummaryRow(
stringResource(R.string.frame_gen_title),
FrameGen.label(LocalContext.current, profile.frameGen),
)
}
if (!profile.proton.inherited) {
ProfileSummaryRow(stringResource(R.string.comp_proton), profileValueLabel(profile.proton))
}