mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
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:
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()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,39 @@ class WinComponentDetectorsTest {
|
||||
assertEquals(emptyList<String?>(), WinCompSources.steamList(context, game, 409710, "Other", auto = true).map { it.component })
|
||||
}
|
||||
|
||||
@Test fun theGamesInstallScriptRedistsAreInstalledAsSteamWould() {
|
||||
val steamapps = tmp.newFolder("steamapps")
|
||||
val game = File(steamapps, "common/DiRT 3 Complete Edition").apply { mkdirs() }
|
||||
File(steamapps, "appmanifest_321040.acf").writeText("\"AppState\"\n{\n\t\"SharedDepots\"\n\t{\n\t\t\"228983\"\t\t\"228980\"\n\t}\n}\n")
|
||||
File(game, "installscript.vdf").writeText(
|
||||
"""
|
||||
"InstallScript"
|
||||
{
|
||||
"Registry" { "HKEY_LOCAL_MACHINE\\Software\\Codemasters" { "string" { "Path" "%INSTALLDIR%" } } }
|
||||
"Run Process"
|
||||
{
|
||||
"OpenAL"
|
||||
{
|
||||
"HasRunKey" "HKEY_LOCAL_MACHINE\\Software\\Valve\\Steam\\Apps\\321040"
|
||||
"process 1" "%INSTALLDIR%\\_CommonRedist\\OpenAL\\2.0.7.0\\oalinst.exe"
|
||||
"command 1" "/s"
|
||||
}
|
||||
"VC2010"
|
||||
{
|
||||
"process 1" "%INSTALLDIR%\\_CommonRedist\\vcredist\\2010\\vcredist_x86.exe"
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent(),
|
||||
)
|
||||
assertEquals(listOf("oalinst", "vcredist2010"), SteamRedists.installScript(game).map { it.first })
|
||||
val context = androidx.test.core.app.ApplicationProvider.getApplicationContext<android.content.Context>()
|
||||
val found = WinCompSources.steamList(context, game, 321040, "DiRT 3 Complete Edition", auto = true)
|
||||
assertEquals(listOf("vcredist2010_dll", "oalinst"), found.map { it.component })
|
||||
assertTrue(found.all { it.auto && it.origin == WinCompSources.Origin.STEAM })
|
||||
assertEquals(emptyList<Pair<String, String>>(), SteamRedists.installScript(File(steamapps, "missing")))
|
||||
}
|
||||
|
||||
@Test fun thePrefixCountsOnlyWhatDroidDeckDidNotPutThere() {
|
||||
val compat = tmp.newFolder("compatdata", "409710")
|
||||
val pfx = File(compat, "pfx")
|
||||
|
||||
Reference in new issue
Block a user