diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0a62af6625..ff3a2d438f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -228,8 +228,8 @@ dependencies { // JavaSteam val localBuild = false // Change to 'true' needed when building JavaSteam manually if (localBuild) { - implementation(files("../../JavaSteam/build/libs/javasteam-1.8.0-5-SNAPSHOT.jar")) - implementation(files("../../JavaSteam/javasteam-depotdownloader/build/libs/javasteam-depotdownloader-1.8.0-5-SNAPSHOT.jar")) + implementation(files("../../JavaSteam/build/libs/javasteam-1.8.0-6-SNAPSHOT.jar")) + implementation(files("../../JavaSteam/javasteam-depotdownloader/build/libs/javasteam-depotdownloader-1.8.0-6-SNAPSHOT.jar")) implementation(libs.bundles.javasteam.dev) } else { implementation(libs.javasteam) { diff --git a/app/src/main/java/app/gamenative/service/SteamService.kt b/app/src/main/java/app/gamenative/service/SteamService.kt index 46d683bf2b..9f096b9f43 100644 --- a/app/src/main/java/app/gamenative/service/SteamService.kt +++ b/app/src/main/java/app/gamenative/service/SteamService.kt @@ -2036,7 +2036,6 @@ class SteamService : Service(), IChallengeUrlChanged { with(instance!!) { scope.launch { db.withTransaction { - appDao.deleteAll() changeNumbersDao.deleteAll() fileChangeListsDao.deleteAll() licenseDao.deleteAll() diff --git a/app/src/main/java/app/gamenative/ui/component/dialog/GameManagerDialog.kt b/app/src/main/java/app/gamenative/ui/component/dialog/GameManagerDialog.kt index 2fa0af8ccb..a2505b8310 100644 --- a/app/src/main/java/app/gamenative/ui/component/dialog/GameManagerDialog.kt +++ b/app/src/main/java/app/gamenative/ui/component/dialog/GameManagerDialog.kt @@ -18,6 +18,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.Checkbox import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.ListItem import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface @@ -109,7 +110,13 @@ fun GameManagerDialog( allDownloadableApps.clear() // Get Downloadable Depots - downloadableDepots.putAll(SteamService.getDownloadableDepots(gameId)) + val allPossibleDownloadableDepots = SteamService.getDownloadableDepots(gameId) + downloadableDepots.putAll(allPossibleDownloadableDepots) + + // Get Optional DLC IDs + val optionalDlcIds = allPossibleDownloadableDepots + .filter { it.value.optionalDlcId == it.value.dlcAppId } + .map { it.value.dlcAppId } // Add DLCs downloadableDepots @@ -123,7 +130,11 @@ fun GameManagerDialog( .forEach { (_, depotInfo) -> allDownloadableApps.add(Pair(depotInfo.dlcAppId, depotInfo)) val installed = SteamService.getInstalledApp(depotInfo.dlcAppId) - selectedAppIds[depotInfo.dlcAppId] = !indirectDlcAppIds.contains(depotInfo.dlcAppId) || installedDlcIds.contains(depotInfo.dlcAppId) || installed != null + selectedAppIds[depotInfo.dlcAppId] = + installed != null || // For installed Base Game and Indirect DLC App + installedDlcIds.contains(depotInfo.dlcAppId) || // For installed DLC from Main Depot + ( !indirectDlcAppIds.contains(depotInfo.dlcAppId) && !optionalDlcIds.contains(depotInfo.dlcAppId) ) // Not in indirect DLC and not in optional DLC ids + enabledAppIds[depotInfo.dlcAppId] = !installedDlcIds.contains(depotInfo.dlcAppId) && installed == null } @@ -230,6 +241,18 @@ fun GameManagerDialog( ) } + val selectableAppIds by remember(enabledAppIds.toMap()) { + derivedStateOf { + enabledAppIds.filter { it.value }.keys.toList() + } + } + + val allSelectableSelected by remember(selectedAppIds.toMap(), selectableAppIds) { + derivedStateOf { + selectableAppIds.isNotEmpty() && selectableAppIds.all { selectedAppIds[it] == true } + } + } + val installSizeInfo by remember(downloadableDepots.keys.toSet(), selectedAppIds.toMap(), enabledAppIds.toMap()) { derivedStateOf { getInstallSizeInfo() } } @@ -372,6 +395,29 @@ fun GameManagerDialog( Column( modifier = Modifier.fillMaxWidth() ) { + // Select All toggle + if (selectableAppIds.isNotEmpty()) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp, vertical = 8.dp), + horizontalArrangement = Arrangement.End + ) { + Button( + onClick = { + val newState = !allSelectableSelected + selectableAppIds.forEach { appId -> + selectedAppIds[appId] = newState + } + } + ) { + Text( + text = if (allSelectableSelected) "Deselect all" else "Select all" + ) + } + } + } + allDownloadableApps.forEach { (dlcAppId, depotInfo) -> val checked = selectedAppIds[dlcAppId] ?: false val enabled = enabledAppIds[dlcAppId] ?: false @@ -406,6 +452,12 @@ fun GameManagerDialog( selectedAppIds[dlcAppId] = !checked } ) + + HorizontalDivider( + modifier = Modifier.padding(horizontal = 16.dp), + thickness = 0.5.dp, + color = MaterialTheme.colorScheme.outline.copy(alpha = 0.3f) + ) } } diff --git a/app/src/main/java/app/gamenative/ui/screen/library/appscreen/SteamAppScreen.kt b/app/src/main/java/app/gamenative/ui/screen/library/appscreen/SteamAppScreen.kt index 6804d7685f..63f12d4667 100644 --- a/app/src/main/java/app/gamenative/ui/screen/library/appscreen/SteamAppScreen.kt +++ b/app/src/main/java/app/gamenative/ui/screen/library/appscreen/SteamAppScreen.kt @@ -609,8 +609,9 @@ class SteamAppScreen : BaseAppScreen() { val gameId = libraryItem.gameId val appId = libraryItem.appId val appInfo = SteamService.getAppInfoOf(gameId) ?: return emptyList() + val isDownloadInProgress = SteamService.getDownloadingAppInfoOf(gameId) != null - if (!isInstalled) { + if (!isInstalled || isDownloadInProgress) { return emptyList() } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 55c18a31b1..fc5d800b5f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ dataStore = "1.1.2" # https://mvnrepository.com/artifact/androidx.datastore/data espressoCore = "3.6.1" # https://mvnrepository.com/artifact/androidx.test.espresso/espresso-core feature-delivery = "2.1.0" # https://mvnrepository.com/artifact/com.google.android.play/feature-delivery hiltNavigationCompose = "1.2.0" # https://mvnrepository.com/artifact/androidx.hilt/hilt-navigation-compose -javasteam = "1.8.0-5-SNAPSHOT" # https://mvnrepository.com/artifact/in.dragonbra/javasteam +javasteam = "1.8.0-6-SNAPSHOT" # https://mvnrepository.com/artifact/in.dragonbra/javasteam json = "1.8.0" # https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-serialization-json junit = "4.13.2" # https://mvnrepository.com/artifact/junit/junit junitVersion = "1.2.1" # https://mvnrepository.com/artifact/androidx.test.ext/junit