Add (buggy) movement of components in the ClickGui class.

This commit is contained in:
Username404-59 2021-04-12 15:06:35 +02:00
parent c06535047c
commit 7f916d82bb
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 15 additions and 1 deletions

View File

@ -6,9 +6,23 @@ import fr.username404.snowygui.gui.SnowyScreen
import net.minecraft.network.chat.TranslatableComponent import net.minecraft.network.chat.TranslatableComponent
class ClickGui: SnowyScreen() { class ClickGui: SnowyScreen() {
private companion object {
var GuiDragging: Boolean = false
}
override val components: MutableSet<Element> = mutableSetOf( override val components: MutableSet<Element> = mutableSetOf(
ClickBox(4.0, 4.0, TranslatableComponent("snowy.clickbox.misc")), ClickBox(4.0, 4.0, TranslatableComponent("snowy.clickbox.misc")),
ClickBox(90.0, 4.0, TranslatableComponent("snowy.clickbox.rendering")) ClickBox(90.0, 4.0, TranslatableComponent("snowy.clickbox.rendering"))
// TODO Add components to the ClickGui
) )
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 + (d - (it.x + it.width))
it.y = e + (e - (it.y + it.height))
} else GuiDragging = false
}
}
return false
}
} }