feat(library): pick the game resolution for games started without Steam (#2520)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-12 22:39:06 -05:00
1 parent 1b732c1b65
commit bb05e20d1b
43 files changed
+332 -2

No files matched your search

@@ -79,6 +79,13 @@ object GameEnvironmentStore {
return config
}
@Synchronized
fun setGameResolution(context: Context, scope: String, choice: com.droiddeck.launcher.core.GameResolution.Choice?): GameEnvironment.Config {
val config = GameEnvironment.withGameResolution(read(context), scope, choice)
save(context, config)
return config
}
@Synchronized
fun setDefault(context: Context, scope: String, name: String, value: String): Boolean {
val config = read(context)
@@ -30,6 +30,25 @@ object NoSteamLaunch {
GameEnvironment.gameNoSteam(GameEnvironmentStore.read(context), (appId and 0xFFFFFFFFL).toString())
}.getOrDefault(false)
fun scopeOf(program: String?, args: List<String>, battleNetTitle: (String) -> String? = { null }): String? = when (program) {
EPIC -> EpicClient.shortcutAppId.toString()
BATTLENET -> args.getOrNull(args.indexOf("launch") + 1)?.takeIf { args.contains("launch") }?.let(battleNetTitle)
?: com.droiddeck.launcher.runtime.BattleNet.APP_ID.toString()
PROTON_RUN -> args.getOrNull(args.indexOf("--app") + 1)?.takeIf { args.contains("--app") }
else -> null
}?.takeIf { it.isNotEmpty() && GameEnvironment.validScope(it) }
fun battleNetTitleScope(context: Context, code: String): String? =
AddedGames.scan(context).firstOrNull { game ->
game.source == com.droiddeck.launcher.stores.Store.BATTLENET.id &&
game.storeId?.let(com.droiddeck.launcher.runtime.BattleNet::title)?.code == code
}?.let { settingsId(it).toString() }
fun resolution(config: GameEnvironment.Config, scope: String?, output: Pair<Int, Int>): Pair<Int, Int>? {
val choice = scope?.let { GameEnvironment.gameResolution(config, it) } ?: return null
return com.droiddeck.launcher.core.GameResolution.resolve(choice, output)
}
fun command(game: Library.SteamGame, added: AddedGames.Game?): Command? = when {
game.library == Library.EPIC_LAUNCHER -> Command(EPIC, listOf("run"), game.name)
game.library == Library.ADDED && game.source == com.droiddeck.launcher.stores.Store.BATTLENET.id ->
@@ -59,7 +59,7 @@ data class SelectedGameProfile(
)
}
val otherEnvironment = environment.games[game.profileKey].orEmpty().keys - FexPreset.environmentKeys -
GameEnvironment.NO_STEAM
GameEnvironment.NO_STEAM - GameEnvironment.GAME_RESOLUTION
return SelectedGameProfile(
appId = selectedAppId,
name = game.name,
@@ -588,6 +588,14 @@ class SessionService : Service() {
guest.add("BL_WIDTH=" + size.first)
guest.add("BL_HEIGHT=" + size.second)
if (noSteamGame()) runCatching {
val scope = NoSteamLaunch.scopeOf(SessionState.program, SessionState.programArgs) { NoSteamLaunch.battleNetTitleScope(this, it) }
NoSteamLaunch.resolution(GameEnvironmentStore.read(this), scope, size)
}.onFailure { Log.w(TAG, "game resolution", it) }.getOrNull()?.let { (w, h) ->
guest.add("BL_GAME_WIDTH=$w")
guest.add("BL_GAME_HEIGHT=$h")
Log.i(TAG, "game resolution: ${w}x$h on a ${size.first}x${size.second} output")
}
if (SessionState.followScreen || size.first < size.second ||
SessionPrefs.orientation(this) == android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER)
guest.add("BL_FOLLOW_OUTPUT=1")