From 7f916d82bb56797b9b03a892ea1cdd7c9bfcfc6e Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Mon, 12 Apr 2021 15:06:35 +0200 Subject: [PATCH] Add (buggy) movement of components in the ClickGui class. --- .../kotlin/fr/username404/snowygui/ClickGui.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt index 509e8b4..644fedd 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt @@ -6,9 +6,23 @@ import fr.username404.snowygui.gui.SnowyScreen import net.minecraft.network.chat.TranslatableComponent class ClickGui: SnowyScreen() { + private companion object { + var GuiDragging: Boolean = false + } override val components: MutableSet = mutableSetOf( ClickBox(4.0, 4.0, TranslatableComponent("snowy.clickbox.misc")), 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 + } } \ No newline at end of file