mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
Share installed games between the arm64 and x86-64 Steam clients
This commit is contained in:
1 parent
8d407aa1e8
commit
c866bb90db
8 files changed
+486
-14
No files matched your search
@@ -106,7 +106,10 @@ object Library {
|
||||
.firstOrNull { it.isDirectory }
|
||||
}
|
||||
|
||||
fun steamGames(context: Context, strictRead: Boolean = false, arch: String = SessionPrefs.activeSteamClientArch(context)): List<SteamGame> {
|
||||
fun steamGames(
|
||||
context: Context, strictRead: Boolean = false, arch: String = SessionPrefs.activeSteamClientArch(context),
|
||||
withShared: Boolean = true,
|
||||
): List<SteamGame> {
|
||||
val root = SessionPrefs.steamRoot(context, arch)
|
||||
val cache = File(root, "appcache/librarycache")
|
||||
val libraries = steamLibraries(context, arch)
|
||||
@@ -139,9 +142,20 @@ object Library {
|
||||
))
|
||||
}
|
||||
}
|
||||
if (withShared) {
|
||||
val other = if (arch == "x86_64") "arm64" else "x86_64"
|
||||
val shared = sharedApps(context, arch) - out.keys
|
||||
if (shared.isNotEmpty()) runCatching { steamGames(context, arch = other, withShared = false) }.getOrDefault(emptyList())
|
||||
.filter { it.appId in shared }.forEach { out[it.appId] = it }
|
||||
}
|
||||
return out.values.toList()
|
||||
}
|
||||
|
||||
internal fun sharedApps(context: Context, arch: String): Set<Int> {
|
||||
val view = File(LinuxRuntime.rootDir(context), "root/.droiddeck-x64/shared/${if (arch == "x86_64") "arm64" else "x86-64"}/steamapps")
|
||||
return view.list().orEmpty().mapNotNull { Regex("appmanifest_(\\d+)\\.acf").matchEntire(it)?.groupValues?.get(1)?.toIntOrNull() }.toSet()
|
||||
}
|
||||
|
||||
fun steamLibraryArt(context: Context): List<Pair<Int, File>> {
|
||||
val root = SessionPrefs.activeSteamRoot(context)
|
||||
val cache = File(root, "appcache/librarycache")
|
||||
|
||||
@@ -61,6 +61,7 @@ object SessionFiles {
|
||||
"usr/local/bin/droiddeck-steam-shaders" to "usr/local/bin/droiddeck-steam-shaders",
|
||||
"usr/local/bin/droiddeck-steam-desktop-ui" to "usr/local/bin/droiddeck-steam-desktop-ui",
|
||||
"usr/local/bin/droiddeck-steam-library" to "usr/local/bin/droiddeck-steam-library",
|
||||
"usr/local/bin/droiddeck-steam-share" to "usr/local/bin/droiddeck-steam-share",
|
||||
"usr/local/bin/droiddeck-seed-redists" to "usr/local/bin/droiddeck-seed-redists",
|
||||
"usr/local/bin/droiddeck-launcher-cores" to "usr/local/bin/droiddeck-launcher-cores",
|
||||
"usr/local/bin/droiddeck-proton-extra" to "usr/local/bin/droiddeck-proton-extra",
|
||||
|
||||
@@ -23,6 +23,20 @@ class LibraryArchTest {
|
||||
assertEquals(emptyList<String>(), Library.launchableGames(app, added = emptyList(), arch = "arm64").map { it.name })
|
||||
}
|
||||
|
||||
@Test fun aGameTheOtherClientSharesIsListedFromItsFiles() {
|
||||
SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "")
|
||||
val apps = File(SessionPrefs.steamRoot(app, "x86_64"), "steamapps").apply { mkdirs() }
|
||||
File(apps, "common/Team Fortress 2").mkdirs()
|
||||
val manifest = "\"AppState\"\n{\n\t\"appid\"\t\t\"440\"\n\t\"name\"\t\t\"Team Fortress 2\"\n\t\"StateFlags\"\t\t\"4\"\n\t\"installdir\"\t\t\"Team Fortress 2\"\n}\n"
|
||||
File(apps, "appmanifest_440.acf").writeText(manifest)
|
||||
val view = File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(app), "root/.droiddeck-x64/shared/x86-64/steamapps").apply { mkdirs() }
|
||||
File(view, "appmanifest_440.acf").writeText(manifest)
|
||||
val shared = Library.steamGames(app, arch = "arm64").single()
|
||||
assertEquals("Team Fortress 2", shared.name)
|
||||
assertEquals(File(apps, "common/Team Fortress 2"), shared.gameFiles)
|
||||
assertEquals(listOf("Team Fortress 2"), Library.steamGames(app, arch = "x86_64").map { it.name })
|
||||
}
|
||||
|
||||
@Test fun anAddedGameSteamAlreadyListsFromItsFolderIsShownOnce() {
|
||||
SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "")
|
||||
val folder = File(app.filesDir, "games/Example").apply { mkdirs() }
|
||||
|
||||
Reference in new issue
Block a user