26 lines
1.0 KiB
Kotlin
26 lines
1.0 KiB
Kotlin
package fr.username404.snowygui
|
|
|
|
import fr.username404.snowygui.gui.ClickBox
|
|
import fr.username404.snowygui.gui.Element
|
|
import fr.username404.snowygui.gui.SnowyScreen
|
|
import net.minecraft.network.chat.TranslatableComponent
|
|
|
|
object ClickGui: SnowyScreen() {
|
|
private var GuiDragging: Boolean = false
|
|
override val components: MutableSet<Element> = mutableSetOf(
|
|
ClickBox(4.0, 4.0, TranslatableComponent("snowy.clickbox.misc")),
|
|
ClickBox(90.0, 4.0, TranslatableComponent("snowy.clickbox.rendering"))
|
|
)
|
|
override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean {
|
|
if (i == 0) {
|
|
components.forEach {
|
|
if (((d >= it.x) && (d <= (it.x + it.width))) and ((e >= it.y) && (e <= (it.y + it.height))) and !GuiDragging) {
|
|
GuiDragging = true
|
|
it.x = d.minus(f) + (d - (it.x + it.width))
|
|
it.y = e.minus(g) + (e - (it.y + it.height))
|
|
} else GuiDragging = false
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
} |