aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons/gui/MoveGui.kt
diff options
context:
space:
mode:
authorAppability <appable@icloud.com>2022-10-23 12:00:05 -0700
committerAppability <appable@icloud.com>2022-10-23 12:00:05 -0700
commit0576a7f5304565bb58a499b8ccdcda31ed587dc4 (patch)
tree766fad4c88ec8be5b142e338f097b67aa7322234 /src/main/kotlin/com/ambientaddons/gui/MoveGui.kt
parent4f25e7948c7e85151a80c17f7d2b25b72675cecf (diff)
downloadAmbientAddons-0576a7f5304565bb58a499b8ccdcda31ed587dc4.tar.gz
AmbientAddons-0576a7f5304565bb58a499b8ccdcda31ed587dc4.tar.bz2
AmbientAddons-0576a7f5304565bb58a499b8ccdcda31ed587dc4.zip
ping command and display
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/gui/MoveGui.kt')
-rw-r--r--src/main/kotlin/com/ambientaddons/gui/MoveGui.kt5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main/kotlin/com/ambientaddons/gui/MoveGui.kt b/src/main/kotlin/com/ambientaddons/gui/MoveGui.kt
index 33c96e7..61bb41b 100644
--- a/src/main/kotlin/com/ambientaddons/gui/MoveGui.kt
+++ b/src/main/kotlin/com/ambientaddons/gui/MoveGui.kt
@@ -11,6 +11,7 @@ import net.minecraft.client.renderer.GlStateManager
import org.lwjgl.input.Mouse
import org.lwjgl.opengl.Display
import java.awt.Color
+import kotlin.math.sign
class MoveGui : GuiScreen() {
private var currentElement: GuiElement? = null
@@ -53,12 +54,12 @@ class MoveGui : GuiScreen() {
override fun handleMouseInput() {
super.handleMouseInput()
val (mouseX, mouseY) = getMouseCoordinates()
+ val dScroll = (Mouse.getEventDWheel().sign * 0.1).takeIf { it != 0.0 } ?: return
currentElement = guiElements.find { it.isInsideElement(mouseX, mouseY) }?.apply {
clickOffsetX = mouseX - position.x
clickOffsetY = mouseY - position.y
- val scrollAmount = Mouse.getEventDWheel()
val oldScale = position.scale
- val newScale = (position.scale + scrollAmount / 7200.0).coerceAtLeast(0.1)
+ val newScale = (position.scale + dScroll).coerceAtLeast(0.1)
position.x = mouseX + (newScale / oldScale) * (position.x - mouseX)
position.y = mouseY + (newScale / oldScale) * (position.y - mouseY)
position.scale = newScale