diff options
author | msg-programs <msgdoesstuff@gmail.com> | 2023-08-06 18:48:52 +0200 |
---|---|---|
committer | msg-programs <msgdoesstuff@gmail.com> | 2023-08-06 18:48:52 +0200 |
commit | f43d26234cb60650af020be7690c0d0b43771c09 (patch) | |
tree | 8b5b8964ea1cb9df547cd1f09f6a7e4de07f4e6a /src/main/java/me/xmrvizzy/skyblocker/skyblock | |
parent | 11c921b7fa882d26a1ac8640fae121f43727984a (diff) | |
download | Skyblocker-f43d26234cb60650af020be7690c0d0b43771c09.tar.gz Skyblocker-f43d26234cb60650af020be7690c0d0b43771c09.tar.bz2 Skyblocker-f43d26234cb60650af020be7690c0d0b43771c09.zip |
Introduce layout constants, make padding to screen bigger
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock')
6 files changed, 35 insertions, 25 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java index 64ec4289..5c4351fd 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/ScreenMaster.java @@ -1,6 +1,5 @@ package me.xmrvizzy.skyblocker.skyblock.tabhud.screenbuilder; -import java.util.ArrayList; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/AlignStage.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/AlignStage.java index 93a11190..0f2e4107 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/AlignStage.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/AlignStage.java @@ -6,6 +6,7 @@ import java.util.NoSuchElementException; import com.google.gson.JsonObject; import me.xmrvizzy.skyblocker.skyblock.tabhud.screenbuilder.ScreenBuilder; +import me.xmrvizzy.skyblocker.skyblock.tabhud.util.ScreenConst; import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.Widget; public class AlignStage extends PipelineStage { @@ -61,31 +62,31 @@ public class AlignStage extends PipelineStage { break; case LEFTCENT: wHalf = screenW / 2; - wid.setX(wHalf - 3 - wid.getWidth()); + wid.setX(wHalf - ScreenConst.WIDGET_PAD_HALF - wid.getWidth()); break; case RIGHTCENT: wHalf = screenW / 2; - wid.setX(wHalf + 3); + wid.setX(wHalf + ScreenConst.WIDGET_PAD_HALF); break; case TOPCENT: hHalf = screenH / 2; - wid.setY(hHalf - 3 - wid.getHeight()); + wid.setY(hHalf - ScreenConst.WIDGET_PAD_HALF - wid.getHeight()); break; case BOTCENT: hHalf = screenH / 2; - wid.setY(hHalf + 3); + wid.setY(hHalf + ScreenConst.WIDGET_PAD_HALF); break; case TOP: - wid.setY(5); + wid.setY(ScreenConst.SCREEN_PAD); break; case BOT: - wid.setY(screenH - wid.getHeight() - 5); + wid.setY(screenH - wid.getHeight() - ScreenConst.SCREEN_PAD); break; case LEFT: - wid.setX(5); + wid.setX(ScreenConst.SCREEN_PAD); break; case RIGHT: - wid.setX(screenW - wid.getWidth() - 5); + wid.setX(screenW - wid.getWidth() - ScreenConst.SCREEN_PAD); break; } } 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 837d1da4..e2911070 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 @@ -6,6 +6,7 @@ import java.util.NoSuchElementException; import com.google.gson.JsonObject; import me.xmrvizzy.skyblocker.skyblock.tabhud.screenbuilder.ScreenBuilder; +import me.xmrvizzy.skyblocker.skyblock.tabhud.util.ScreenConst; import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.Widget; public class CollideStage extends PipelineStage { @@ -65,17 +66,17 @@ public class CollideStage extends PipelineStage { // assume others to be sorted top-bottom. for (Widget other : secondary) { - if (other.getY() + other.getHeight() + 5 < yMin) { + if (other.getY() + other.getHeight() + ScreenConst.WIDGET_PAD < yMin) { // too high, next one continue; } - if (other.getY() - 5 > yMax) { + if (other.getY() - ScreenConst.WIDGET_PAD > yMax) { // too low, next continue; } - int xPos = other.getX() - 5 - w.getWidth(); + int xPos = other.getX() - ScreenConst.WIDGET_PAD - w.getWidth(); xCor = Math.min(xCor, xPos); } w.setX(xCor); @@ -89,17 +90,17 @@ public class CollideStage extends PipelineStage { // assume others to be sorted top-bottom. for (Widget other : secondary) { - if (other.getY() + other.getHeight() + 5 < yMin) { + if (other.getY() + other.getHeight() + ScreenConst.WIDGET_PAD < yMin) { // too high, next one continue; } - if (other.getY() - 5 > yMax) { + if (other.getY() - ScreenConst.WIDGET_PAD > yMax) { // too low, next continue; } - int xPos = other.getX() + other.getWidth() + 5; + int xPos = other.getX() + other.getWidth() + ScreenConst.WIDGET_PAD; xCor = Math.max(xCor, xPos); } w.setX(xCor); diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/PlaceStage.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/PlaceStage.java index 94e0ac07..0f91a161 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/PlaceStage.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/PlaceStage.java @@ -6,6 +6,7 @@ import java.util.NoSuchElementException; import com.google.gson.JsonObject; import me.xmrvizzy.skyblocker.skyblock.tabhud.screenbuilder.ScreenBuilder; +import me.xmrvizzy.skyblocker.skyblock.tabhud.util.ScreenConst; import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.Widget; public class PlaceStage extends PipelineStage { @@ -52,7 +53,7 @@ public class PlaceStage extends PipelineStage { break; case TOPCENT: wid.setX((screenW - wid.getWidth()) / 2); - wid.setY(5); + wid.setY(ScreenConst.SCREEN_PAD); break; } } diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/StackStage.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/StackStage.java index 9fe83601..b614caef 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/StackStage.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/screenbuilder/pipeline/StackStage.java @@ -6,6 +6,7 @@ import java.util.NoSuchElementException; import com.google.gson.JsonObject; import me.xmrvizzy.skyblocker.skyblock.tabhud.screenbuilder.ScreenBuilder; +import me.xmrvizzy.skyblocker.skyblock.tabhud.util.ScreenConst; import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.Widget; public class StackStage extends PipelineStage { @@ -78,41 +79,41 @@ public class StackStage extends PipelineStage { } public void stackWidgetsVert(int screenH) { - int compHeight = -5; + int compHeight = -ScreenConst.WIDGET_PAD; for (Widget wid : primary) { compHeight += wid.getHeight() + 5; } int y = switch (this.align) { - case TOP -> y = 5; - case BOT -> y = (screenH - compHeight) - 5; + case TOP -> y = ScreenConst.SCREEN_PAD; + case BOT -> y = (screenH - compHeight) - ScreenConst.SCREEN_PAD; default -> y = (screenH - compHeight) / 2; }; for (Widget wid : primary) { wid.setY(y); - y += wid.getHeight() + 5; + y += wid.getHeight() + ScreenConst.WIDGET_PAD; } } public void stackWidgetsHoriz(int screenW) { // TODO not centered (?) - int compWidth = -5; + int compWidth = -ScreenConst.WIDGET_PAD; for (Widget wid : primary) { - compWidth += wid.getWidth() + 5; + compWidth += wid.getWidth() + ScreenConst.WIDGET_PAD; } int x = switch (this.align) { - case LEFT-> x = 5; - case RIGHT -> x = (screenW - compWidth) - 5; + case LEFT-> x = ScreenConst.SCREEN_PAD; + case RIGHT -> x = (screenW - compWidth) - ScreenConst.SCREEN_PAD; default -> x = (screenW - compWidth) / 2; }; for (Widget wid : primary) { wid.setX(x); - x += wid.getWidth() + 5; + x += wid.getWidth() + ScreenConst.WIDGET_PAD; } } }
\ No newline at end of file diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/ScreenConst.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/ScreenConst.java new file mode 100644 index 00000000..8788c017 --- /dev/null +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/ScreenConst.java @@ -0,0 +1,7 @@ +package me.xmrvizzy.skyblocker.skyblock.tabhud.util; + +public class ScreenConst { + public static final int WIDGET_PAD = 5; + public static final int WIDGET_PAD_HALF = 3; + public static final int SCREEN_PAD = 10; +} |