Make ClickBox.buttons a map

This commit is contained in:
Username404-59 2021-05-01 20:18:46 +02:00
parent 8a65839816
commit 9dc097d32f
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1

View File

@ -15,9 +15,9 @@ import org.lwjgl.opengl.GL20
class ClickBox( class ClickBox(
x: Double, y: Double, x: Double, y: Double,
private val name: TranslatableComponent? = null, private val name: TranslatableComponent? = null
val buttons: MutableCollection<ClickButton> = mutableSetOf()
): ColoredElement(x, y, 80, 10, 0x6C9E9D, 0.5F) { ): ColoredElement(x, y, 80, 10, 0x6C9E9D, 0.5F) {
val buttons = mutableMapOf<String, ClickButton>()
@JvmField @JvmField
val scrollBar: ColoredElement = object: ColoredElement( val scrollBar: ColoredElement = object: ColoredElement(
(x + width), y + height + 3, (x + width), y + height + 3,
@ -70,7 +70,7 @@ class ClickBox(
x = this@ClickBox.x + this@ClickBox.width - 3 x = this@ClickBox.x + this@ClickBox.width - 3
y = this@ClickBox.y + this@ClickBox.height + 3 y = this@ClickBox.y + this@ClickBox.height + 3
}.display(poseStack) }.display(poseStack)
buttons.forEachIndexed { num, it -> buttons.values.forEachIndexed { num, it ->
it.apply { it.apply {
it.x = this@ClickBox.x + 3 it.x = this@ClickBox.x + 3
it.y = this@ClickBox.y + 5 + height + (num * 9) it.y = this@ClickBox.y + 5 + height + (num * 9)