Add a shouldSave property to the ButtonInfo annotation class

This commit is contained in:
Username404 2021-06-27 23:11:03 +02:00
parent 520f14ced9
commit d70dae6da1
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
4 changed files with 5 additions and 4 deletions

View File

@ -94,7 +94,7 @@ object Configuration {
Thread {
runBlocking {
ClickGui.boxContext {
enabledFeatures.putAll(buttons.map {
enabledFeatures.putAll(buttons.filter { it.info.shouldSave }.map {
it.title to it.toggled
})
}

View File

@ -18,7 +18,7 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
ClickGui.clickBoxes.find { box ->
it.let { impl ->
with(impl) {
if (info.kind == Type.TOGGLE && !info.parent.shouldHide) {
if (info.shouldSave && info.kind == Type.TOGGLE && !info.parent.shouldHide) {
Configuration.enabledFeatures[title]?.let { bool ->
toggled = bool
}
@ -55,7 +55,7 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) {
field = value
hidden = value
}
private val info = this::class.findAnnotation<ButtonInfo>() ?: throw Exception("Missing @ButtonInfo annotaton")
internal val info = this::class.findAnnotation<ButtonInfo>() ?: throw Exception("Missing @ButtonInfo annotaton")
override var color = info.parent.categoryColor; get() {
return info.parent.box.color.let {
if (field == it) field else it

View File

@ -12,6 +12,7 @@ import net.minecraft.network.chat.TranslatableComponent
annotation class ButtonInfo(
val parent: Category,
val kind: Type = Type.TOGGLE,
val shouldSave: Boolean = true, /** Whether or not the state of the button should be saved */
val ignored: Boolean = false /** Excludes a class from button collection */
) {
companion object {

View File

@ -3,7 +3,7 @@ package fr.username404.snowygui.gui.feature
import fr.username404.snowygui.config.Configuration
import net.minecraft.client.Minecraft
@ButtonInfo(Category.MISC)
@ButtonInfo(Category.MISC, shouldSave = false)
object Zoom: ButtonImpl() {
internal var smoothCameraOnZoom: Boolean by Configuration
internal var zoomFactor: Double by Configuration