mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 13:26:02 +00:00
feat: install Battle.net games from Stores with downloads, updates and uninstall
Battle.net games now install like Epic, Xbox and itch games: Install, pick a location, and the download runs in the Downloads tab while the Stores page stays open. droiddeck-battlenet starts Blizzard's own Agent on its own under a headless gamescope and drives its local API, so no window opens and nothing waits on the Battle.net client. - Progress, speed and time left come from the Agent, with pause, resume (the Agent keeps what it downloaded) and cancel, which uninstalls the partial game and removes its folder. - A job only finishes once the Agent has really run it and the game is playable; the first status after a request can still describe the previous operation. - Installed games check Blizzard's version service and show Update when the build on disk is behind; the update repairs missing files too. - Battle.net games can be uninstalled from their page through the Agent. - Games land in the chosen location: internal storage, other storage or a Games folder. - The hero keeps its action row clear of the playtime column.
This commit is contained in:
1 parent
9fc48515c1
commit
b887e8653d
43 files changed
+1176
-49
No files matched your search
@@ -56,6 +56,7 @@ import androidx.compose.ui.input.key.onPreviewKeyEvent
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.layout.boundsInRoot
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.layout.positionInRoot
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
@@ -86,6 +87,7 @@ import com.droiddeck.launcher.stores.StoreInstallRoot
|
||||
import com.droiddeck.launcher.stores.StoreLanguage
|
||||
import com.droiddeck.launcher.stores.StoreSizes
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import com.droiddeck.launcher.stores.battlenet.BattleNetInstall
|
||||
import com.droiddeck.launcher.stores.download.DownloadQueue
|
||||
import com.droiddeck.launcher.stores.download.DownloadState
|
||||
import com.droiddeck.launcher.stores.formatBytes
|
||||
@@ -267,13 +269,15 @@ private fun GameHero(
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.matchParentSize().background(Brush.horizontalGradient(0f to colors.background.copy(alpha = 0.94f), 0.55f to colors.background.copy(alpha = 0.58f), 1f to Color.Transparent)))
|
||||
var scoresWidth by remember { mutableStateOf(0) }
|
||||
if (scores != null) {
|
||||
Spacer(Modifier.matchParentSize().background(Brush.horizontalGradient(0.45f to Color.Transparent, 1f to colors.background.copy(alpha = 0.75f))))
|
||||
HeroScores(scores, Modifier.align(Alignment.BottomEnd).padding(end = 16.dp, bottom = 18.dp))
|
||||
HeroScores(scores, Modifier.align(Alignment.BottomEnd).padding(end = 16.dp, bottom = 18.dp).onSizeChanged { scoresWidth = it.width })
|
||||
}
|
||||
val scoresSpace = with(LocalDensity.current) { if (scores != null && scoresWidth > 0) scoresWidth.toDp() + 16.dp else 0.dp }
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
modifier = Modifier.align(Alignment.BottomStart).padding(horizontal = 22.dp, vertical = 18.dp),
|
||||
modifier = Modifier.align(Alignment.BottomStart).padding(start = 22.dp, end = 22.dp + scoresSpace, top = 18.dp, bottom = 18.dp),
|
||||
content = content,
|
||||
)
|
||||
Box(Modifier.align(Alignment.TopEnd).padding(12.dp), content = corner)
|
||||
@@ -358,7 +362,19 @@ internal fun GameActions(
|
||||
}
|
||||
SecondaryButton(stringResource(R.string.stores_xbox_manage), enabled = download == null) { XboxContent.manage(ctx, installed) }
|
||||
}
|
||||
if (store == Store.BATTLENET) SecondaryButton(stringResource(R.string.bnet_open)) { a.onBattleNet() }
|
||||
if (store == Store.BATTLENET) {
|
||||
if (installed != null && id != null) {
|
||||
LaunchedEffect(id) { BattleNetInstall.checkUpdate(ctx, installed) }
|
||||
if (download != null) {
|
||||
ActionChip(downloadLabel(download), ok = false)
|
||||
if (download.state != DownloadState.PAUSED) SecondaryButton(stringResource(R.string.stores_dl_pause)) { DownloadQueue.pause(download.key) }
|
||||
else SecondaryButton(stringResource(R.string.stores_dl_resume)) { DownloadQueue.resume(ctx, download.key) }
|
||||
} else if (BattleNetInstall.updates[id] == true) {
|
||||
SecondaryButton(stringResource(R.string.bnet_update)) { BattleNetInstall.update(ctx, installed) }
|
||||
}
|
||||
}
|
||||
SecondaryButton(stringResource(R.string.bnet_open)) { a.onBattleNet() }
|
||||
}
|
||||
}
|
||||
download != null -> {
|
||||
ActionChip(downloadLabel(download), ok = false)
|
||||
@@ -534,7 +550,7 @@ private fun IconAction(icon: androidx.compose.ui.graphics.vector.ImageVector, la
|
||||
private fun RemoveButton(title: String, game: Library.SteamGame?, installed: InstalledStoreGame?, a: FrontEndActions) {
|
||||
val ctx = LocalContext.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
if ((installed?.sidecar?.store?.id ?: game?.source) == Store.BATTLENET.id) return
|
||||
if ((installed?.sidecar?.store?.id ?: game?.source) == Store.BATTLENET.id && installed?.sidecar?.id?.let(BattleNetInstall::product) == null) return
|
||||
if (installed != null) {
|
||||
val key = installed.key
|
||||
val gone = StoresState.uninstalling[key]
|
||||
|
||||
@@ -1392,7 +1392,11 @@ internal fun downloadLabel(d: com.droiddeck.launcher.stores.download.DownloadEnt
|
||||
|
||||
@Composable
|
||||
internal fun activeStageLabel(d: com.droiddeck.launcher.stores.download.DownloadEntry): String = when (d.stage) {
|
||||
DownloadStage.MANIFEST -> if (d.stageItemsTotal > 0) stringResource(R.string.stores_stage_checking) else stringResource(R.string.stores_stage_manifest)
|
||||
DownloadStage.MANIFEST -> when {
|
||||
d.store == Store.BATTLENET && d.detail.isNotBlank() -> d.detail
|
||||
d.stageItemsTotal > 0 -> stringResource(R.string.stores_stage_checking)
|
||||
else -> stringResource(R.string.stores_stage_manifest)
|
||||
}
|
||||
DownloadStage.DOWNLOAD -> stringResource(R.string.stores_stage_downloading)
|
||||
DownloadStage.VERIFY -> stringResource(R.string.stores_stage_verifying)
|
||||
DownloadStage.INSTALL -> stringResource(R.string.stores_stage_installing)
|
||||
|
||||
Reference in new issue
Block a user