Add a addBox() method to the Category enum class and complete the constructor that uses a ClickBox

This commit is contained in:
Username404 2021-06-25 16:37:35 +02:00
parent dbc7f6b8bf
commit 1ac22a7e97
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 8 additions and 3 deletions

View File

@ -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() }
}
}
}