diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-24 22:53:48 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-24 22:53:48 +0100 |
commit | 3fec4abfc623771237fe093fdd1b66873491b0bb (patch) | |
tree | a668a9bd60054027937499b7becb16bafc758fcb /src/main/java/at | |
parent | 2bcde66ce1c01ea6da785e422c46c6f178ca10c2 (diff) | |
download | skyhanni-3fec4abfc623771237fe093fdd1b66873491b0bb.tar.gz skyhanni-3fec4abfc623771237fe093fdd1b66873491b0bb.tar.bz2 skyhanni-3fec4abfc623771237fe093fdd1b66873491b0bb.zip |
reverted wrongly removed code
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java | 20 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt | 26 |
2 files changed, 30 insertions, 16 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java b/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java index 9213408e4..1e58bfa9f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java +++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java @@ -60,10 +60,6 @@ public class Position { return position; } -// public boolean isCenterX() { -// return ; -// } - public int getRawX() { return x; } @@ -107,7 +103,7 @@ public class Position { return ret; } - public int moveX(int deltaX) { + public int moveX(int deltaX, int objWidth) { int screenWidth = new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth(); boolean wasPositiveX = this.x >= 0; this.x += deltaX; @@ -132,10 +128,16 @@ public class Position { } } + if (this.x >= 0 && this.x + objWidth / 2 > screenWidth / 2) { + this.x -= screenWidth - objWidth; + } + if (this.x < 0 && this.x + objWidth / 2 <= -screenWidth / 2) { + this.x += screenWidth - objWidth; + } return deltaX; } - public int moveY(int deltaY) { + public int moveY(int deltaY, int objHeight) { int screenHeight = new ScaledResolution(Minecraft.getMinecraft()).getScaledHeight(); boolean wasPositiveY = this.y >= 0; this.y += deltaY; @@ -160,6 +162,12 @@ public class Position { } } + if (this.y >= 0 && this.y - objHeight / 2 > screenHeight / 2) { + this.y -= screenHeight - objHeight; + } + if (this.y < 0 && this.y - objHeight / 2 <= -screenHeight / 2) { + this.y += screenHeight - objHeight; + } return deltaY; } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt index 44672ff46..8bcce9055 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt @@ -90,15 +90,17 @@ class GuiPositionEditor( mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1 for (position in positions) { + var elementWidth = position.getDummySize(true).x + var elementHeight = position.getDummySize(true).y if (position.clicked) { - grabbedX += position.moveX(mouseX - grabbedX) - grabbedY += position.moveY(mouseY - grabbedY) + grabbedX += position.moveX(mouseX - grabbedX, elementWidth) + grabbedY += position.moveY(mouseY - grabbedY, elementHeight) } val x = position.getAbsX() val y = position.getAbsY() - val elementWidth = position.getDummySize().x - val elementHeight = position.getDummySize().y + elementWidth = position.getDummySize().x + elementHeight = position.getDummySize().y drawRect(x - border, y - border, x + elementWidth + border * 2, y + elementHeight + border * 2, -0x7fbfbfc0) } @@ -182,14 +184,16 @@ class GuiPositionEditor( } else if (!position.clicked) { val shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) val dist = if (shiftHeld) 10 else 1 + val elementWidth = position.getDummySize(true).x + val elementHeight = position.getDummySize(true).y if (keyCode == Keyboard.KEY_DOWN) { - position.moveY(dist) + position.moveY(dist, elementHeight) } else if (keyCode == Keyboard.KEY_UP) { - position.moveY(-dist) + position.moveY(-dist, elementHeight) } else if (keyCode == Keyboard.KEY_LEFT) { - position.moveX(-dist) + position.moveX(-dist, elementWidth,) } else if (keyCode == Keyboard.KEY_RIGHT) { - position.moveX(dist) + position.moveX(dist, elementWidth) } } } @@ -212,8 +216,10 @@ class GuiPositionEditor( if (position.clicked) { mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1 - grabbedX += position.moveX(mouseX - grabbedX) - grabbedY += position.moveY(mouseY - grabbedY) + val elementWidth = position.getDummySize(true).x + val elementHeight = position.getDummySize(true).y + grabbedX += position.moveX(mouseX - grabbedX, elementWidth) + grabbedY += position.moveY(mouseY - grabbedY, elementHeight) Utils.pushGuiScale(-1) } } |