diff options
author | Yasin <a.piri@hotmail.de> | 2024-05-08 01:57:08 +0200 |
---|---|---|
committer | Yasin <a.piri@hotmail.de> | 2024-05-08 01:57:08 +0200 |
commit | 9b27b4cbd8899ada89fd0a47f33ef4b717db5637 (patch) | |
tree | de3459c0c53dfa0f8e8bc990097eafb1e21e86c1 /src/main/java/de/hysky/skyblocker/utils/render/title | |
parent | f8a187651000739b256bfbe4d50d671e0b8744e6 (diff) | |
download | Skyblocker-9b27b4cbd8899ada89fd0a47f33ef4b717db5637.tar.gz Skyblocker-9b27b4cbd8899ada89fd0a47f33ef4b717db5637.tar.bz2 Skyblocker-9b27b4cbd8899ada89fd0a47f33ef4b717db5637.zip |
reorder configs
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils/render/title')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java | 27 | ||||
-rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java | 35 |
2 files changed, 30 insertions, 32 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java index 7a2ea60a..c21485e2 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java @@ -1,8 +1,7 @@ package de.hysky.skyblocker.utils.render.title; -import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.config.configs.UiAndVisualsConfig; +import de.hysky.skyblocker.config.configs.UIAndVisualsConfig; import de.hysky.skyblocker.events.HudRenderEvents; import de.hysky.skyblocker.utils.scheduler.Scheduler; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; @@ -94,8 +93,8 @@ public class TitleContainer { float scale = 3F * (SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale / 100F); // Grab direction and alignment values - UiAndVisualsConfig.Direction direction = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; - UiAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; + UIAndVisualsConfig.Direction direction = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; + UIAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; // x/y refer to the starting position for the text // y always starts at yPos float x = 0; @@ -107,8 +106,8 @@ public class TitleContainer { width += textRenderer.getWidth(title.getText()) * scale + 10; } - if (alignment == UiAndVisualsConfig.Alignment.MIDDLE) { - if (direction == UiAndVisualsConfig.Direction.HORIZONTAL) { + if (alignment == UIAndVisualsConfig.Alignment.MIDDLE) { + if (direction == UIAndVisualsConfig.Direction.HORIZONTAL) { //If middle aligned horizontally, start the xPosition at half of the width to the left. x = xPos - (width / 2); } else { @@ -116,7 +115,7 @@ public class TitleContainer { x = xPos; } } - if (alignment == UiAndVisualsConfig.Alignment.LEFT || alignment == UiAndVisualsConfig.Alignment.RIGHT) { + if (alignment == UIAndVisualsConfig.Alignment.LEFT || alignment == UIAndVisualsConfig.Alignment.RIGHT) { //If left or right aligned, start at xPos, we will shift each text later x = xPos; } @@ -125,14 +124,14 @@ public class TitleContainer { //Calculate which x the text should use float xToUse; - if (direction == UiAndVisualsConfig.Direction.HORIZONTAL) { - xToUse = alignment == UiAndVisualsConfig.Alignment.RIGHT ? + if (direction == UIAndVisualsConfig.Direction.HORIZONTAL) { + xToUse = alignment == UIAndVisualsConfig.Alignment.RIGHT ? x - (textRenderer.getWidth(title.getText()) * scale) : //if right aligned we need the text position to be aligned on the right side. x; } else { - xToUse = alignment == UiAndVisualsConfig.Alignment.MIDDLE ? + xToUse = alignment == UIAndVisualsConfig.Alignment.MIDDLE ? x - (textRenderer.getWidth(title.getText()) * scale) / 2 : //if middle aligned we need the text position to be aligned in the middle. - alignment == UiAndVisualsConfig.Alignment.RIGHT ? + alignment == UIAndVisualsConfig.Alignment.RIGHT ? x - (textRenderer.getWidth(title.getText()) * scale) : //if right aligned we need the text position to be aligned on the right side. x; } @@ -157,13 +156,13 @@ public class TitleContainer { context.getMatrices().pop(); //Calculate the x and y positions for the next title - if (direction == UiAndVisualsConfig.Direction.HORIZONTAL) { - if (alignment == UiAndVisualsConfig.Alignment.MIDDLE || alignment == UiAndVisualsConfig.Alignment.LEFT) { + if (direction == UIAndVisualsConfig.Direction.HORIZONTAL) { + if (alignment == UIAndVisualsConfig.Alignment.MIDDLE || alignment == UIAndVisualsConfig.Alignment.LEFT) { //Move to the right if middle or left aligned x += textRenderer.getWidth(title.getText()) * scale + 10; } - if (alignment == UiAndVisualsConfig.Alignment.RIGHT) { + if (alignment == UIAndVisualsConfig.Alignment.RIGHT) { //Move to the left if right aligned x -= textRenderer.getWidth(title.getText()) * scale + 10; } diff --git a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java index 6a66faad..e5cf6f80 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java @@ -1,8 +1,7 @@ package de.hysky.skyblocker.utils.render.title; -import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; -import de.hysky.skyblocker.config.configs.UiAndVisualsConfig; +import de.hysky.skyblocker.config.configs.UIAndVisualsConfig; import de.hysky.skyblocker.utils.render.RenderHelper; import dev.isxander.yacl3.api.ConfigCategory; import dev.isxander.yacl3.api.Option; @@ -43,8 +42,8 @@ public class TitleContainerConfigScreen extends Screen { super.render(context, mouseX, mouseY, delta); renderBackground(context, mouseX, mouseY, delta); TitleContainer.render(context, Set.of(example1, example2, example3), (int) hudX, (int) hudY, delta); - UiAndVisualsConfig.Direction direction = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; - UiAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; + UIAndVisualsConfig.Direction direction = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; + UIAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; context.drawCenteredTextWithShadow(textRenderer, "Press Q/E to change Alignment: " + alignment, width / 2, textRenderer.fontHeight * 2, Color.WHITE.getRGB()); context.drawCenteredTextWithShadow(textRenderer, "Press R to change Direction: " + direction, width / 2, textRenderer.fontHeight * 3 + 5, Color.WHITE.getRGB()); context.drawCenteredTextWithShadow(textRenderer, "Press +/- to change Scale", width / 2, textRenderer.fontHeight * 4 + 10, Color.WHITE.getRGB()); @@ -63,7 +62,7 @@ public class TitleContainerConfigScreen extends Screen { } private Pair<Vector2f, Vector2f> getSelectionBoundingBox() { - UiAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; + UIAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; float midWidth = getSelectionWidth() / 2F; float x1 = 0; @@ -89,14 +88,14 @@ public class TitleContainerConfigScreen extends Screen { private float getSelectionHeight() { float scale = (3F * (SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale / 100F)); - return SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction == UiAndVisualsConfig.Direction.HORIZONTAL ? + return SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction == UIAndVisualsConfig.Direction.HORIZONTAL ? (textRenderer.fontHeight * scale) : (textRenderer.fontHeight + 10F) * 3F * scale; } private float getSelectionWidth() { float scale = (3F * (SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale / 100F)); - return SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction == UiAndVisualsConfig.Direction.HORIZONTAL ? + return SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction == UIAndVisualsConfig.Direction.HORIZONTAL ? (textRenderer.getWidth("Test1") + 10 + textRenderer.getWidth("Test23") + 10 + textRenderer.getWidth("Testing1234")) * scale : textRenderer.getWidth("Testing1234") * scale; } @@ -136,26 +135,26 @@ public class TitleContainerConfigScreen extends Screen { @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (keyCode == GLFW.GLFW_KEY_Q) { - UiAndVisualsConfig.Alignment current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; + UIAndVisualsConfig.Alignment current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment = switch (current) { - case LEFT -> UiAndVisualsConfig.Alignment.MIDDLE; - case MIDDLE -> UiAndVisualsConfig.Alignment.RIGHT; - case RIGHT -> UiAndVisualsConfig.Alignment.LEFT; + case LEFT -> UIAndVisualsConfig.Alignment.MIDDLE; + case MIDDLE -> UIAndVisualsConfig.Alignment.RIGHT; + case RIGHT -> UIAndVisualsConfig.Alignment.LEFT; }; } if (keyCode == GLFW.GLFW_KEY_E) { - UiAndVisualsConfig.Alignment current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; + UIAndVisualsConfig.Alignment current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment = switch (current) { - case LEFT -> UiAndVisualsConfig.Alignment.RIGHT; - case MIDDLE -> UiAndVisualsConfig.Alignment.LEFT; - case RIGHT -> UiAndVisualsConfig.Alignment.MIDDLE; + case LEFT -> UIAndVisualsConfig.Alignment.RIGHT; + case MIDDLE -> UIAndVisualsConfig.Alignment.LEFT; + case RIGHT -> UIAndVisualsConfig.Alignment.MIDDLE; }; } if (keyCode == GLFW.GLFW_KEY_R) { - UiAndVisualsConfig.Direction current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; + UIAndVisualsConfig.Direction current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction = switch (current) { - case HORIZONTAL -> UiAndVisualsConfig.Direction.VERTICAL; - case VERTICAL -> UiAndVisualsConfig.Direction.HORIZONTAL; + case HORIZONTAL -> UIAndVisualsConfig.Direction.VERTICAL; + case VERTICAL -> UIAndVisualsConfig.Direction.HORIZONTAL; }; } if (keyCode == GLFW.GLFW_KEY_EQUAL) { |