From 1ac22a7e970cdc05045b69765ef889e6770ba337 Mon Sep 17 00:00:00 2001 From: Username404 Date: Fri, 25 Jun 2021 16:37:35 +0200 Subject: [PATCH] Add a addBox() method to the Category enum class and complete the constructor that uses a ClickBox --- .../fr/username404/snowygui/gui/feature/ButtonInfo.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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() } } } }