aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-24 02:29:20 +0200
committernea <nea@nea.moe>2023-05-24 02:29:20 +0200
commit5984383d2c48b4ae84bac1827bc6ca1891af8cf0 (patch)
tree90aaae93147ce7aad48777be488039626b70512a /src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt
parent5ff50799b6c8baf6dd87ecbf44860d19a4acceab (diff)
downloadFirmament-5984383d2c48b4ae84bac1827bc6ca1891af8cf0.tar.gz
Firmament-5984383d2c48b4ae84bac1827bc6ca1891af8cf0.tar.bz2
Firmament-5984383d2c48b4ae84bac1827bc6ca1891af8cf0.zip
Common config gui
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt b/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt
index b1091fc..ea77fc1 100644
--- a/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt
+++ b/src/main/kotlin/moe/nea/firmament/repo/RepoManager.kt
@@ -8,8 +8,6 @@ import io.github.moulberry.repo.data.NEUItem
import io.github.moulberry.repo.data.NEURecipe
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import kotlinx.coroutines.launch
-import kotlinx.serialization.Serializable
-import kotlinx.serialization.serializer
import net.minecraft.client.MinecraftClient
import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket
import net.minecraft.text.Text
@@ -17,16 +15,21 @@ import moe.nea.firmament.Firmament
import moe.nea.firmament.Firmament.logger
import moe.nea.firmament.hud.ProgressBar
import moe.nea.firmament.util.SkyblockId
-import moe.nea.firmament.util.data.DataHolder
-
-object RepoManager : DataHolder<RepoManager.Config>(serializer(), "repo", ::Config) {
- @Serializable
- data class Config(
- var user: String = "NotEnoughUpdates",
- var repo: String = "NotEnoughUpdates-REPO",
- var autoUpdate: Boolean = true,
- var branch: String = "dangerous",
- )
+import moe.nea.firmament.gui.config.ManagedConfig
+
+object RepoManager {
+ object Config : ManagedConfig("repo") {
+ var username by string("username") { "NotEnoughUpdates" }
+ var reponame by string("reponame") { "NotEnoughUpdates-REPO" }
+ var branch by string("branch") { "prerelease" }
+ val autoUpdate by toggle("autoUpdate") { true }
+ val reset by button("reset") {
+ username = "NotEnoughUpdates"
+ reponame = "NotEnoughUpdates-REPO"
+ branch = "prerelease"
+ save()
+ }
+ }
val currentDownloadedSha by RepoDownloadManager::latestSavedVersionHash
@@ -93,7 +96,7 @@ object RepoManager : DataHolder<RepoManager.Config>(serializer(), "repo", ::Conf
}
fun initialize() {
- if (data.autoUpdate) {
+ if (Config.autoUpdate) {
launchAsyncUpdate()
} else {
reload()