diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt index ed45d33..2227149 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt @@ -36,13 +36,18 @@ annotation class ButtonInfo( name = TranslatableComponent(translationKey), color = categoryColor ); private set + private fun addBox() = ClickGui.components.add(box.apply { if (shouldHide) hidden = true }) constructor( translationKey: String, categoryColor: Colors, condition: Boolean = false ): this(translationKey, categoryColor.hexValue, condition) - constructor(box: ClickBox): this(translationKey = box.name.key, categoryColor = box.color) { this.box = box } - init { - ClickGui.components.add(box.apply { if (shouldHide) hidden = true }) + constructor(categoryBox: ClickBox): this(translationKey = categoryBox.name.key, categoryColor = categoryBox.color) { + with(ClickGui.components) { + remove(this@Category.box) + this@Category.box = categoryBox + addBox() + } } + init { addBox() } } } }