mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bcc08c081 |
No files matched your search
@@ -28,7 +28,8 @@ object AutoComponents {
|
|||||||
else -> game.appId.takeIf { it > 0 }?.toString()
|
else -> game.appId.takeIf { it > 0 }?.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun autoPicks(findings: List<WinCompSources.Finding>, catalog: Map<String, WinComponents.Component>): Map<String, WinComponents.AutoReason> {
|
fun autoPicks(findings: List<WinCompSources.Finding>, catalog: Map<String, WinComponents.Component>,
|
||||||
|
user: Map<String, Boolean> = emptyMap()): Map<String, WinComponents.AutoReason> {
|
||||||
val out = LinkedHashMap<String, WinComponents.AutoReason>()
|
val out = LinkedHashMap<String, WinComponents.AutoReason>()
|
||||||
for (f in findings) {
|
for (f in findings) {
|
||||||
if (!f.auto || f.component == null) continue
|
if (!f.auto || f.component == null) continue
|
||||||
@@ -37,6 +38,13 @@ object AutoComponents {
|
|||||||
if (WinComponents.support(c, catalog) != WinComponents.Support.READY) continue
|
if (WinComponents.support(c, catalog) != WinComponents.Support.READY) continue
|
||||||
if (id !in out) out[id] = WinComponents.AutoReason(f.origin.name, listOf(f.original) + f.args)
|
if (id !in out) out[id] = WinComponents.AutoReason(f.origin.name, listOf(f.original) + f.args)
|
||||||
}
|
}
|
||||||
|
if (user["d3dx9"] != false && (user["d3dx9"] == true || "d3dx9" in out)) {
|
||||||
|
val reason = out["d3dx9"] ?: WinComponents.AutoReason(WinCompSources.Origin.FOLDER.name, listOf("d3dx9"))
|
||||||
|
for (id in listOf("d3dcompiler_42", "d3dcompiler_43")) {
|
||||||
|
val c = catalog[id] ?: continue
|
||||||
|
if (WinComponents.support(c, catalog) == WinComponents.Support.READY) out.putIfAbsent(id, reason)
|
||||||
|
}
|
||||||
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,8 +236,8 @@ object AutoComponents {
|
|||||||
val findings = findings(context, game)
|
val findings = findings(context, game)
|
||||||
val refreshed = if (knownCatalog == null && asked && online(context)) catalogOf(context, true) else null
|
val refreshed = if (knownCatalog == null && asked && online(context)) catalogOf(context, true) else null
|
||||||
val catalog = knownCatalog ?: (refreshed ?: catalogOf(context, false) ?: catalogOf(context, true))?.associateBy { it.name } ?: return
|
val catalog = knownCatalog ?: (refreshed ?: catalogOf(context, false) ?: catalogOf(context, true))?.associateBy { it.name } ?: return
|
||||||
val wanted = autoPicks(findings, catalog)
|
|
||||||
val user = WinComponents.selection(context, key).user
|
val user = WinComponents.selection(context, key).user
|
||||||
|
val wanted = autoPicks(findings, catalog, user)
|
||||||
val before = WinComponents.selection(context, key).auto
|
val before = WinComponents.selection(context, key).auto
|
||||||
val installed = installedOf(context)
|
val installed = installedOf(context)
|
||||||
val kept = LinkedHashMap<String, WinComponents.AutoReason>()
|
val kept = LinkedHashMap<String, WinComponents.AutoReason>()
|
||||||
@@ -452,9 +460,9 @@ object AutoComponents {
|
|||||||
}
|
}
|
||||||
return pendingSaved && pending.isEmpty()
|
return pendingSaved && pending.isEmpty()
|
||||||
}
|
}
|
||||||
val wanted = autoPicks(findings, catalog)
|
|
||||||
val selection = WinComponents.selection(context, key)
|
val selection = WinComponents.selection(context, key)
|
||||||
val user = selection.user
|
val user = selection.user
|
||||||
|
val wanted = autoPicks(findings, catalog, user)
|
||||||
val installed = installedOf(context)
|
val installed = installedOf(context)
|
||||||
val roots = selection.effective + wanted.keys.filter { user[it] != false }
|
val roots = selection.effective + wanted.keys.filter { user[it] != false }
|
||||||
val required = withParts(roots.filter { WinComponents.validId(it) }, catalog)
|
val required = withParts(roots.filter { WinComponents.validId(it) }, catalog)
|
||||||
|
|||||||
@@ -205,6 +205,36 @@ class WinCompSourcesTest {
|
|||||||
assertEquals("GOG", picks.getValue("vcredist2015_dll").kind)
|
assertEquals("GOG", picks.getValue("vcredist2015_dll").kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun nativeD3dxSelectsItsEffectCompilersForEveryAutomaticSource() {
|
||||||
|
val catalog = listOf(ready("d3dx9"), ready("d3dcompiler_42"), ready("d3dcompiler_43")).associateBy { it.name }
|
||||||
|
for (origin in WinCompSources.Origin.values()) {
|
||||||
|
val finding = WinCompSources.Finding("d3dx9", "DirectX", origin, true)
|
||||||
|
val picks = AutoComponents.autoPicks(listOf(finding), catalog)
|
||||||
|
assertEquals(setOf("d3dx9", "d3dcompiler_42", "d3dcompiler_43"), picks.keys)
|
||||||
|
assertEquals(origin.name, picks.getValue("d3dcompiler_43").kind)
|
||||||
|
assertEquals(picks.getValue("d3dx9").args, picks.getValue("d3dcompiler_43").args)
|
||||||
|
assertEquals(setOf("d3dx9"), AutoComponents.autoPicks(listOf(finding), catalog, mapOf("d3dx9" to false)).keys)
|
||||||
|
assertTrue(AutoComponents.autoPicks(listOf(finding.copy(auto = false)), catalog).isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(setOf("d3dcompiler_42", "d3dcompiler_43"),
|
||||||
|
AutoComponents.autoPicks(emptyList(), catalog, mapOf("d3dx9" to true)).keys)
|
||||||
|
assertTrue(AutoComponents.autoPicks(emptyList(), catalog, mapOf("xact" to true)).isEmpty())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun effectCompilerSelectionKeepsIndependentFindingsAndSkipsUnavailableComponents() {
|
||||||
|
val catalog = listOf(ready("d3dx9"), ready("d3dcompiler_43"),
|
||||||
|
WinComponents.Component("d3dcompiler_42", "", "", "broken", emptyList(), emptyList())).associateBy { it.name }
|
||||||
|
val findings = listOf(
|
||||||
|
WinCompSources.Finding("d3dx9", "DirectX", WinCompSources.Origin.GOG, true),
|
||||||
|
WinCompSources.Finding("d3dcompiler_43", "Compiler", WinCompSources.Origin.STEAM, true),
|
||||||
|
)
|
||||||
|
val picks = AutoComponents.autoPicks(findings, catalog)
|
||||||
|
assertEquals(setOf("d3dx9", "d3dcompiler_43"), picks.keys)
|
||||||
|
assertEquals("STEAM", picks.getValue("d3dcompiler_43").kind)
|
||||||
|
assertEquals(picks.keys, AutoComponents.autoPicks(findings, catalog, mapOf("d3dx9" to false)).keys)
|
||||||
|
assertEquals(setOf("d3dx9"), AutoComponents.autoPicks(findings.take(1), catalog - "d3dcompiler_43").keys)
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun theUsersSwitchWinsOverAnAutoPickEitherWay() {
|
@Test fun theUsersSwitchWinsOverAnAutoPickEitherWay() {
|
||||||
val key = "12345"
|
val key = "12345"
|
||||||
WinComponents.setAuto(app, key, mapOf("d3dx9" to WinComponents.AutoReason("GOG", listOf("DirectX")), "xact" to WinComponents.AutoReason("GOG", listOf("XACT"))))
|
WinComponents.setAuto(app, key, mapOf("d3dx9" to WinComponents.AutoReason("GOG", listOf("DirectX")), "xact" to WinComponents.AutoReason("GOG", listOf("XACT"))))
|
||||||
@@ -279,6 +309,42 @@ class WinCompSourcesTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun installedD3dxGainsCompilersWithoutReplacingUserChoices() = withFakeWorker {
|
||||||
|
AutoComponents.catalogOf = { _, _ -> catalog3 + ready("d3dcompiler_42") + ready("d3dcompiler_43") }
|
||||||
|
installedNow.addAll(catalog3.map { it.name })
|
||||||
|
val game = payback()
|
||||||
|
WinComponents.setUser(app, "1262580", "d3dcompiler_42", false)
|
||||||
|
AutoComponents.queueGame(app, game, asked = true)
|
||||||
|
assertEquals(listOf("d3dcompiler_43"), downloaded)
|
||||||
|
assertEquals(setOf("d3dx9", "vcredist2013_dll", "vcredist2019_dll", "d3dcompiler_43"), WinComponents.picks(app, "1262580").toSet())
|
||||||
|
assertEquals(mapOf("d3dcompiler_42" to false), WinComponents.selection(app, "1262580").user)
|
||||||
|
assertTrue(AutoComponents.Pending.ids(app, "1262580").isEmpty())
|
||||||
|
AutoComponents.queueGame(app, game, asked = true)
|
||||||
|
assertEquals(listOf("d3dcompiler_43"), downloaded)
|
||||||
|
WinComponents.setUser(app, "1262580", "d3dx9", false)
|
||||||
|
AutoComponents.queueGame(app, game, asked = true)
|
||||||
|
assertEquals(setOf("vcredist2013_dll", "vcredist2019_dll"), WinComponents.picks(app, "1262580").toSet())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun manuallySelectedD3dxQueuesCompilersBeforeLaunch() = withFakeWorker {
|
||||||
|
AutoComponents.catalogOf = { _, _ -> catalog3 + ready("d3dcompiler_42") + ready("d3dcompiler_43") }
|
||||||
|
installedNow.add("d3dx9")
|
||||||
|
val game = game(tmp.newFolder("ManualEffects"), Library.ADDED)
|
||||||
|
val key = AutoComponents.appKey(game)!!
|
||||||
|
WinComponents.setUser(app, key, "d3dx9", true)
|
||||||
|
WinComponents.setUser(app, key, "d3dcompiler_42", false)
|
||||||
|
session = true
|
||||||
|
gameUp = true
|
||||||
|
assertTrue(AutoComponents.prepareLaunch(app, game))
|
||||||
|
assertEquals(listOf("d3dcompiler_43"), AutoComponents.Pending.ids(app, key))
|
||||||
|
assertTrue(downloaded.isEmpty())
|
||||||
|
gameUp = false
|
||||||
|
AutoComponents.drain(app)
|
||||||
|
assertEquals(listOf("d3dcompiler_43"), downloaded)
|
||||||
|
assertEquals(setOf("d3dx9", "d3dcompiler_43"), WinComponents.picks(app, key).toSet())
|
||||||
|
assertTrue(AutoComponents.Pending.ids(app, key).isEmpty())
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun anExplicitCheckRefreshesTheCatalogAndAnOfflineCheckUsesTheCache() = withFakeWorker {
|
@Test fun anExplicitCheckRefreshesTheCatalogAndAnOfflineCheckUsesTheCache() = withFakeWorker {
|
||||||
installedNow.addAll(catalog3.map { it.name })
|
installedNow.addAll(catalog3.map { it.name })
|
||||||
val requests = ArrayList<Boolean>()
|
val requests = ArrayList<Boolean>()
|
||||||
|
|||||||
Reference in new issue
Block a user