aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/CollideStage.java58
-rw-r--r--src/main/resources/assets/skyblocker/tabhud/readme.md2
2 files changed, 56 insertions, 4 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/CollideStage.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/CollideStage.java
index e2911070..187dc9f9 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/CollideStage.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/CollideStage.java
@@ -13,7 +13,9 @@ public class CollideStage extends PipelineStage {
private enum CollideDirection {
LEFT("left"),
- RIGHT("right");
+ RIGHT("right"),
+ TOP("top"),
+ BOT("bot");
private String str;
@@ -55,6 +57,12 @@ public class CollideStage extends PipelineStage {
case RIGHT:
primary.forEach(w -> collideAgainstR(screenW, w));
break;
+ case TOP:
+ primary.forEach(w -> collideAgainstT(screenH, w));
+ break;
+ case BOT:
+ primary.forEach(w -> collideAgainstB(screenH, w));
+ break;
}
}
@@ -64,7 +72,6 @@ public class CollideStage extends PipelineStage {
int xCor = screenW / 2;
- // assume others to be sorted top-bottom.
for (Widget other : secondary) {
if (other.getY() + other.getHeight() + ScreenConst.WIDGET_PAD < yMin) {
// too high, next one
@@ -88,7 +95,6 @@ public class CollideStage extends PipelineStage {
int xCor = screenW / 2;
- // assume others to be sorted top-bottom.
for (Widget other : secondary) {
if (other.getY() + other.getHeight() + ScreenConst.WIDGET_PAD < yMin) {
// too high, next one
@@ -106,4 +112,50 @@ public class CollideStage extends PipelineStage {
w.setX(xCor);
}
+ public void collideAgainstT(int screenH, Widget w) {
+ int xMin = w.getX();
+ int xMax = w.getX() + w.getWidth();
+
+ int yCor = screenH / 2;
+
+ for (Widget other : secondary) {
+ if (other.getX() + other.getWidth() + ScreenConst.WIDGET_PAD < xMin) {
+ // too far left, next one
+ continue;
+ }
+
+ if (other.getX() - ScreenConst.WIDGET_PAD > xMax) {
+ // too far right, next
+ continue;
+ }
+
+ int yPos = other.getY() - ScreenConst.WIDGET_PAD - w.getHeight();
+ yCor = Math.min(yCor, yPos);
+ }
+ w.setY(yCor);
+ }
+
+ public void collideAgainstB(int screenH, Widget w) {
+ int xMin = w.getX();
+ int xMax = w.getX() + w.getWidth();
+
+ int yCor = screenH / 2;
+
+ for (Widget other : secondary) {
+ if (other.getX() + other.getWidth() + ScreenConst.WIDGET_PAD < xMin) {
+ // too far left, next one
+ continue;
+ }
+
+ if (other.getX() - ScreenConst.WIDGET_PAD > xMax) {
+ // too far right, next
+ continue;
+ }
+
+ int yPos = other.getY() + other.getHeight() + ScreenConst.WIDGET_PAD;
+ yCor = Math.max(yCor, yPos);
+ }
+ w.setY(yCor);
+ }
+
}
diff --git a/src/main/resources/assets/skyblocker/tabhud/readme.md b/src/main/resources/assets/skyblocker/tabhud/readme.md
index 8ba473fd..800a69d2 100644
--- a/src/main/resources/assets/skyblocker/tabhud/readme.md
+++ b/src/main/resources/assets/skyblocker/tabhud/readme.md
@@ -133,7 +133,7 @@ Example: align A and B with "horizontalCenter"
#### Collide
- op: `collideAgainst`
-- direction: One of `left`, `right`
+- direction: One of `left`, `right`, `top`, `bot`
- widgets: List of widgets to individually move.
- colliders: List static reference widgets to "collide against".
- Moves a widget in the `direction` until it would overlap with any one of the colliders. Doesn't move the widget in the other direction, doesn't move the widget if it wouldn't collide with anything.