Improve the ClickGui.boxContext() method
This commit is contained in:
parent
c992b24b16
commit
1b4037be02
|
@ -10,7 +10,7 @@ object ClickGui: SnowyScreen() {
|
||||||
override val components = mutableSetOf<Element>()
|
override val components = mutableSetOf<Element>()
|
||||||
|
|
||||||
val clickBoxes get() = components.filterIsInstance<ClickBox>()
|
val clickBoxes get() = components.filterIsInstance<ClickBox>()
|
||||||
inline fun boxContext(args: ClickBox.() -> Unit) = components.filterIsInstance<ClickBox>().forEach(args)
|
inline fun boxContext(args: ClickBox.() -> Unit) = clickBoxes.forEach(args)
|
||||||
private inline fun buttonsContext(args: ColoredElement.() -> Unit) = boxContext { buttons.forEach(args) }
|
private inline fun buttonsContext(args: ColoredElement.() -> Unit) = boxContext { buttons.forEach(args) }
|
||||||
override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseClicked(d, e, i) }; return false }
|
override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseClicked(d, e, i) }; return false }
|
||||||
override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseReleased(d, e, i) }; return false }
|
override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseReleased(d, e, i) }; return false }
|
||||||
|
|
Loading…
Reference in New Issue