diff options
author | nea <romangraef@gmail.com> | 2022-10-22 00:34:22 +0200 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-10-22 00:34:22 +0200 |
commit | f85c449ed586c7ced780423943e55bfa5abaeb0f (patch) | |
tree | 0c5f59c73cc9e5fcb07de6e3f1f102e2413def27 /src/main/kotlin/moe/nea/notenoughupdates/features | |
parent | c98d4693f1fc9dcae8d78cb33e6233629f4cb2e7 (diff) | |
download | Firmament-f85c449ed586c7ced780423943e55bfa5abaeb0f.tar.gz Firmament-f85c449ed586c7ced780423943e55bfa5abaeb0f.tar.bz2 Firmament-f85c449ed586c7ced780423943e55bfa5abaeb0f.zip |
rudimentary config gui (again)
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/features')
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/features/FeatureManager.kt | 8 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt | 21 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/features/FeatureManager.kt b/src/main/kotlin/moe/nea/notenoughupdates/features/FeatureManager.kt index 0ffaad5..bc9a916 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/features/FeatureManager.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/features/FeatureManager.kt @@ -4,9 +4,9 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.serializer import moe.nea.notenoughupdates.NotEnoughUpdates import moe.nea.notenoughupdates.features.world.FairySouls -import moe.nea.notenoughupdates.util.config.ConfigHolder +import moe.nea.notenoughupdates.util.data.DataHolder -object FeatureManager : ConfigHolder<FeatureManager.Config>(serializer(), "features", ::Config) { +object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "features", ::Config) { @Serializable data class Config( val enabledFeatures: MutableMap<String, Boolean> = mutableMapOf() @@ -40,11 +40,11 @@ object FeatureManager : ConfigHolder<FeatureManager.Config>(serializer(), "featu } fun isEnabled(identifier: String): Boolean? = - config.enabledFeatures[identifier] + data.enabledFeatures[identifier] fun setEnabled(identifier: String, value: Boolean) { - config.enabledFeatures[identifier] = value + data.enabledFeatures[identifier] = value markDirty() } diff --git a/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt b/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt index 9bd1a1f..b8052a6 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt @@ -3,6 +3,7 @@ package moe.nea.notenoughupdates.features.world import io.github.moulberry.repo.data.Coordinate import kotlinx.serialization.Serializable import kotlinx.serialization.serializer +import net.minecraft.client.MinecraftClient import net.minecraft.util.math.BlockPos import moe.nea.notenoughupdates.events.ServerChatLineReceivedEvent import moe.nea.notenoughupdates.events.SkyblockServerUpdateEvent @@ -11,7 +12,8 @@ import moe.nea.notenoughupdates.features.NEUFeature import moe.nea.notenoughupdates.repo.RepoManager import moe.nea.notenoughupdates.util.MC import moe.nea.notenoughupdates.util.SBData -import moe.nea.notenoughupdates.util.config.ProfileSpecificConfigHolder +import moe.nea.notenoughupdates.util.config.ManagedConfig +import moe.nea.notenoughupdates.util.data.ProfileSpecificDataHolder import moe.nea.notenoughupdates.util.render.RenderBlockContext.Companion.renderBlocks import moe.nea.notenoughupdates.util.unformattedString @@ -19,12 +21,22 @@ val Coordinate.blockPos: BlockPos get() = BlockPos(x, y, z) object FairySouls : NEUFeature, - ProfileSpecificConfigHolder<FairySouls.Config>(serializer(), "fairy-souls.json", ::Config) { + ProfileSpecificDataHolder<FairySouls.Config>(serializer(), "found-fairysouls", ::Config) { @Serializable data class Config( val foundSouls: MutableMap<String, MutableSet<Int>> = mutableMapOf() ) + object TConfig : ManagedConfig("fairysouls") { + + val displaySouls by toggle("show") { false } + val resetSouls by button("reset") { + FairySouls.data?.foundSouls?.clear() != null + updateMissingSouls() + } + } + + override val name: String get() = "Fairy Souls" override val identifier: String get() = "fairy-souls" @@ -37,7 +49,7 @@ object FairySouls : NEUFeature, fun updateMissingSouls() { currentMissingSouls = emptyList() - val c = config ?: return + val c = data ?: return val fi = c.foundSouls[currentLocationName] ?: setOf() val cms = currentLocationSouls.toMutableList() fi.asSequence().sortedDescending().filter { it in cms.indices }.forEach { cms.removeAt(it) } @@ -65,7 +77,7 @@ object FairySouls : NEUFeature, private fun markNearestSoul() { val nearestSoul = findNearestClickableSoul() ?: return - val c = config ?: return + val c = data ?: return val loc = currentLocationName ?: return val idx = currentLocationSouls.indexOf(nearestSoul) c.foundSouls.computeIfAbsent(loc) { mutableSetOf() }.add(idx) @@ -92,6 +104,7 @@ object FairySouls : NEUFeature, } } WorldRenderLastEvent.subscribe { + if (!TConfig.displaySouls) return@subscribe renderBlocks(it.camera) { color(1F, 1F, 0F, 0.8F) currentMissingSouls.forEach { |