From a82cc5035ba7c76bbbdf389e6e48d5852676babb Mon Sep 17 00:00:00 2001 From: Josh Larson Date: Tue, 5 Jul 2022 18:36:24 -0500 Subject: [PATCH] Added cancel button for downloads --- .../launcher/resources/gui/ServerListView.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/projectswg/launcher/resources/gui/ServerListView.kt b/src/main/java/com/projectswg/launcher/resources/gui/ServerListView.kt index d6f76f5..a3615ab 100644 --- a/src/main/java/com/projectswg/launcher/resources/gui/ServerListView.kt +++ b/src/main/java/com/projectswg/launcher/resources/gui/ServerListView.kt @@ -28,6 +28,7 @@ import com.projectswg.launcher.resources.gui.events.LauncherNewVersionEvent import com.projectswg.launcher.resources.gui.servers.LauncherUpdatePopup import com.projectswg.launcher.resources.gui.servers.WebsitePostFeedList import com.projectswg.launcher.resources.gui.style.Style +import com.projectswg.launcher.resources.intents.CancelDownloadIntent import com.projectswg.launcher.resources.intents.DownloadPatchIntent import com.projectswg.launcher.resources.intents.GameLaunchedIntent import com.projectswg.launcher.resources.intents.RequestScanIntent @@ -137,8 +138,22 @@ class ServerListView : View() { DownloadPatchIntent(LauncherData.INSTANCE.login.activeServer?.updateServer ?: return@setOnAction).broadcast() } } + button("Cancel") { + val targetWidthProperty = updateStatus.select { ReadOnlyDoubleWrapper(if (it == UpdateServer.UpdateServerStatus.DOWNLOADING) 75.0 else 0.0) } + visibleWhen { updateStatus.select { ReadOnlyBooleanWrapper(it == UpdateServer.UpdateServerStatus.DOWNLOADING) } } + minWidthProperty().bind(targetWidthProperty) + maxWidthProperty().bind(targetWidthProperty) + + setOnAction { + CancelDownloadIntent(LauncherData.INSTANCE.login.activeServer?.updateServer ?: return@setOnAction).broadcast() + } + } button("Scan") { - minWidth = 75.0 + val targetWidthProperty = updateStatus.select { ReadOnlyDoubleWrapper(if (it != UpdateServer.UpdateServerStatus.DOWNLOADING) 75.0 else 0.0) } + visibleWhen { updateStatus.select { ReadOnlyBooleanWrapper(it != UpdateServer.UpdateServerStatus.DOWNLOADING) } } + minWidthProperty().bind(targetWidthProperty) + maxWidthProperty().bind(targetWidthProperty) + setOnAction { RequestScanIntent(LauncherData.INSTANCE.login.activeServer?.updateServer ?: return@setOnAction).broadcast() }