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

@@ -49,6 +49,16 @@ object GameEnvironment {
return withScopeValue(config, scope, NO_STEAM, if (on) "1" else null)
}
const val GAME_RESOLUTION = "DROIDDECK_GAME_RESOLUTION"
fun gameResolution(config: Config, scope: String): GameResolution.Choice? =
if (scope.isEmpty()) null else GameResolution.parse(config.games[scope]?.get(GAME_RESOLUTION))
fun withGameResolution(config: Config, scope: String, choice: GameResolution.Choice?): Config {
require(scope.isNotEmpty() && validScope(scope))
return withScopeValue(config, scope, GAME_RESOLUTION, choice?.let(GameResolution::format))
}
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()
@@ -0,0 +1,70 @@
package com.droiddeck.launcher.core
object GameResolution {
sealed interface Choice
data class Fixed(val width: Int, val height: Int) : Choice
data class Scaled(val scale: Float) : Choice
data class Aspect(val label: String, val sizes: List<Fixed>)
val aspects = listOf(
Aspect("16:9", listOf(Fixed(960, 540), Fixed(1280, 720), Fixed(1600, 900), Fixed(1920, 1080), Fixed(2560, 1440))),
Aspect("16:10", listOf(Fixed(1280, 800), Fixed(1440, 900), Fixed(1680, 1050), Fixed(1920, 1200), Fixed(2560, 1600))),
Aspect("4:3", listOf(Fixed(640, 480), Fixed(800, 600), Fixed(1024, 768), Fixed(1280, 960), Fixed(1440, 1080))),
)
val scales = listOf(1.5f, 2f, 3f)
const val MIN_WIDTH = 320
const val MIN_HEIGHT = 240
const val MAX_SIDE = 7680
private const val SCALED_PREFIX = "/"
fun parse(value: String?): Choice? {
val text = value?.trim().orEmpty()
if (text.startsWith(SCALED_PREFIX)) {
return text.removePrefix(SCALED_PREFIX).toFloatOrNull()?.takeIf { it > 1f && it <= 8f }?.let(::Scaled)
}
val parts = text.split('x', 'X', '×').map { it.trim().toIntOrNull() }
if (parts.size != 2) return null
val (w, h) = parts
return if (w != null && h != null && valid(w, h)) Fixed(w and 1.inv(), h and 1.inv()) else null
}
fun valid(width: Int, height: Int) = width in MIN_WIDTH..MAX_SIDE && height in MIN_HEIGHT..MAX_SIDE
fun format(choice: Choice): String = when (choice) {
is Fixed -> "${choice.width}x${choice.height}"
is Scaled -> SCALED_PREFIX + formatScale(choice.scale)
}
fun formatScale(scale: Float): String =
(Math.round(scale * 10) / 10f).let { if (it % 1f == 0f) it.toInt().toString() else it.toString() }
fun resolve(choice: Choice, output: Pair<Int, Int>): Pair<Int, Int> = when (choice) {
is Fixed -> choice.width to choice.height
is Scaled -> (Math.round(output.first / choice.scale).coerceAtLeast(MIN_WIDTH) and 1.inv()) to
(Math.round(output.second / choice.scale).coerceAtLeast(MIN_HEIGHT) and 1.inv())
}
fun aspectLabel(width: Int, height: Int): String {
if (width <= 0 || height <= 0) return ""
val ratio = width.toFloat() / height
aspects.firstOrNull { a ->
val (w, h) = a.label.split(':').map(String::toFloat)
kotlin.math.abs(ratio - w / h) < 0.02f
}?.let { return it.label }
if (kotlin.math.abs(ratio - 64f / 27f) < 0.04f || kotlin.math.abs(ratio - 21f / 9f) < 0.04f) return "21:9"
val g = gcd(width, height)
return if (width / g <= 32) "${width / g}:${height / g}" else String.format(java.util.Locale.ROOT, "%.2f:1", ratio)
}
fun sizesFor(aspect: Aspect, panel: Pair<Int, Int>): List<Fixed> {
val long = maxOf(panel.first, panel.second)
val short = minOf(panel.first, panel.second)
val fit = aspect.sizes.filter { it.width <= long && it.height <= short }
return fit.ifEmpty { aspect.sizes.take(1) }
}
private tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
}
@@ -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")
@@ -918,12 +918,37 @@ internal fun GameSettingsMenus(host: MenuHost, game: com.droiddeck.launcher.fron
val custom = stringResource(R.string.comp_game_fex_custom)
val customSync = stringResource(R.string.game_sync_custom)
val resetDone = stringResource(R.string.comp_game_reset_done, game.name)
val resKey = "game-settings-res"
val resolution = current?.let { com.droiddeck.launcher.core.GameEnvironment.gameResolution(it, scope) }
val screen = remember { com.droiddeck.launcher.session.SessionDisplay.screenSize(com.droiddeck.launcher.session.SessionDisplay.panelSize(appContext)) }
val matchScreen = stringResource(R.string.display_match_screen, screen.first, screen.second)
val scaledLabels = com.droiddeck.launcher.core.GameResolution.scales.associateWith {
stringResource(R.string.display_follow_screen_scaled, com.droiddeck.launcher.core.GameResolution.formatScale(it))
}
fun sizeLabel(size: Pair<Int, Int>) = "${size.first}×${size.second} · ${com.droiddeck.launcher.core.GameResolution.aspectLabel(size.first, size.second)}"
fun resolutionLabel(choice: com.droiddeck.launcher.core.GameResolution.Choice?): String = when (choice) {
null -> matchScreen
is com.droiddeck.launcher.core.GameResolution.Scaled -> (scaledLabels[choice.scale]
?: "÷" + com.droiddeck.launcher.core.GameResolution.formatScale(choice.scale)) +
" · " + sizeLabel(com.droiddeck.launcher.core.GameResolution.resolve(choice, screen))
is com.droiddeck.launcher.core.GameResolution.Fixed -> sizeLabel(choice.width to choice.height)
}
fun pickResolution(choice: com.droiddeck.launcher.core.GameResolution.Choice?) {
host.open = key
save { com.droiddeck.launcher.session.GameEnvironmentStore.setGameResolution(it, scope, choice) }
}
var editResolution by remember(scope) { mutableStateOf(false) }
AnchoredMenu(host.open == key, onDismiss = { if (host.open == key) host.open = null }, title = stringResource(R.string.game_settings_menu_title, game.name)) { first ->
MenuItem(stringResource(R.string.game_no_steam_title), checked = noSteam, enabled = ready,
detail = stringResource(R.string.game_no_steam_detail), focusRequester = first) {
val on = !noSteam
save { com.droiddeck.launcher.session.GameEnvironmentStore.setGameNoSteam(it, scope, on) }
}
if (noSteam) MenuItem(
stringResource(R.string.game_res_title), checked = false, enabled = ready,
detail = resolutionLabel(resolution),
trailing = { Text("›", fontSize = 16.sp, color = colors.onSurfaceVariant) },
) { host.open = resKey }
if (!launcher) {
val chosen = com.droiddeck.launcher.core.FexPreset.all.firstOrNull { it.id == fex }
MenuItem(
@@ -960,6 +985,45 @@ internal fun GameSettingsMenus(host: MenuHost, game: com.droiddeck.launcher.fron
}
}
}
AnchoredMenu(host.open == resKey, onDismiss = { if (host.open == resKey) host.open = null }, title = stringResource(R.string.game_res_title)) { first ->
MenuItem(matchScreen, checked = resolution == null, enabled = ready, focusRequester = first) { pickResolution(null) }
com.droiddeck.launcher.core.GameResolution.scales.forEach { scale ->
val choice = com.droiddeck.launcher.core.GameResolution.Scaled(scale)
MenuItem(scaledLabels.getValue(scale), checked = resolution == choice, enabled = ready,
detail = sizeLabel(com.droiddeck.launcher.core.GameResolution.resolve(choice, screen))) { pickResolution(choice) }
}
com.droiddeck.launcher.core.GameResolution.aspects.forEach { aspect ->
val sizes = com.droiddeck.launcher.core.GameResolution.sizesFor(aspect, screen)
MenuItem(aspect.label, checked = resolution in aspect.sizes, enabled = ready,
detail = sizes.joinToString(" · ") { "${it.width}×${it.height}" },
trailing = { Text("›", fontSize = 16.sp, color = colors.onSurfaceVariant) },
) { host.open = "$resKey-${aspect.label}" }
}
val fixed = resolution as? com.droiddeck.launcher.core.GameResolution.Fixed
val customValue = fixed?.takeIf { f -> com.droiddeck.launcher.core.GameResolution.aspects.none { f in it.sizes } }
MenuItem(
if (customValue == null) stringResource(R.string.mode_res_custom) else stringResource(R.string.mode_res_custom_value, customValue.width, customValue.height),
checked = customValue != null, enabled = ready,
detail = customValue?.let { com.droiddeck.launcher.core.GameResolution.aspectLabel(it.width, it.height) },
) { editResolution = true }
}
com.droiddeck.launcher.core.GameResolution.aspects.forEach { aspect ->
val aspectKey = "$resKey-${aspect.label}"
AnchoredMenu(host.open == aspectKey, onDismiss = { if (host.open == aspectKey) host.open = null }, title = aspect.label) { first ->
com.droiddeck.launcher.core.GameResolution.sizesFor(aspect, screen).forEachIndexed { index, size ->
MenuItem("${size.width}×${size.height}", checked = resolution == size, enabled = ready,
focusRequester = if (index == 0) first else null) { pickResolution(size) }
}
}
}
if (editResolution) CustomResolutionDialog(
(resolution as? com.droiddeck.launcher.core.GameResolution.Fixed)?.let { it.width to it.height },
onSave = { value ->
editResolution = false
pickResolution(com.droiddeck.launcher.core.GameResolution.Fixed(value.first, value.second))
},
onDismiss = { editResolution = false },
)
AnchoredMenu(host.open == fexKey, onDismiss = { if (host.open == fexKey) host.open = null }, title = stringResource(R.string.fex_preset_title)) { first ->
MenuItem(useDefault, checked = fex == null, enabled = ready, detail = stringResource(generalFex.label), focusRequester = first) {
host.open = key
+1
View File
@@ -488,6 +488,7 @@
<string name="game_no_steam_on">تشغيل</string>
<string name="game_steam_with">يبدأ مع Steam</string>
<string name="game_steam_without">يبدأ بدون Steam</string>
<string name="game_res_title">دقة اللعبة</string>
<string name="game_settings_card">الإعدادات</string>
<string name="game_settings_menu_title">إعدادات %1$s</string>
<string name="game_settings_default">الافتراضي</string>
@@ -482,6 +482,7 @@
<string name="game_no_steam_on">Activado</string>
<string name="game_steam_with">Se inicia con Steam</string>
<string name="game_steam_without">Se inicia sin Steam</string>
<string name="game_res_title">Resolución del juego</string>
<string name="game_settings_card">Ajustes</string>
<string name="game_settings_menu_title">Ajustes de %1$s</string>
<string name="game_settings_default">Predeterminado</string>
+1
View File
@@ -480,6 +480,7 @@
<string name="game_no_steam_on">Включено</string>
<string name="game_steam_with">Стартира със Steam</string>
<string name="game_steam_without">Стартира без Steam</string>
<string name="game_res_title">Резолюция на играта</string>
<string name="game_settings_card">Настройки</string>
<string name="game_settings_menu_title">Настройки на %1$s</string>
<string name="game_settings_default">По подразбиране</string>
+1
View File
@@ -484,6 +484,7 @@
<string name="game_no_steam_on">Zapnuto</string>
<string name="game_steam_with">Spouští se se Steamem</string>
<string name="game_steam_without">Spouští se bez Steamu</string>
<string name="game_res_title">Rozlišení hry</string>
<string name="game_settings_card">Nastavení</string>
<string name="game_settings_menu_title">Nastavení %1$s</string>
<string name="game_settings_default">Výchozí</string>
+1
View File
@@ -480,6 +480,7 @@
<string name="game_no_steam_on">Til</string>
<string name="game_steam_with">Starter med Steam</string>
<string name="game_steam_without">Starter uden Steam</string>
<string name="game_res_title">Spilopløsning</string>
<string name="game_settings_card">Indstillinger</string>
<string name="game_settings_menu_title">Indstillinger for %1$s</string>
<string name="game_settings_default">Standard</string>
+1
View File
@@ -480,6 +480,7 @@
<string name="game_no_steam_on">An</string>
<string name="game_steam_with">Startet mit Steam</string>
<string name="game_steam_without">Startet ohne Steam</string>
<string name="game_res_title">Spielauflösung</string>
<string name="game_settings_card">Einstellungen</string>
<string name="game_settings_menu_title">Einstellungen für %1$s</string>
<string name="game_settings_default">Standard</string>
+1
View File
@@ -480,6 +480,7 @@
<string name="game_no_steam_on">Ενεργό</string>
<string name="game_steam_with">Ξεκινά με το Steam</string>
<string name="game_steam_without">Ξεκινά χωρίς το Steam</string>
<string name="game_res_title">Ανάλυση παιχνιδιού</string>
<string name="game_settings_card">Ρυθμίσεις</string>
<string name="game_settings_menu_title">Ρυθμίσεις %1$s</string>
<string name="game_settings_default">Προεπιλογή</string>
+1
View File
@@ -482,6 +482,7 @@
<string name="game_no_steam_on">Activado</string>
<string name="game_steam_with">Se inicia con Steam</string>
<string name="game_steam_without">Se inicia sin Steam</string>
<string name="game_res_title">Resolución del juego</string>
<string name="game_settings_card">Ajustes</string>
<string name="game_settings_menu_title">Ajustes de %1$s</string>
<string name="game_settings_default">Predeterminado</string>
+1
View File
@@ -480,6 +480,7 @@
<string name="game_no_steam_on">Päällä</string>
<string name="game_steam_with">Käynnistyy Steamin kanssa</string>
<string name="game_steam_without">Käynnistyy ilman Steamia</string>
<string name="game_res_title">Pelin resoluutio</string>
<string name="game_settings_card">Asetukset</string>
<string name="game_settings_menu_title">%1$s – asetukset</string>
<string name="game_settings_default">Oletus</string>
+1
View File
@@ -482,6 +482,7 @@
<string name="game_no_steam_on">Activé</string>
<string name="game_steam_with">Démarre avec Steam</string>
<string name="game_steam_without">Démarre sans Steam</string>
<string name="game_res_title">Résolution du jeu</string>
<string name="game_settings_card">Paramètres</string>
<string name="game_settings_menu_title">Paramètres de %1$s</string>
<string name="game_settings_default">Par défaut</string>
+1
View File
@@ -480,6 +480,7 @@
<string name="game_no_steam_on">चालू</string>
<string name="game_steam_with">Steam के साथ शुरू होता है</string>
<string name="game_steam_without">Steam के बिना शुरू होता है</string>
<string name="game_res_title">गेम रिज़ॉल्यूशन</string>
<string name="game_settings_card">सेटिंग</string>
<string name="game_settings_menu_title">%1$s सेटिंग</string>
<string name="game_settings_default">डिफ़ॉल्ट</string>
+1
View File
@@ -480,6 +480,7 @@
<string name="game_no_steam_on">Be</string>
<string name="game_steam_with">Steammel indul</string>
<string name="game_steam_without">Steam nélkül indul</string>
<string name="game_res_title">Játék felbontása</string>
<string name="game_settings_card">Beállítások</string>
<string name="game_settings_menu_title">%1$s beállításai</string>
<string name="game_settings_default">Alapértelmezett</string>
+1
View File
@@ -478,6 +478,7 @@
<string name="game_no_steam_on">Aktif</string>
<string name="game_steam_with">Dimulai dengan Steam</string>
<string name="game_steam_without">Dimulai tanpa Steam</string>
<string name="game_res_title">Resolusi game</string>
<string name="game_settings_card">Setelan</string>
<string name="game_settings_menu_title">Setelan %1$s</string>
<string name="game_settings_default">Default</string>
+1
View File
@@ -482,6 +482,7 @@
<string name="game_no_steam_on">Attivo</string>
<string name="game_steam_with">Si avvia con Steam</string>
<string name="game_steam_without">Si avvia senza Steam</string>
<string name="game_res_title">Risoluzione del gioco</string>
<string name="game_settings_card">Impostazioni</string>
<string name="game_settings_menu_title">Impostazioni di %1$s</string>
<string name="game_settings_default">Predefinito</string>
+1
View File
@@ -478,6 +478,7 @@
<string name="game_no_steam_on">オン</string>
<string name="game_steam_with">Steam と一緒に起動</string>
<string name="game_steam_without">Steam なしで起動</string>
<string name="game_res_title">ゲームの解像度</string>
<string name="game_settings_card">設定</string>
<string name="game_settings_menu_title">%1$s の設定</string>
<string name="game_settings_default">デフォルト</string>
+1
View File
@@ -478,6 +478,7 @@
<string name="game_no_steam_on">켜짐</string>
<string name="game_steam_with">Steam과 함께 시작</string>
<string name="game_steam_without">Steam 없이 시작</string>
<string name="game_res_title">게임 해상도</string>
<string name="game_settings_card">설정</string>
<string name="game_settings_menu_title">%1$s 설정</string>
<string name="game_settings_default">기본값</string>
+1
View File
@@ -478,6 +478,7 @@
<string name="game_no_steam_on">Hidup</string>
<string name="game_steam_with">Bermula dengan Steam</string>
<string name="game_steam_without">Bermula tanpa Steam</string>
<string name="game_res_title">Resolusi permainan</string>
<string name="game_settings_card">Tetapan</string>
<string name="game_settings_menu_title">Tetapan %1$s</string>
<string name="game_settings_default">Lalai</string>
+1
View File
@@ -480,6 +480,7 @@
<string name="game_no_steam_on">På</string>
<string name="game_steam_with">Starter med Steam</string>
<string name="game_steam_without">Starter uten Steam</string>
<string name="game_res_title">Spilloppløsning</string>
<string name="game_settings_card">Innstillinger</string>
<string name="game_settings_menu_title">Innstillinger for %1$s</string>
<string name="game_settings_default">Standard</string>
+1
View File
@@ -480,6 +480,7 @@
<string name="game_no_steam_on">Aan</string>
<string name="game_steam_with">Start met Steam</string>
<string name="game_steam_without">Start zonder Steam</string>
<string name="game_res_title">Spelresolutie</string>
<string name="game_settings_card">Instellingen</string>
<string name="game_settings_menu_title">Instellingen voor %1$s</string>
<string name="game_settings_default">Standaard</string>
+1
View File
@@ -484,6 +484,7 @@
<string name="game_no_steam_on">Wł.</string>
<string name="game_steam_with">Uruchamia się ze Steam</string>
<string name="game_steam_without">Uruchamia się bez Steam</string>
<string name="game_res_title">Rozdzielczość gry</string>
<string name="game_settings_card">Ustawienia</string>
<string name="game_settings_menu_title">Ustawienia: %1$s</string>
<string name="game_settings_default">Domyślne</string>
@@ -482,6 +482,7 @@
<string name="game_no_steam_on">Ativado</string>
<string name="game_steam_with">Inicia com o Steam</string>
<string name="game_steam_without">Inicia sem o Steam</string>
<string name="game_res_title">Resolução do jogo</string>
<string name="game_settings_card">Definições</string>
<string name="game_settings_menu_title">Definições de %1$s</string>
<string name="game_settings_default">Predefinição</string>
+1
View File
@@ -482,6 +482,7 @@
<string name="game_no_steam_on">Ativado</string>
<string name="game_steam_with">Inicia com o Steam</string>
<string name="game_steam_without">Inicia sem o Steam</string>
<string name="game_res_title">Resolução do jogo</string>
<string name="game_settings_card">Configurações</string>
<string name="game_settings_menu_title">Configurações de %1$s</string>
<string name="game_settings_default">Padrão</string>
+1
View File
@@ -482,6 +482,7 @@
<string name="game_no_steam_on">Activat</string>
<string name="game_steam_with">Pornește cu Steam</string>
<string name="game_steam_without">Pornește fără Steam</string>
<string name="game_res_title">Rezoluția jocului</string>
<string name="game_settings_card">Setări</string>
<string name="game_settings_menu_title">Setări %1$s</string>
<string name="game_settings_default">Implicit</string>
+1
View File
@@ -503,6 +503,7 @@
<string name="game_no_steam_on">Включено</string>
<string name="game_steam_with">Запускается со Steam</string>
<string name="game_steam_without">Запускается без Steam</string>
<string name="game_res_title">Разрешение игры</string>
<string name="game_settings_card">Настройки</string>
<string name="game_settings_menu_title">Настройки %1$s</string>
<string name="game_settings_default">По умолчанию</string>
+1
View File
@@ -480,6 +480,7 @@
<string name="game_no_steam_on">På</string>
<string name="game_steam_with">Startar med Steam</string>
<string name="game_steam_without">Startar utan Steam</string>
<string name="game_res_title">Spelupplösning</string>
<string name="game_settings_card">Inställningar</string>
<string name="game_settings_menu_title">Inställningar för %1$s</string>
<string name="game_settings_default">Standard</string>
+1
View File
@@ -478,6 +478,7 @@
<string name="game_no_steam_on">เปิด</string>
<string name="game_steam_with">เริ่มพร้อม Steam</string>
<string name="game_steam_without">เริ่มโดยไม่ใช้ Steam</string>
<string name="game_res_title">ความละเอียดของเกม</string>
<string name="game_settings_card">การตั้งค่า</string>
<string name="game_settings_menu_title">การตั้งค่า %1$s</string>
<string name="game_settings_default">ค่าเริ่มต้น</string>
+1
View File
@@ -480,6 +480,7 @@
<string name="game_no_steam_on">Açık</string>
<string name="game_steam_with">Steam ile başlar</string>
<string name="game_steam_without">Steam olmadan başlar</string>
<string name="game_res_title">Oyun çözünürlüğü</string>
<string name="game_settings_card">Ayarlar</string>
<string name="game_settings_menu_title">%1$s Ayarları</string>
<string name="game_settings_default">Varsayılan</string>
+1
View File
@@ -484,6 +484,7 @@
<string name="game_no_steam_on">Увімкнено</string>
<string name="game_steam_with">Запускається зі Steam</string>
<string name="game_steam_without">Запускається без Steam</string>
<string name="game_res_title">Роздільна здатність гри</string>
<string name="game_settings_card">Налаштування</string>
<string name="game_settings_menu_title">Налаштування %1$s</string>
<string name="game_settings_default">За замовчуванням</string>
+1
View File
@@ -478,6 +478,7 @@
<string name="game_no_steam_on">Bật</string>
<string name="game_steam_with">Khởi động cùng Steam</string>
<string name="game_steam_without">Khởi động không cần Steam</string>
<string name="game_res_title">Độ phân giải trò chơi</string>
<string name="game_settings_card">Thiết lập</string>
<string name="game_settings_menu_title">Thiết lập %1$s</string>
<string name="game_settings_default">Mặc định</string>
@@ -478,6 +478,7 @@
<string name="game_no_steam_on">开</string>
<string name="game_steam_with">随 Steam 启动</string>
<string name="game_steam_without">不通过 Steam 启动</string>
<string name="game_res_title">游戏分辨率</string>
<string name="game_settings_card">设置</string>
<string name="game_settings_menu_title">%1$s 设置</string>
<string name="game_settings_default">默认</string>
@@ -478,6 +478,7 @@
<string name="game_no_steam_on">開</string>
<string name="game_steam_with">隨 Steam 啟動</string>
<string name="game_steam_without">不經 Steam 啟動</string>
<string name="game_res_title">遊戲解像度</string>
<string name="game_settings_card">設定</string>
<string name="game_settings_menu_title">%1$s 設定</string>
<string name="game_settings_default">預設</string>
@@ -478,6 +478,7 @@
<string name="game_no_steam_on">開</string>
<string name="game_steam_with">隨 Steam 啟動</string>
<string name="game_steam_without">不經 Steam 啟動</string>
<string name="game_res_title">遊戲解析度</string>
<string name="game_settings_card">設定</string>
<string name="game_settings_menu_title">%1$s 設定</string>
<string name="game_settings_default">預設</string>
+1
View File
@@ -528,6 +528,7 @@
<string name="game_no_steam_on">On</string>
<string name="game_steam_with">Starts with Steam</string>
<string name="game_steam_without">Starts without Steam</string>
<string name="game_res_title">Game resolution</string>
<string name="game_settings_card">Settings</string>
<string name="game_settings_menu_title">%1$s Settings</string>
<string name="game_settings_default">Default</string>
@@ -0,0 +1,60 @@
package com.droiddeck.launcher.core
import com.droiddeck.launcher.session.NoSteamLaunch
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
class GameResolutionTest {
@Test
fun choicesRoundTripThroughTheStoredValue() {
for (choice in listOf(GameResolution.Fixed(1280, 720), GameResolution.Scaled(1.5f), GameResolution.Scaled(2f))) {
assertEquals(choice, GameResolution.parse(GameResolution.format(choice)))
}
assertEquals("1280x720", GameResolution.format(GameResolution.Fixed(1280, 720)))
assertEquals("/1.5", GameResolution.format(GameResolution.Scaled(1.5f)))
}
@Test
fun invalidValuesAreIgnored() {
for (value in listOf(null, "", "abc", "100x100", "1280", "1280x720x2", "/1", "/0.5", "/9")) {
assertNull(value, GameResolution.parse(value))
}
}
@Test
fun aScaleDividesTheOutputToEvenSides() {
assertEquals(1706 to 1066, GameResolution.resolve(GameResolution.Scaled(1.5f), 2560 to 1600))
assertEquals(1280 to 800, GameResolution.resolve(GameResolution.Scaled(2f), 2560 to 1600))
assertEquals(1280 to 720, GameResolution.resolve(GameResolution.Fixed(1280, 720), 2560 to 1600))
}
@Test
fun aspectRatiosAreNamed() {
assertEquals("16:9", GameResolution.aspectLabel(1920, 1080))
assertEquals("16:10", GameResolution.aspectLabel(2560, 1600))
assertEquals("4:3", GameResolution.aspectLabel(1024, 768))
assertEquals("21:9", GameResolution.aspectLabel(2560, 1080))
assertEquals("20:9", GameResolution.aspectLabel(2400, 1080))
}
@Test
fun presetsLargerThanThePanelAreLeftOut() {
val wide = GameResolution.aspects.first { it.label == "16:9" }
assertEquals(listOf(960 to 540, 1280 to 720, 1600 to 900, 1920 to 1080),
GameResolution.sizesFor(wide, 1920 to 1200).map { it.width to it.height })
}
@Test
fun theSessionFindsTheResolutionOfTheGameItStarts() {
val config = GameEnvironment.withGameResolution(GameEnvironment.Config(), "570", GameResolution.Fixed(1280, 800))
val scope = NoSteamLaunch.scopeOf(NoSteamLaunch.PROTON_RUN, listOf("--app", "570"))
assertEquals("570", scope)
assertEquals(1280 to 800, NoSteamLaunch.resolution(config, scope, 2560 to 1600))
assertNull(NoSteamLaunch.resolution(config, "440", 2560 to 1600))
assertEquals("123", NoSteamLaunch.scopeOf(NoSteamLaunch.BATTLENET, listOf("launch", "WTCG")) { if (it == "WTCG") "123" else null })
assertEquals(com.droiddeck.launcher.runtime.BattleNet.APP_ID.toString(),
NoSteamLaunch.scopeOf(NoSteamLaunch.BATTLENET, listOf("launch", "Pro")))
assertNull(GameEnvironment.withGameResolution(config, "570", null).games["570"])
}
}