diff options
author | nea <romangraef@gmail.com> | 2022-08-07 23:51:45 +0200 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-08-07 23:51:45 +0200 |
commit | 9713b856f8abdb003824fd3d0ef4bc8a8bfc5b06 (patch) | |
tree | 72f24e1f42e8449c8fb993aca33d752008a13f7b /src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt | |
parent | dc4755eb79ab78f87b0e1e4ad6dac81912af0ee0 (diff) | |
download | firmament-9713b856f8abdb003824fd3d0ef4bc8a8bfc5b06.tar.gz firmament-9713b856f8abdb003824fd3d0ef4bc8a8bfc5b06.tar.bz2 firmament-9713b856f8abdb003824fd3d0ef4bc8a8bfc5b06.zip |
progress bar
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt index 375b2bb..c515ff7 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt @@ -1,5 +1,6 @@ package moe.nea.notenoughupdates.repo +import io.github.cottonmc.cotton.gui.client.CottonHud import io.github.moulberry.repo.NEURepository import io.github.moulberry.repo.NEURepositoryException import kotlinx.coroutines.launch @@ -7,6 +8,7 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.serializer import moe.nea.notenoughupdates.NotEnoughUpdates import moe.nea.notenoughupdates.NotEnoughUpdates.logger +import moe.nea.notenoughupdates.hud.ProgressBar import moe.nea.notenoughupdates.util.ConfigHolder import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents import net.minecraft.client.Minecraft @@ -24,6 +26,10 @@ object RepoManager : ConfigHolder<RepoManager.Config>(serializer(), "repo", ::Co var recentlyFailedToUpdateItemList = false + val progressBar = ProgressBar("", null, 0).also { + it.setSize(180, 22) + } + val neuRepo: NEURepository = NEURepository.of(RepoDownloadManager.repoSavedLocation).apply { registerReloadListener(ItemCache) registerReloadListener { @@ -49,13 +55,18 @@ object RepoManager : ConfigHolder<RepoManager.Config>(serializer(), "repo", ::Co fun launchAsyncUpdate() { NotEnoughUpdates.coroutineScope.launch { + progressBar.reportProgress("Downloading", 0, null) + CottonHud.add(progressBar) RepoDownloadManager.downloadUpdate() + progressBar.reportProgress("Download complete", 1, 1) reload() } } fun reload() { try { + progressBar.reportProgress("Reloading from Disk", 0, null) + CottonHud.add(progressBar) neuRepo.reload() } catch (exc: NEURepositoryException) { Minecraft.getInstance().player?.sendSystemMessage( |