Add receivers to ClickGui.kt too
This commit is contained in:
parent
f4a16a10d2
commit
f8fbf1eb09
|
@ -19,11 +19,11 @@ object ClickGui: SnowyScreen() {
|
|||
override val components = mutableSetOf<Element>()
|
||||
internal fun addComps(vararg toAdd: Element) = components.addAll(toAdd)
|
||||
|
||||
inline fun boxContext(args: (ClickBox) -> Unit) = components.filterIsInstance<ClickBox>().forEach(args)
|
||||
private inline fun buttonsContext(args: (ClickButton) -> Unit) = boxContext { it.buttons.values.forEach(args) }
|
||||
override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { buttonsContext { it.mouseClicked(d, e, i) }; return false }
|
||||
override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { it.mouseReleased(d, e, i) }; return false }
|
||||
override fun mouseScrolled(d: Double, e: Double, f: Double): Boolean { boxContext { it.scroll(d, e, f) }; return false }
|
||||
inline fun boxContext(args: ClickBox.() -> Unit) = components.filterIsInstance<ClickBox>().forEach(args)
|
||||
private inline fun buttonsContext(args: ClickButton.() -> Unit) = boxContext { buttons.values.forEach(args) }
|
||||
override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { buttonsContext { mouseClicked(d, e, i) }; return false }
|
||||
override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { mouseReleased(d, e, i) }; return false }
|
||||
override fun mouseScrolled(d: Double, e: Double, f: Double): Boolean { boxContext { scroll(d, e, f) }; return false }
|
||||
override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean {
|
||||
if (i == 0) {
|
||||
components.forEach {
|
||||
|
|
Loading…
Reference in New Issue