feat: install the redists a Steam game's install script runs on Windows (#1561)

* feat: install the redists a Steam game's install script runs on Windows

* fix: rescan a game's components when its install script changes
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-25 12:44:35 -04:00
1 parent 597402107d
commit 6918fd9308
4 files changed
+49 -3

No files matched your search

@@ -257,7 +257,7 @@ object AutoComponents {
private const val FINDINGS = "wincomp-findings.json"
private const val DETECTORS = "d2"
private const val DETECTORS = "d3"
internal fun signature(context: Context, game: Library.SteamGame): String {
val folder = game.gameFiles
@@ -267,6 +267,8 @@ object AutoComponents {
folder?.let { SteamRedists.manifest(it, game.appId)?.lastModified() },
folder?.let { StoreGameSidecar.file(it).lastModified() },
folder?.let { File(it, "fuel.json").lastModified() },
folder?.listFiles { f -> f.name.lowercase().let { it.startsWith("installscript") && it.endsWith(".vdf") } }
?.maxOfOrNull { it.lastModified() },
SteamAppInfo.appinfoFile(context).lastModified(),
folder?.let { SteamMatch.get(context, it.path) }?.let { "${it.appId}/${it.certainty}" },
steamAppOf(context, game)?.let { SteamAppInfo.state(context, it) },
@@ -28,6 +28,17 @@ object SteamRedists {
return File(steamapps, "appmanifest_$appId.acf").takeIf { it.isFile }
}
/** Redists the game's own install script has Steam run on Windows, from its "Run Process" entries. */
fun installScript(gameDir: File?): List<Pair<String, String>> =
gameDir?.listFiles { f ->
f.isFile && f.length() < 1L shl 20 && f.name.lowercase().let { it.startsWith("installscript") && it.endsWith(".vdf") }
}.orEmpty().sortedBy { it.name }.flatMap { file ->
val root = runCatching { com.droiddeck.launcher.input.KeyValues.parse(file.readText()) }.getOrNull() ?: return@flatMap emptyList()
(root.child("InstallScript") ?: root).children("Run Process")
.flatMap { run -> run.entries.mapNotNull { (it.second as? com.droiddeck.launcher.input.KeyValues.Node)?.string("process 1") } }
.flatMap { path -> DependencyDetector.componentsFor(path).map { it to DependencyDetector.label(it) } }
}.distinctBy { it.first }
fun detect(gameDir: File?, appId: Int): List<DependencyDetector.Recommendation> {
val text = try {
manifest(gameDir, appId)?.takeIf { it.length() < 1L shl 20 }?.readText() ?: return emptyList()
@@ -79,8 +79,8 @@ object WinCompSources {
val local = SteamRedists.detect(gameDir, appId)
val pairs = (if (local.isNotEmpty()) local.map { it.componentName to it.label }
else SteamAppInfo.info(context, appId)?.let { steamDepots(it.sharedDepots) }.orEmpty()) +
SteamRedists.SCRIPTED[appId].orEmpty()
return pairs.map { (component, label) ->
SteamRedists.installScript(gameDir) + SteamRedists.SCRIPTED[appId].orEmpty()
return pairs.distinctBy { it.first.removeSuffix("_dll") }.map { (component, label) ->
Finding(component, label, if (auto) Origin.STEAM else Origin.STEAM_NAME, auto, listOf(label, gameName, appId.toString()))
}
}