From a973d8c00154333bdff3012329690b2d6b506f68 Mon Sep 17 00:00:00 2001 From: Username404 Date: Sun, 23 May 2021 11:10:43 +0200 Subject: [PATCH] Only show ClickBoxes when they have buttons --- common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt | 2 +- .../kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt index a4a0054..5b91957 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt @@ -40,7 +40,7 @@ abstract class Element( } } } - fun display(stack: PoseStack? = null) { + open fun display(stack: PoseStack? = null) { if (!hidden && !caughtError) try { render(stack) } catch (t: Throwable) { diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt index 6501475..c365604 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt @@ -22,6 +22,10 @@ class ClickBox( val name: TranslatableComponent? = null ): ColoredElement(x, y, 80, 10, color, 0.5F) { val buttons = mutableSetOf() + override fun display(stack: PoseStack?) { + hidden = buttons.isEmpty() || hidden + super.display(stack) + } @JvmField val buttonsProgressBar: ColoredElement = object: ColoredElement( (x + width), y + height + 3,