From b0509261558c30baf3fe73eaf3df794297e34456 Mon Sep 17 00:00:00 2001 From: purofle Date: Sun, 31 Dec 2023 23:38:08 +0800 Subject: [PATCH] =?UTF-8?q?UI:=20=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=E7=BA=BF=E7=A8=8B=E9=98=BB=E5=A1=9E?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/github/purofle/nmsl/pages/DownloadPage.kt | 6 +++++- src/main/kotlin/com/github/purofle/nmsl/pages/GamePage.kt | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/github/purofle/nmsl/pages/DownloadPage.kt b/src/main/kotlin/com/github/purofle/nmsl/pages/DownloadPage.kt index b4e2696..a099fc8 100644 --- a/src/main/kotlin/com/github/purofle/nmsl/pages/DownloadPage.kt +++ b/src/main/kotlin/com/github/purofle/nmsl/pages/DownloadPage.kt @@ -26,7 +26,9 @@ import com.github.purofle.nmsl.game.Manifest import com.github.purofle.nmsl.game.VersionType import com.github.purofle.nmsl.utils.getDefaultProvider import com.github.purofle.nmsl.utils.getGameDownloader +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import java.time.Instant import java.time.ZoneOffset import java.time.format.DateTimeFormatter @@ -46,7 +48,9 @@ class DownloadPage : Page { var remoteManifest: Manifest? by rememberSaveable { mutableStateOf(null) } LaunchedEffect(Unit) { - remoteManifest = GameManager.downloadManifest(DownloadProvider.getDefaultProvider()) + withContext(Dispatchers.IO) { + remoteManifest = GameManager.downloadManifest(DownloadProvider.getDefaultProvider()) + } } val scope = rememberCoroutineScope() diff --git a/src/main/kotlin/com/github/purofle/nmsl/pages/GamePage.kt b/src/main/kotlin/com/github/purofle/nmsl/pages/GamePage.kt index c264290..2eea3b2 100644 --- a/src/main/kotlin/com/github/purofle/nmsl/pages/GamePage.kt +++ b/src/main/kotlin/com/github/purofle/nmsl/pages/GamePage.kt @@ -23,6 +23,7 @@ import com.github.purofle.nmsl.config.NmslConfig import com.github.purofle.nmsl.game.GameManager import com.github.purofle.nmsl.utils.getGameDownloader import com.github.purofle.nmsl.utils.startGame +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import org.jetbrains.skiko.ClipboardManager import org.jetbrains.skiko.URIManager @@ -91,8 +92,8 @@ class GamePage : Page { if (selectedGame.isNotBlank()) { ExtendedFloatingActionButton( { + scope.launch(Dispatchers.IO) { val gameDownloader = getGameDownloader(selectedGame) - scope.launch { startGame(selectedGame, gameDownloader.getLauncherArgument()) }