Added progress bar to active downloads

This commit is contained in:
Josh Larson
2022-07-05 18:30:29 -05:00
parent 9011b7591a
commit e6240557d4
3 changed files with 15 additions and 1 deletions

View File

@@ -144,6 +144,16 @@ class ServerListView : View() {
}
}
}
progressbar {
val updateStatus = LauncherData.INSTANCE.login.activeServerProperty.select { it.updateServerProperty }
visibleWhen { updateStatus.select { it.statusProperty }.select { ReadOnlyBooleanWrapper(it == UpdateServer.UpdateServerStatus.DOWNLOADING) } }
prefHeight = 12.0
maxHeight = 12.0
maxWidth = Double.POSITIVE_INFINITY
progressProperty().bind(updateStatus.select { it.downloadProgressProperty })
isFillWidth = true
}
}
button("Play") { // TODO: Get proper string for this
isFillWidth = true

View File

@@ -110,6 +110,9 @@ class Style : Stylesheet() {
highlightFill = additionalColorPrimary
textFill = textColorPrimary
}
s(progressBar child bar) {
backgroundColor += additionalColorSecondary
}
// ComboBox, Button, and ScrollBar button styling
s( comboBox,

View File

@@ -89,7 +89,8 @@ class DownloadService : Service() {
dataTransferredBinding = dataTransferredBinding.add(downloadAmount)
threadPool.execute { download(file, fileLockPool, downloadAmount, running) }
}
dpi.server.downloadProgressProperty.bind(dataTransferredBinding.divide(files.stream().mapToLong { it.length }.sum().toDouble()))
val totalDownloadSize = files.stream().mapToLong { it.length }.sum().toDouble()
Platform.runLater { dpi.server.downloadProgressProperty.bind(dataTransferredBinding.divide(totalDownloadSize)) }
// Waits for all files to complete, then is able to grab the one remaining lock
try {