Add a shouldSave property to the ButtonInfo annotation class
This commit is contained in:
parent
520f14ced9
commit
d70dae6da1
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue